• Categories
    • Unread
    • Recent
    • Popular
    • Users
    • Groups
    • Register
    • Login
    1. Home
    2. Schamper
    3. Topics
    Offline
    • Profile
    • Following 0
    • Followers 2
    • Topics 17
    • Posts 155
    • Groups 1

    Topics

    • SchamperS

      Far Cry 4's Honey badgers are OP as fuck, and the game knows it.

      Watching Ignoring Scheduled Pinned Locked Moved Gaming
      9
      9 Posts
      1k Views
      SchamperS
      http://xboxclips.com/Schamper/787339a8-987a-4410-a196-55a2ef2c5cc7
    • SchamperS

      Blog post for my internship

      Watching Ignoring Scheduled Pinned Locked Moved Development and Coding internship blog
      1
      1 Posts
      550 Views
      SchamperS
      My boss kept nagging me to make a short blog post about my internship project, so I did. Some of you might know that I’m having trouble getting feedback on my work, so I put in some comments about that in this post. Android application development I’ve been working on the Projectcampus Android application since September, and I must say I’ve learned a lot about Android and personally think the application is coming along nicely. ​​​It all started as a very simple list of hardcoded data, but gradually grew to make use of various Android components such as a Content Provider, Authenticator, Sync Adapter and even custom views. Besides these components I’ve learned about using various mainstream libraries such as Retrofit, OkHttp, Glide, Butterknife, Eventbus, Crashlytics and the Android Support Library. ​ Retrofit powers the REST communication with the Projectcampus backend in combination with EventBus. EventBus is exactly what it sounds like, an event bus. This makes it possible to launch a REST request from anywhere in the application and also to allow any part of the application to receive any REST response. EventBus is also used for other inner-application communication. Glide is an image loading and caching library used for the various images used throughout the application. All of the networking is backed by OkHttp.​ Butterknife is a view “injection” library for Android and is used to reduce the amount of boilerplate code. Crashlytics is used to report crashes and errors. The Android Support Library is used for a couple of things like Material support for API levels below 21, Toolbar and new Swipe Refresh Layout. ​ In the current structure, all REST request events are handled by a Retrofit client. This client posts all the results to the event bus. A database service listens to all the response events and writes these to the database through a content provider. Any fragment or activity subscribed to the affected URI’s will be automatically updated through the magic of cursor loaders. ​ I’ve also made sure to improve performance where I can. Making use of the View holder pattern, reducing layout XML complexity and depth and reducing overdraw are a few examples I can currently think of. I’m sure there are parts in my code that can be refactored to be more performant, but that’s hard to determine when you’re the only person looking at the code. ​ The application is also configurable at build time using gradle. There are several properties that can be set to configure the application, most important being the URLs and client ID for the API. There are also properties to disable certain features of the application. ​ All in all I’m fairly happy with the current state of the application. However, I also feel like it could be a lot better and further along if I had occasional feedback. A very large portion of my time has been spend redoing something I did the previous week. On the other hand, I’m also kind of proud of myself that I’ve managed to put together the application in its current state all by myself. [image: iqFWO8C.png]
    • SchamperS

      List of Python resources

      Watching Ignoring Scheduled Pinned Locked Moved Development and Coding python learning resources
      5
      5 Posts
      1k Views
      S
      @Scuzz They have an ebook version that looks good but I’ve not been able to find a download for it anywhere.
    • SchamperS

      The years YouTube Rewind

      Watching Ignoring Scheduled Pinned Locked Moved The lounge
      8
      8 Posts
      836 Views
      S
      From the people listed at the end I knew 27 of them; I watch too much YT. Still a shitload I’ve never heard of.
    • SchamperS

      nodebb-plugin-butt

      Watching Ignoring Scheduled Pinned Locked Moved Development and Coding nodebb plugin
      1
      1 Posts
      626 Views
      SchamperS
      About In protest of the removal of all my contest entries I have made a new plugin! I’m sure you are familiar with the cloud -> butt extensions for basically all major browsers out there… Well now there’s a NodeBB plugin for it as well! Bonus: you can even customize what words to change to butt in the ACP! Installation npm install nodebb-plugin-butt Source Github
    • SchamperS

      Messed something up in Git? Here's a flowchart on how to fix it!

      Watching Ignoring Scheduled Pinned Locked Moved General Computing git flowchart
      1
      1 Posts
      524 Views
      SchamperS
      [image: git-pretty.png] Source: http://justinhileman.info/article/git-pretty/
    • SchamperS

      Looking to build a new PC?

      Watching Ignoring Scheduled Pinned Locked Moved General Computing
      3
      3 Posts
      894 Views
      SchamperS
      @Scuzz Also pound.
    • SchamperS

      How the shoutbox client sockets work

      Watching Ignoring Scheduled Pinned Locked Moved Development and Coding
      1
      1 Posts
      729 Views
      SchamperS
      This is about the following file: sockets.js We need more posts, why not write something about how the shoutbox works? Could be interesting for some people I suppose :P The fun thing about the recent refactor of the client sockets is that you can call them by simple doing Shoutbox.sockets.<action>(data, callback);. This is possible because we add each message to the global Shoutbox.sockets object. Doing this for every single message would take a lot of time and code, especially with the recent addition of commands. So how do we do this? As you can see at the beginning of the file there are 2 objects with a bunch of method names as key and socket events as value, these names will later be used as the <action>: var Messages = { getShouts: 'plugins.shoutbox.get', sendShout: 'plugins.shoutbox.send', removeShout : 'plugins.shoutbox.remove', editShout: 'plugins.shoutbox.edit', notifyStartTyping: 'plugins.shoutbox.notifyStartTyping', notifyStopTyping: 'plugins.shoutbox.notifyStopTyping', getOriginalShout: 'plugins.shoutbox.getOriginalShout', saveSettings: 'plugins.shoutbox.saveSetting', getSettings: 'plugins.shoutbox.getSettings', getUsers: 'user.loadMore', getUserStatus: 'user.isOnline' }; var Events = { onUserStatusChange: Messages.getUserStatus, onReceive: 'event:shoutbox.receive', onDelete: 'event:shoutbox.delete', onEdit: 'event:shoutbox.edit', onStartTyping: 'event:shoutbox.startTyping', onStopTyping: 'event:shoutbox.stopTyping' }; These are the default messages and events we work with. Extra events or messages required for commands etc are defined by the command itself (we get to this later). After that we have a Handlers object, which essentially has all the default socket handlers required for the shoutbox to actually work. You can see some basic stuff ilke onReceive, onDelete etc. You can pretty much guess by their name what their function is. Interesting here is the defaultSocketHandler: var Handlers = { onReceive: ..., onDelete: ..., onEdit: ..., onUserStatusChange: .., onStartTyping: ..., onStopTyping: ..., defaultSocketHandler: function(message) { this.message = message; var self = this; return function (data, callback) { if (typeof data === 'function') { callback = data; data = null; } socket.emit(self.message, data, callback); }; } }; In the next bit I explain how the defaultSocketHandler works. At the very end of the file we find what we actually “expose” to the public/global Shoutbox object. Shoutbox.sockets = { messages: Messages, events: Events, registerMessage: function(handle, message) { if (!Shoutbox.sockets.hasOwnProperty(handle)) { Shoutbox.sockets[handle] = new Handlers.defaultSocketHandler(message); } }, registerEvent: function(event, handler) { if (socket.listeners(event).length === 0) { socket.on(event, handler); } }, initialize: function() { for (var e in Events) { if (Events.hasOwnProperty(e)) { this.registerEvent(Events[e], Handlers[e]); } } for (var m in Messages) { if (Messages.hasOwnProperty(m)) { this.registerMessage(m, Messages[m]); } } } }; The first two keys, messages and events simply expose the default messages and events that we talked about at the beginning. registerMessage is more interesting. Let’s take a closer look at it. registerMessage: function(handle, message) { if (!Shoutbox.sockets.hasOwnProperty(handle)) { Shoutbox.sockets[handle] = new Handlers.defaultSocketHandler(message); } }, registerMessage first checks if we don’t already have the requested key in the Shoutbox.sockets object, if we don’t it adds a new key with a new defaultSocketHandler as value. We pass the message from the second argument to the defaultSocketHandler constructor, which, if you scroll up, is stored in the newly created object with this.message = message;. If you look at the return value of defaultSocketHandler you can see that it returns a function that takes 2 arguments. This function essentially just emits a socket message with the data and callback as arguments. Because we store this newly created function as the value of the Shoutbox.sockets[handle] key, this allows us to do the Shoutbox.sockets.<action>(data, callback); from the beginning of this post. registerEvent just registers a new event with socket.io for the passed in event and handler. intialize simply loops over all the Events and Messages and calls the appropriate functions to register all the default events and messages. Because we expose registerMessage and registerEvent commands and actions can easily add their own methods and event handlers to the Shoutbox.sockets object. Hopefully this post was somewhat interesting to read ;)
    • SchamperS

      (Web)design showcases

      Watching Ignoring Scheduled Pinned Locked Moved Development and Coding
      7
      7 Posts
      1k Views
      AntuA
      @theDaftDev Welcome, it looks great now ! :)
    • SchamperS

      Show off your PC / Laptop

      Watching Ignoring Scheduled Pinned Locked Moved General Computing show off laptop
      8
      8 Posts
      1k Views
      1
      @Scuzz Like your wall paper though.
    • SchamperS

      nodebb-plugin-webrtc

      Watching Ignoring Scheduled Pinned Locked Moved Development and Coding
      1
      1 Posts
      622 Views
      SchamperS
      I made another thing. Just wanted to get this (working) out on Github so that other people can hopefully contribute… It’s been a bitch. https://github.com/Schamper/nodebb-plugin-webrtc
    • SchamperS

      Watches

      Watching Ignoring Scheduled Pinned Locked Moved The lounge
      8
      8 Posts
      1k Views
      AlmostA
      $130, I think.
    • SchamperS

      Using websockets in your plugin

      Watching Ignoring Scheduled Pinned Locked Moved General Computing
      1
      1 Posts
      1k Views
      SchamperS
      The Problem Say you want your plugin to communicate between client and server using websockets. There isn’t a documented (or “official”) way on how to hook into the websockets API of NodeBB. I was facing this issue with the Shoutbox plugin, and had to find a clever way to get it to work. The way I found is a bit “hackish” but actually works really well and is now actually being used by a core developer in one of his plugins. The Process of finding a Solution When digging around a bit in the NodeBB source you can see how their socket implementation works. For this we navigate to src/socket.io. In this folder we see some files. You can quickly see that index.js is controlling everything, and that all the other files are socket “namespaces” (e.g. all the socket calls that have the user prefix will be handled by the user.js file. I won’t go into too many details on how this works, you’ll just have to believe me on this :) When playing around with this, you find out that when you add another js file in that folder, you’ll have working sockets on that namespace! But we don’t want to change anything in core… We want to do this from a plugin! We will further investigate one of these files. I chose the modules file because I thought it would fit a Shoutbox the most. It’s some pretty basic stuff in here. SocketModules is defined as a new object, and so is every “module”, like SocketModules.composer. At the very end you can see that this file sets the module.exports to the SocketModules object. This means that when you require(..) this file, you’ll have access to everything in the SocketModules object, but nothing outside of it. This gave me an idea. Exploring the Idea From your plugin you can require(..) files from NodeBB using module.parent.require(..). In this way you can also require the modules.js file like so: var ModulesSockets = module.parent.require('./socket.io/modules'); ModulesSockets will now be whatever this file has given us as their export. In our case, the SocketModules object, which includes everything that was defined in the modules.js file, which are basically all the socket handlers for the composer, chat, etc… Here I enter my idea: What happens if I add my own custom sockets to this object? I simply tested this with something like this (from within my plugin): var ModulesSockets = module.parent.require('./socket.io/modules'); ModulesSockets.test = function(socket, data, callback) { console.log("Working?"); console.log(data); callback(null, "It worked!"); } Then, on the client, I entered something like this in the console: socket.emit('modules.test', {data: "Some data"}, function(err, result) { alert(result); }); And hit enter. And it worked! I saw the logs in the NodeBB log and was alerted with “It worked!”. Using all this information I came up with the following solution. #The Solution So the solution is quite easy. All you have to do is require the namespace you want to extend, and add your custom handlers. You could even replace the default handlers with your own in this way! In a bit of code: var ModulesSockets = module.parent.require('./socket.io/modules'); ... //I prefer to execute this in the "action:app.load" handler method ModulesSockets.shoutbox = Shoutbox.sockets; //in this case, my handlers will listen to "modules.shoutbox.*" ... Shoutbox.sockets = { //Bunch of socket handlers here } I hope you guys learned something from this :D If you have any corrections or enhancements please call me out on it :P
    • SchamperS

      nodebb-plugin-buzzer

      Watching Ignoring Scheduled Pinned Locked Moved Development and Coding
      1
      1 Posts
      482 Views
      SchamperS
      So for the sake of creating something silly I made this little plugin. It’s add a nice button called ‘Buzz’ next to the Send button in the chat modal. When pressed, the other user will have their modal shaken all about and an annoying little nostalgic sound will play! To prevent users from losing their sanity these are the limitations: You can only buzz a user if you both have the chat window open (this is very much intentional to keep it from being too annoying) A buzz will last about 1 second, and you can only buzz every 2 seconds. (this is very much intentional to keep it annoying, but not too annoying) Have fun :D npm install nodebb-plugin-buzzer Source: https://github.com/MrWaffle/nodebb-plugin-buzzer
    • SchamperS

      Project Honeypot plugin?

      Watching Ignoring Scheduled Pinned Locked Moved Development and Coding
      1
      1 Posts
      805 Views
      SchamperS
      It looks like the NodeBB community really wants an anti-spam plugin. (http://community.nodebb.org/topic/150/nodebb-anti-spam) Perhaps we can develop a plugin that utilises Project Honeypot? IP that users register with should already be available.
    • SchamperS

      nodebb-plugin-shoutbox

      Watching Ignoring Scheduled Pinned Locked Moved Development and Coding
      14
      14 Posts
      2k Views
      ScuzzS
      Any updates on this @schamper?
    • 1 / 1