Skip to content

Instantly share code, notes, and snippets.

View simonmorley's full-sized avatar

Simon Morley simonmorley

View GitHub Profile
describe "elastic search" do
let (:fw) {create :firmware}
before(:all) do ## SOMETIMES BEFORE EACH ##
Nas.index.delete
Nas.create_elasticsearch_index
end
it "should output nice json for nas session search" do
language: ruby
cache:
bundler: true
apt: true
rvm:
- 2.0.0
env:
# - TESTFOLDER=spec/models
# - TESTFOLDER=spec/controllers
# - TESTFOLDER=spec/routing
require "amqp"
error_handler = Proc.new do |settings|
puts "Failed to connect."
EM.stop
end
Thread.new { AMQP.start(
:port => 5672,
:vhost => '/',
@simonmorley
simonmorley / gist:663c7307fdd1105101c2
Last active August 29, 2015 14:00
Vim Cheat Sheet
Navigation
Ctrl-D "Move half-page down
Ctrl-U "Move half-page up
Ctrl-B "Page up
Ctrl-F "Page down
**Nerd Tree**
Ctrl-f "Page down
@simonmorley
simonmorley / gist:24f1492e8515d1038d29
Created May 4, 2014 15:20
Public API Cors Before Filter Rails API
before_filter: cors_filters
def cors_filters
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS'
headers['Access-Control-Request-Method'] = '*'
headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
end
@simonmorley
simonmorley / gist:64f6b784f7c26ee1d1a6
Created May 9, 2014 08:53
Small Rabbit Consumer Test
#!/usr/bin/env ruby
# encoding: utf-8
require "bunny"
conn = Bunny.new vhost: '/boxes', user: 'boxes', pass: 'xxx', host: '127.0.0.1'
conn.start
ch = conn.create_channel
x = ch.topic("boxes", durable: true)
@simonmorley
simonmorley / gist:0c625876f2c2328a57a0
Created June 2, 2014 13:57
default chilli file for Cucumber Tony
######### Production PolkaSpots ########
HS_WANIF=`uci -P/var/state get network.wan.ifname`
HS_LANIF=`uci -P/var/state get network.lan.ifname`
HS_NETWORK=192.168.4.0
HS_NETMASK=255.255.255.0
HS_UAMLISTEN=192.168.4.1
HS_UAMPORT=3990
HS_UAMUIPORT=4990
# HS_DYNIP=
# HS_DYNIP_MASK=255.255.255.0
@simonmorley
simonmorley / gist:57dd35abda1889bf3868
Created September 24, 2014 10:40
Testing the gubbins
Here is a dummy gubbins.rb
#!/usr/bin/ruby
class Gubbins
def initialize
@api_url = "https://api.polkaspots.com"
end
it("should call CT's api and enable alerts for a box", function() {
expect($scope.box.is_monitored).toBe(false)
spyOn(boxFactory, 'alerts').andCallThrough()
var cont = element.find('input').controller('ngModel');
cont.$setViewValue(true);
deferred.resolve({slug: 123, is_monitored: true});
$scope.$apply()
expect($scope.status.processing).toBe(true)
expect(boxFactory.alerts).toHaveBeenCalled();
expect($scope.box.is_monitored).toBe(true)
{
"ap_mac": "00-18-0A-13-XX-XX",
"unique_id": "xxx",
"created_at": "20141010",
"meraki_secret": "xxx",
"location_id": 1294,
"latitude": 52.924263174858446,
"longitude": -1.4837226407115054,
"day": 5,
"version": 2,