Skip to content

Instantly share code, notes, and snippets.

Your username on Github: DanKnox
Please publicly post the following Gist, and name it keybase.md
### Keybase proof
I hereby claim:
* I am danknox on github.
* I am danknox (https://keybase.io/danknox) on keybase.
* I have a public key ASBHRii0bwhUxa5X02Ga2jcSea48tgohI7JRaCv3kYQOiwo
@DanKnox
DanKnox / 0_reuse_code.js
Last active August 29, 2015 14:25
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@DanKnox
DanKnox / index.js
Last active August 29, 2015 14:22 — forked from thlorenz/index.js
/*
Browserify Live Demos!
How to make your own:
1. Clone this RequireBin
2. Adjust the REQUIRES section
3. Create a gist with demo snippets that can be run
4. Put the id for that gist into the demoGist variable
*/
/* REQUIRES: Put modules you need in your demo in this Array */
@DanKnox
DanKnox / phr.c
Last active August 29, 2015 14:22 — forked from Asmod4n/phr.c
#include "picohttpparser.h"
#include <mruby.h>
#include <mruby/data.h>
#include <mruby/variable.h>
#include <mruby/array.h>
#include <mruby/string.h>
#include <mruby/class.h>
#define PHR_MAX_HEADERS 255
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes
# When running daemonized, Redis writes a pid file in /var/run/redis.pid by
# default. You can specify a custom pid file location here.
pidfile /var/run/redis.pid
# Accept connections on the specified port, default is 6379.
# If port 0 is specified Redis will not listen on a TCP socket.
-----BEGIN PGP MESSAGE-----
Version: GnuPG v1.4.13 (Darwin)
owGbwMvMwMR4WcFofv8mnzmMpw+8SGIIFm/0rFZKyk+pVLKqVspOBVNpmXnpqUUF
RZl5JUpWSgZJJkmJFsmmqSlmhuYmlqnGSRbmJkmpRinGRgbGRpZpFmlJRibJlslK
OkoZ+cUgHUBjkhKLU/Uy84FiQE58ZgpQ1AWi3s3CzcnIxNnSGShXCpYwS7MwNDQ0
STQ2TzM1T06yMDM1SU4yTLM0MjG0NEs1MAApLE4tykvMTQWqTknMy87Lr1Cq1VEC
CpZlJqeCnAyVTM8syShNQtXgkpjnDdVQUlkAEilPTYqH6o1PysxLAXoXqKUstag4
Mz9PycoQqDK5JBOk2dDY0sTAxNLY1FhHKbWiILMoNT4TpMLU3MzCAAh0lAqKUsuA
RqalARWZmhsZJhkbJqeaWZgYphkDeQYmBhYmSUmWFimmlhbmicamBpbG5knJxmkG
class ChannelManager
attr_reader :channels, :channel_tokens
def initialize
@channels = {}.with_indifferent_access
@channel_tokens = ChannelTokens.new
end
def [](channel)

Setting Up The Development Environment

1. Clone the project.

git clone git@github.com:websocket-rails/websocket-rails.git

If you are planning on submitting a pull request, fork the project to your own account first and clone it from there.

@DanKnox
DanKnox / websocket-rails_message_format.js
Last active February 10, 2016 14:00
Format of WebsocketRails Messages
/****** Current Format ******/
// Basic Message
metadata = {
id: 1234234234, // Randomly generated by the client. Used for receiving success/fail callbacks
client_id: 123456 // Sent from the server with the `websocket_rails.client_connected` event which is sent after the connection is opened. Store this and send it with each message.
data: {name: 'shoes'} // Arbitrary data. Can be Object or String. This is available through #message or #data in the controller.
}
event = ["products.new", metadata]
@DanKnox
DanKnox / force_garbage_collection.cfm
Created April 26, 2013 16:42
Constants to set before using this function: `SEC_BTWN_GC`: Seconds before garbage collection is forced. `MIN_MEMORY_PCT`: The percentage of memory usage at which this function will actually force Garbage Collection `CRITICAL_MEMORY_PCT`: If the free memory dips below this percentage, cold fusion won't even be able to run garbage collection so w…
Calling this function:
interval = iteration at which to execute the GC cleanup. We can set this to a reasonable value and add this call right before the main outer loop that begins to process the set of Surveys. In our case we will probably set it to 1 or 2 so it runs the GC after every other survey set processing.
cleanupMemory(interval)
<cffunction name="cleanupMemory" output="true" returntype="void">
<!--- ColdFusion doesn't run garbage collection until onRequestEnd. --->
<!--- Since this is such a long running script, we must run it sooner. --->
<cfargument name="interval" required="true" type="numeric">