Skip to content

Instantly share code, notes, and snippets.

View StephanieSunshine's full-sized avatar

Stephanie Sunshine StephanieSunshine

  • Prisma Digital Technologies
  • Pacific Northwest, United States
View GitHub Profile
@StephanieSunshine
StephanieSunshine / celluloid test
Created August 18, 2013 14:28
Celluloid signal testing
#!/usr/bin/env ruby
require 'celluloid'
require 'pp'
require 'timers'
#include Celluloid
class Bot
include Celluloid
#!/usr/rubinius/2.0/bin/ruby
require 'rubygems'
require 'bundler/setup'
require 'reel'
require 'celluloid/autostart'
class TimeServer
include Celluloid
include Celluloid::Notifications
@StephanieSunshine
StephanieSunshine / gist:6276507
Last active December 21, 2015 08:09
I'm trying to subscribe to a redis server and have it echo what it hears to all the active websockets. I've been looking at example https://github.com/redis/redis-rb/blob/master/examples/pubsub.rb and https://github.com/celluloid/reel/blob/master/examples/websockets.rb. I'm using rubinius build just yesterday
require 'rubygems'
require 'bundler/setup'
require 'reel'
require 'celluloid/autostart'
require 'celluloid/redis'
require 'redis'
class TimeServer
include Celluloid
include Celluloid::Notifications
@StephanieSunshine
StephanieSunshine / gist:6277870
Created August 20, 2013 06:49
How do I get celluloid-redis to work within a class?
#!/usr/bin/env ruby
require 'celluloid'
require 'celluloid/redis'
require 'sucker_punch'
class BWorker
include SuckerPunch::Job
include Celluloid::Redis
@StephanieSunshine
StephanieSunshine / chat-server.rb
Last active December 21, 2015 08:29
My *working* yet very crude example of ruby reel websockets backending a redis server!!!!
require 'rubygems'
require 'bundler/setup'
require 'reel'
require 'celluloid/autostart'
require 'celluloid/redis'
class TimeServer
include Celluloid
include Celluloid::Notifications
@StephanieSunshine
StephanieSunshine / gist:6293760
Created August 21, 2013 12:19
Javascript array sorting question
If I have an array of arrays in javascript like:
[
[ 1, "a", "b"],
[ 2, "a", "b"],
[ 2, "c", "d"],
[ 3, "d", "d"]
]
How do I sort the array by the first column of each element?
@StephanieSunshine
StephanieSunshine / controller.rb
Created August 23, 2013 01:57
The Neurobots controller
#!/usr/bin/env ruby
require 'rubygems'
require 'base32'
require 'sinatra'
require 'mysql'
require 'json'
require 'ap'
require 'sys/proctable'
require 'turntabler'
@StephanieSunshine
StephanieSunshine / processTriggers.rb
Created August 23, 2013 02:52
processTriggers.rb
module Processtriggers
def validate_security(id, level)
returnset = 0
case level
when 0 # Anyone
returnset = 1
when 1 # Level 1
returnset = 1 if(@botData['level1acl'].include?(id)||@botData['level2acl'].include?(id)||@botData['level3acl'].include?(id)||@botData['ownerid'] == id)
when 2 # Level 2
# Main
# Start Eventmachine main loop
bot = Neurobot.new
Turntabler.interactive
Turntabler.run do
# Start the client handle
@StephanieSunshine
StephanieSunshine / gist:6319922
Last active December 21, 2015 14:29
Oh javascript how i love you......
var server_list = []
function createCORSRequest(method, url){
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr){
xhr.open(method, url, true);
} else if (typeof XDomainRequest != "undefined"){
xhr = new XDomainRequest();
xhr.open(method, url);
} else {