Skip to content

Instantly share code, notes, and snippets.

View trevordixon's full-sized avatar

Trevor Dixon trevordixon

View GitHub Profile
ruleset examine_location {
meta {
name "Examine Location Data"
description <<
Examine Location Data
>>
author ""
logging off
use module b505206x2 alias LocationData
}
ruleset a2294x3 {
meta {
name "Hello World"
description <<
Hello World
>>
author ""
logging off
use module a169x701 alias CloudRain
use module a41x186 alias SquareTag
ruleset a2294x2 {
rule first_rule is active {
select when pageview ".*" setting ()
pre {
results = <<
<dl id="results" style="display:none">
<dt></dt>
<dd><img id="thumbnail" src=""></dd>
<dt>Title</dt>
@trevordixon
trevordixon / a2294x1.krl
Last active August 29, 2015 13:56
Lab 3
ruleset a2294x1 {
rule show_form is active {
select when pageview "ktest\.heroku\.com"
pre {
firstName = ent:firstName;
lastName = ent:lastName;
form = <<
<form id="simple_form">
<input placeholder="First Name" name="first_name"><br>
'use strict';
var angular = require('angular');
module.exports = function LoginFormDirective ($compile) {
return {
restrict: 'E',
template: require('./loginFormTemplate.html'),
link: function (scope, element) {
// Already compiled!
@trevordixon
trevordixon / hello.krl
Last active August 29, 2015 13:56
Hello World KRL
ruleset HelloWorldApp {
rule Excercise1 is active {
select when pageview ".*"
{
notify("Hello World", "This is a sample rule.") with sticky = true;
notify("Another One", "Notification 2.") with sticky = true;
}
}
rule Exercise4 is active {
@trevordixon
trevordixon / cloud-init.sh
Last active January 3, 2016 04:59
Bootstrap EC2 server
#!/bin/bash
wget "https://gist.github.com/trevordixon/8413132/raw/index.html" -O /var/www/index.html
@trevordixon
trevordixon / ReconnectingWebSocket.js
Last active April 24, 2021 12:54
ReconnectingWebSocket that exposes its constructor on module.exports.
// MIT License:
//
// Copyright (c) 2010-2012, Joe Walnes
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@trevordixon
trevordixon / extendedEu.hs
Created October 9, 2013 03:34
Extended euclidean algorithm in Haskell
extendedEu :: Integer -> Integer -> (Integer, Integer)
extendedEu a 0 = (1, 0)
extendedEu a b = (t, s - q * t)
where (q, r) = quotRem a b
(s, t) = extendedEu b r
@trevordixon
trevordixon / rndPrime.hs
Created October 2, 2013 03:01
Find a Large Random Prime Number in Haskell
import System.Random
import Math.NumberTheory.Primes.Testing
rndPrime :: Int -> IO Integer
rndPrime bits = do
x <- fmap (.|. 1) $ randomRIO (2^(bits - 1), 2^bits - 1)
if isPrime x then return x else rndPrime bits