Skip to content

Instantly share code, notes, and snippets.

desc "Will replace i18n references in specs with actual text from default locale"
task undo_i18n_in_specs: :environment do
Dir[Rails.root.join("spec/features/**/*.rb")].collect do |file_name|
file_text = File.read(file_name)
file_text.scan(/\Wt\("([\w\.]+)"\)/).each do |match|
file_text.gsub!("t(\"#{match.first}\")", "\"#{I18n.t(match.first)}\"")
end
File.open(file_name, "w") { |file| file.puts file_text }
end
end
@james
james / flame_detector.py
Last active July 20, 2020 17:25
Zonal flame detector
# Install raspbian lite
# run `sudo raspi-config` and enable camera
# sudo apt-get update
# sudo apt-get upgrade
# sudo apt-get install python3-picamera
# sudo apt-get install python3-rpi.gpio
from picamera.array import PiYUVArray
from picamera import PiCamera
from time import sleep
Hello,
Thanks for the email and nice to read from you,i can assure you of the viewing but i will like to discuss some thing with you, as you know am in Ireland currently and before i can come down for the viewing i will like to see a proof of your financial capacity and to know how serious you are in need of the property because i have been fooled so many times and i will not let that to happen to me again, Been fooled by several tenant telling me to come from Ireland to London to show them my property but when i got there for the viewing they will never show up and when i called there phone they will keep on banging the phone on me so it has been a very sad and disappointing occasion for me and i waste alot of money also for transport when coming for the viewing, so i don't want that to happen to me anymore,well this is what you will have to do for me before i can come down for the viewing, If you have a partner or friend in UK,what you will have to do is to locate a western union money transfer around you
@james
james / convert.rb
Created August 19, 2017 18:02
Example hacky code from the Jeremy Corbyn Labour leadership campaign 2015
require 'csv'
require 'date'
require 'chronic'
HEADERS_TO_KEEP = ['MembershipNumber', 'Title', 'LastName', 'PreferredFirstName', 'DateOfBirth', 'AddressLine1', 'AddressLine2', 'AddressLine3', 'Town', 'Country Code', 'County', 'PostCode', 'Email', 'MobilePhoneNumber', 'PhoneNumber', 'RegionName', 'ConstituencyName', 'TradeUnion', 'PrimaryStatus'] #, 'JoinedDate'
Dir.entries('to_convert')[2..999].each do |file|
members = CSV.read("to_convert/#{file}", headers: true, :encoding => 'windows-1251:utf-8')
# remove unused columns
@james
james / REAMDE.md
Last active November 16, 2016 18:30
Pingdom Dashing Widget

Description

Simple Dashing widget (and associated job) to display Pingdom checks.

##Dependencies

pingdom-client

Add it to dashing's gemfile:

9 dir 117150 svn+ssh://tubbs/svnroot/tfb/releases/thefacebook-r116496-fb95/www/lib/display/privacy svn+ssh://tubbs/svnroot 2008-08-05T21:47:04.536211Z 114218 chad svn:special svn:externals svn:needs-lock 2c7ba8d8-a2f7-0310-a573-de162e16dcc7 pages.php file 2008-08-18T18:50:32.000000Z e69ad78841111ae71df858b23a4d356c 2008-08-05T21:47:04.536211Z 114218 chad 8328 ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
// ==UserScript==
// @name Highlight italics
// @version 0.1
// @namespace abscond
// @include *
// ==/UserScript==
arr = document.getElementsByTagName('i');
var length = arr.length;
@james
james / rightmove_bedrooms.user.js
Created July 1, 2013 08:57
Userscript to add price per bedroom in rightmove.co.uk search results.
// ==UserScript==
// @name Right Move Price per Bedroom
// @version 0.1.4
// @namespace abscond
// @include http://*rightmove.co.uk/*/find*
// ==/UserScript==
function addJQuery(callback) {
var script = document.createElement("script");
@james
james / gist:5508572
Last active December 16, 2015 22:39
require 'twitter'
Twitter.configure do |config|
config.consumer_key = YOUR_CONSUMER_KEY
config.consumer_secret = YOUR_CONSUMER_SECRET
config.oauth_token = YOUR_OAUTH_TOKEN
config.oauth_token_secret = YOUR_OAUTH_TOKEN_SECRET
end
s = nil
while true
if IO.popen('pbpaste', 'r+').read != s
@james
james / waitrose_login_paste.user.js
Created October 29, 2012 18:02
Waitrose Login Paste Password
// ==UserScript==
// @name Waitrose Login Paste Password
// @description Allow to paste password in Waitrose's login forms
// @author James Darling <james@abscond.org>
// @include http*://www.waitrose.com/*
// ==/UserScript==
document.getElementById("logonPasswordField").setAttribute("onpaste", "return true;");
document.getElementById("newPasswordField").setAttribute("onpaste", "return true;");
document.getElementById("logonPasswordVerifyField").setAttribute("onpaste", "return true;");