Skip to content

Instantly share code, notes, and snippets.

@kenoir
kenoir / draggable.js
Created June 20, 2012 15:05
Simple cross browser element dragging
var Draggable = function(element) {
element.addEventListener('mousedown', Draggable.mousedown, false);
document.addEventListener('mouseup', Draggable.mouseup, false);
}
Draggable.mousedown = function(e) {
e.target.style.position = 'relative';
document.addEventListener('mousemove', Draggable.mousemove, false);
var startingPosition = Draggable.mouseposition(e);
var targetPostion = Draggable.targetposition(e);
@kenoir
kenoir / cheesewire.js
Created June 20, 2012 16:05
Really simple js object for testing HTML5 browser capabilities
var Cheesewire = {
cutsTheMustard: function(){
if('querySelector' in document
&& 'localStorage' in window
&& 'addEventListener' in window) {
return true;
}
return false;
},
@kenoir
kenoir / biglog.rb
Created June 20, 2012 16:08
Quick script to grep the logs from the BBC logging service
require 'ruby-debug'
# An HTTPS client that can read the Forge PEMs
module Forge
module Http
require 'net/http'
require 'net/https'
require 'uri'
@kenoir
kenoir / droop.js
Created July 11, 2012 09:39
For simulating drag drop events (not in IE).
var Droop = function(){
}
Droop.simulateDragStart = function(target){
var e = new Event('mousedown');
target.dispatchEvent(e);
}
Droop.simulateDrag = function(position){
var e = new Event('mousemove');
e.pageY = position.y;
@kenoir
kenoir / js-loader.rb
Created July 11, 2012 12:31
For loading javascript into files into a page with capybara
module JSLoader
def read_file(file)
file = File.open(file, "rb")
contents = file.read
file.close
contents
end
@kenoir
kenoir / gist:3531585
Created August 30, 2012 15:55
Starter rakefile for PHP projects
require 'rubygems'
require 'configatron'
require 'colorize'
configatron.app_root= File.dirname(__FILE__)
configatron.app_name = "events"
configatron.relish_id = "bbc-knowlearn/kandl-events-poc"
def run_phpunit
system "phing -Dwebapp.name=#{configatron.app_name} -Dwebapp.root=#{configatron.app_root}/webapp test coverage -f #{configatron.app_root}/webapp/php/lib-test/all_tests.xml"
@kenoir
kenoir / main.py
Created September 3, 2012 08:55
Python HelloWorld
#!/usr/local/bin/python
class HelloWorld:
def say_hello(self,name):
print "Hello, ", name
helloWorld = HelloWorld()
name = "Kenny"
@kenoir
kenoir / gist:3618577
Created September 4, 2012 08:37
Proxy stuff for reith
> cat ~/proxies_off
#!/bin/sh
echo "Proxies OFF"
unset HTTP_PROXY
unset ALL_PROXY
unset http_proxy
unset HTTPS_PROXY
unset https_proxy
@kenoir
kenoir / gist:3697080
Created September 11, 2012 09:04
Trying our some media selectors for screen width
@media all and (max-width: 320px){
article.intro {
width: 100%;
}
section {
width: 100%;
}
}
@media all and (max-width: 640px) and (min-width: 321px){
@kenoir
kenoir / watch.rb
Created September 18, 2012 18:23
Rake task to watch changes to .php files and run a phpunit rake task
require 'watchr'
desc 'Start watching PHP changes and run PHPUnit'
task :watch_php do
script = Watchr::Script.new
script.watch('./(.*)\.php') {|m|
Rake::Task["phpunit"].reenable
Rake::Task["phpunit"].invoke
}
handler = Watchr.handler.new;