Skip to content

Instantly share code, notes, and snippets.

View kylewelsby's full-sized avatar
🏠
Working from home

Kyle Welsby kylewelsby

🏠
Working from home
View GitHub Profile
@kylewelsby
kylewelsby / f1-cherker.js
Created March 16, 2014 19:28
Using PhantomJS to check if F1 is available to watch or not.
(function () {
'use strict';
var page;
page = require('webpage').create();
page.onResourceRequested = function(requestData, request) {
if ((/http:\/\/.+?\.(css|png|js|jpg|gif)/gi).test(requestData['url']) || requestData['Content-Type'] == 'text/css') {
request.abort();
}
};
var app = angular.module('app',[]);
app.config(function($http){
/* a request we're wanting to stub */
$http.get('/example').then(function(){
// handle example
});
});
var app;
app = angular.module('app',[]);
app.constant('endpoint', 'http://api.example.com');

Testing socket.io onMessage.

phantomjs ./socket_message_test.js

should return the message emitted on exit.

@kylewelsby
kylewelsby / 0.README.md
Last active August 29, 2015 13:56
Super Simple straight through socket.io with rooms.

Start the Server using

node server.js --port 8080

Navigate to the index.html document frommany tabs or browsers.

require 'redis'
require 'open3'
class Finder
def redis
Redis.new
end
def listen_for_terminate(id)
Thread.new do
loop do
@kylewelsby
kylewelsby / bugsnag_phantomjs.js
Last active December 31, 2015 20:09
A useful bit of code to be able to report PhantomJS errors to BugSnag
/* global require, phantom */
(function () {
'use strict';
var exec, system, env;
exec = require('child_process').spawn;
system = require('system');
env = system.env.NODE_ENV || system.env.RACK_ENV || 'development';
phantom.onError = function (message, trace) {
// dont report for development
if (env === 'development') {
@kylewelsby
kylewelsby / pub_sub_test.rb
Created November 21, 2013 16:50
Test that waits for pub/sub message before asserting.
require 'minitest'
require 'minitest/autorun'
require 'minitest/pride'
require 'redis'
require 'sidekiq'
class ThingWorker
include Sidekiq::Worker
{
"config": {
"errorMessages": [],
"channelToken": "AHRlWrpa5tISngbssBEDidkSwqZQnG2e_a7mSmX5K8gJheKfCdoGowKIJdHPSKyyk-xwwN0l8rF4WjWM9rBTDnJ4ais6AvULM4HqrlnAiDu4Mapm1X6Csw8",
"me": "65499267",
"roomKey": "61879062",
"roomLink": "https: //apprtc.appspot.com/?r=61879062",
"initiator": 0,
"pcConfig": {
"iceServers": [
[postgesql]
directory = .
command = postgres -D /usr/local/var/postgres
[nginx]
directory = .
command = nginx -p . -c config/nginx.conf
[web]
directory = .