Skip to content

Instantly share code, notes, and snippets.

@byteface
byteface / gist:8250195
Created January 4, 2014 01:21
Learning python / mucking about. Built an obj like an array but with negative index positions. index's can now be a value (i.e for rank). My first gist :)
class RankArray(object):
"""An array with negative index positions"""
average=None
pos=[]
neg=[]
def __init__(self,average,pos,neg):
@byteface
byteface / gist:8ee9cdc774d74d61a0d5
Created September 22, 2014 02:30
reload page javascript
setTimeout( function(){ windowReload() }, 2000 );
function windowReload(){
if(!window.location.hash) {
window.location = window.location + '#loaded';
window.location.reload();
}else{
if (history && history.pushState){
history.pushState( null, null, window.location.href.split('#')[0] );
}
}
@byteface
byteface / gist:0898aa5714465c350331
Created March 11, 2015 00:20
load a google doc
// get google. js/jsapi.js
// go to doc. create spreasheet. publish it.
var docKey = '';
var url = 'http://spreadsheets.google.com/feeds/list/' + docKey +'/od6/public/values?alt=json';
$(document).ready(function(){
google.load('feeds', '1', { 'callback' : function(){
($.getJSON(url, 'callback=?')).success(function(data){
$(data.feed.entry).each(function(i,entry){
@byteface
byteface / gist:acc19c7ee880f8b83a31
Created March 15, 2015 22:46
import jquery into console from a CDN.
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... give time for script to load, then type.
jQuery.noConflict();
# gets everything for a single page...
wget -E -H -k -K -p http://www.site.com.au/path/topage
# gets the whole site...
wget -r -p -U wget -r -p -U Mozilla http://www.site.com.au
@byteface
byteface / gist:a260ab5cfd24b0291bac
Created April 9, 2015 06:59
url xpath into google doc cell
// scrape web data into google doc cell with formulas.
i.e
= IMPORTXML("http://en.wikipedia.org/wiki/Test_cricket","//html")
takes an xpath right into neigbouring cell. could be useful.
i pulled an ubuntu12/nginx container with docker.
install a bunch of stuff...
sudo apt-get update
sudo apt-get -y install build-essential
sudo apt-get install xvfb
sudo apt-get install xfs xfonts-scalable xfonts-100dpi
sudo apt-get install libgl1-mesa-dri
sudo apt-get install subversion libqt4-webkit libqt4-dev g++
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update
@byteface
byteface / docker
Created June 12, 2015 01:18
docker stuff
#remove ones not using
docker ps -a | grep "salttest" | awk '{print $1}' | xargs docker rm
bash profile addition to pass messages to slack
function slack()
{
join="{ \"username\": \"mike\", \"text\": \""$@"\" , \"icon_emoji\": \":ghost:\"}"
curl -X POST --data-urlencode "payload=$join" https://hooks.slack.com/services/YOUR/PRIVATE/CODE
}