Skip to content

Instantly share code, notes, and snippets.

Bundler could not find compatible versions for gem "jquery-rails":
In Gemfile:
spree (>= 0) ruby depends on
jquery-rails (~> 2.1.4) ruby
jquery-rails (2.2.0)
@xorrbit
xorrbit / gist:5497013
Created May 1, 2013 18:04
Creating a world zone in spree
first create a new Zone called World and add any country to it
then fire up your ruby console and do:
Spree::Country.find_each { |country| Spree::ZoneMember.create! zone_id: Spree::Zone.where(:name => "World").first.id, zoneable_id: country.id, zoneable_type: "Spree::Country" }
@xorrbit
xorrbit / caddoge.py
Last active December 31, 2015 06:39
Scrapes doge/btd and cad/doge and tells you cad per 100k doge.
import httplib2
import re
cadpat = re.compile('Daily.*?<td> ([0-9.]+) \(CAD\)', re.DOTALL)
dogepat = re.compile('DOGE/BTC<div.*?>\(last: ([0-9.]+)\)</')
def get_html(url):
_, html = httplib2.Http(disable_ssl_certificate_validation=True).request(url)
return html
@xorrbit
xorrbit / doge.py
Created December 20, 2013 19:14
doge.py
# -*- coding: utf-8 -*-
import httplib2
import re
cadpat = re.compile('Daily.*?<td> ([0-9.]+) \(CAD\)', re.DOTALL)
usdpat = re.compile('"btc_to_usd":"([0-9.]+?)"')
dogepat = re.compile('"lasttradeprice":"([0-9.]+?)"')
def get_html(url):
_, html = httplib2.Http(disable_ssl_certificate_validation=True).request(url)
// Bind F7 to 'step'
javascript:$(document).bind('keydown', function(e) { e.which == 118 && parse('s'); }); void(0)
// Add a 'readhex' command that works just like 'read' but dumps nothing but the hex
javascript:cpu._readhex =
function(e) {
if (!e[1]) return write(" Please give an expression to read the memory at."), void 0;
var t = cpu.to_addr(e[1]);
cpu.get("/cpu/dbg/memory/" + t + "?len=" + (parseInt(e[2], 16) + (15 - parseInt(e[2], 16) & 15) || 32), function(e) {
for (var n = atob(e.raw), i = "", o = " ", s = 0; s < n.length; s++) s % 2 == 0 && (o += " "), o += pad(n.charCodeAt(s).toString(16), 2), s % 8 == 7 && (i += " " + o + "\n", o = " ");
private static void rangeCheck(int arrayLen, int fromIndex, int toIndex {
if (fromIndex > toIndex)
throw new IllegalArgumentException("fromIndex(" + fromIndex +
") > toIndex(" + toIndex+")");
if (fromIndex < 0)
throw new ArrayIndexOutOfBoundsException(fromIndex);
if (toIndex > arrayLen)
throw new ArrayIndexOutOfBoundsException(toIndex);
}
@xorrbit
xorrbit / gist:10472822
Created April 11, 2014 14:21
How to troll the cloudflare challenge
wget --no-check-certificate --post-data="---- BEGIN PRIVATE KEY ----\r\ntrololololololololol\r\n---- END PRIVATE KEY ----" https://www.cloudflarechallenge.com
@xorrbit
xorrbit / convert.sh
Created June 9, 2014 14:54
shell script to convert mjpeg camera videos to a sane format (x264/aac in an mp4 container).
for FILE in `ls *AVI | sort` ; do
avidemux --nogui --output-format MP4 --video-codec x264 --audio-codec aac --load "$FILE" --save ${FILE%.*}.mp4 --quit
done
@xorrbit
xorrbit / average_power.sh
Created March 2, 2015 22:55
Shell script to calculate the average power of a GSM base station using my fork of kalibrate-hackrf.
file=`mktemp`
echo "Average power of channel $1:"
for i in {1..10};
do kalibrate-hackrf/src/kal -s GSM850 -c $1 2>&1 | sed -n 's/.*power: \([0-9.]*\)/\1/p' >> $file;
done
awk '{ total += $1; count++ } END { print total/count }' $file
rm $file
@xorrbit
xorrbit / hide.freep.login.user.js
Last active August 29, 2015 14:17
hide freep login
// Install the Greasemonkey extension for Firefox or the Tampermonkey extension for Chrome
// then click the Raw button --->
// ==UserScript==
// @name hide freep login
// @namespace xorrbit
// @include http://*.winnipegfreepress.com/*
// @version v5
// @grant none
// ==/UserScript==