Skip to content

Instantly share code, notes, and snippets.

@Antti
Antti / zoopla_postcode.js
Created October 31, 2017 10:11
zoopla postcode
javascript:$('h2[itemprop="streetAddress"').append('<span style="color: red; font-weight:bold"> (' + $("meta[property='og:postal-code']").attr("content") + ')</span>')
#include <FS.h> // This needs to be first, or it all crashes and burns
#include <IRremoteESP8266.h>
#include <IRsend.h>
#include <IRrecv.h>
#include <IRutils.h>
#include <ESP8266WiFi.h>
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager WiFi Configuration Magic
//#include <ESP8266mDNS.h> // Useful to access to ESP by hostname.local
LETTER_MAP = ('a'..'z').to_a
def decode_word_faster(word, current_word=[], words=[])
if word.size == 0 # we reached the end of word
words.push(current_word.map{ |letter| LETTER_MAP[letter-1] }.join)
return words
end
decode_word_faster(word[1..-1], current_word.clone.push(word[0].to_i), words)
if word.size > 1 && (word[0..1].to_i < 26)
decode_word_faster(word[2..-1], current_word.clone.push(word[0..1].to_i), words)
@Antti
Antti / make_pr.sh
Created July 27, 2016 10:42
make_pr.sh
export SLACK_TOKEN="your_token"
export TARGET_CHANNEL="channel_name_or_id"
function call_slack(){
local API_METHOD=$1
local data_args=""
for arg in ${@:2}; do data_args="$data_args -d \"$arg\""; done
eval curl -XPOST -d "pretty=1" -d "token=\"$SLACK_TOKEN\"" $data_args https://slack.com/api/$API_METHOD
}
@Antti
Antti / cloudflare_auto_update_ip.sh
Last active January 26, 2016 13:32
cloudflare_auto_update_ip.sh
# Cloudflare automatic IP updating script.
# Usage instructions:
#
# 1. Get the cloud flare API key: https://www.cloudflare.com/a/account/my-account
# 2. Set some env variables:
# $ export [email protected]
# $ export CLOUDFLARE_API_KEY=your_api_key
# 3. Get your zone id:
# $ curl -X GET -H "Content-Type: application/json" -H "X-Auth-Key: ${CLOUDFLARE_API_KEY}" -H "X-Auth-Email:${CLOUDFLARE_EMAIL}" https://api.cloudflare.com/client/v4/zones
# 4. Get your record id:
@Antti
Antti / p_macro.rs
Created August 6, 2015 10:18
rust p macro
macro_rules! p {
($($e:expr),+) => ({
$(
println!("{} = {:?}", stringify!($e), $e);
)+
})
}
module Sass::Script::Functions
def user_color
color_values = options[:custom][:user].color.
scan(/^#?(..?)(..?)(..?)$/).first.
map {|num| num.ljust(2, num).to_i(16)}
Sass::Script::Color.new(color_values)
end
end
use std::io;
fn main() {
eval(bytes!("++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.")); // I stole this off of wikipedia, sorry, wikipedia :(
}
fn eval(program: &[u8]) {
let mut pointer = 0u;
let mut memory = [0u8, ..1024];
let mut jmp_stack = vec!();
@Antti
Antti / keybase.md
Created September 22, 2014 20:54
keybase.md

Keybase proof

I hereby claim:

  • I am Antti on github.
  • I am antti_ua (https://keybase.io/antti_ua) on keybase.
  • I have a public key whose fingerprint is 1A66 BD1A 317C 6943 C943 B536 F6E3 FCE3 9D66 4EFB

To claim this, I am signing this object:

@Antti
Antti / gist:b99ef9d4ca6d5d78a8ae
Last active August 29, 2015 14:04
Call rust code from ruby

#Benchmarks:

##Ruby: Command: ruby -I lib/ test_ruby.rb ~/Guitar/Nightwish\ -\ Nemo\ (Pro).gpx > /dev/null

rubinius 2.2.9 (2.1.0 8694b613 2014-06-10 JI) [x86_64-darwin13.2.0]: 18.58s user 1.12s system 129% cpu 15.184 total

ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]: 115.73s user 12.35s system 99% cpu 2:08.18 total