This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo -n "{\"version\": \"1.1.0\",\"host\": \"maps.google.com\",\"request_address\": true,\"address_language\": \"en_GB\", \"wifi_towers\": [`iwlist scan 2> /dev/null | tr -d '\n' | sed -e 's/Cell [0-9]* - Address: \([0-9A-Z:]*\)[^C]*Channel:\([0-9]*\)[^S]*Signal level=\([0-9-]*\) dBm[^E]*E[^E]*ESSID:"\([^"]*\)"/\{"mac_address": "\1","signal_strength": \3,"age": 0,"channel": \2,"ssid": "\4"}/g' -e 's/[^{]*{/{/' -e 's/}[^{]*{/},{/g' -e 's/\}[^}]*$/\}/' `]}" | curl -s -X POST -d @/dev/fd/0 http://www.google.com/loc/json | |
# TIP: run with sudo for improved accuracy since iwlist can then provide more than the active hotspot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
class MRISC | |
def run(code) | |
tokens = code.gsub(/(\*.*?\*)|[^a-z0-9,-;@\._]/,'').split(';') | |
@vars,stack,i = {:_pc=>-1,:_oc=>0},[],0 | |
tokens.map!{|t| t.chars.first=='@' ? (@vars[t.to_sym]=i-1;nil) : (i+=1;t.split(',').map{|e|numeric?(e) ? e.to_i : e.to_sym})}.compact! | |
while @vars[:_pc] < tokens.size-1 | |
@vars[:_pc] += 1 | |
@vars[:_oc] += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
d,l,s,c,f,S=15,3,[[5,6],[5,5],[5,4]],[1,0],[rand(15),rand(15)],STDIN | |
system'stty -icanon -echoke' | |
loop do | |
k=S.getc if k=select([S],[],[],0.2)&&S.getc=="\e"&&S.getc==?[ | |
c={?A=>[0,-1],?B=>[0,1],?C=>[1,0],?D=>[-1,0]}[k]||c | |
s=[[s[0][0]+c[0],s[0][1]+c[1]]]+s[0..-2] | |
exit if s[0][0]+1>d||s[0][1]+1>d||s[0][0]+1==0||s[0][1]+1==0||s[1..-1].index(s[0]) | |
s+=[[s[0][0]+c[0],s[0][1]+c[1]]] if s[0]==f | |
f=[rand(d),rand(d)] if s.index f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mathn' | |
require 'rubygems' | |
require 'gd2' | |
include GD2 | |
def hough_transform(img) | |
mx, my = img.w*0.5, img.h*0.5 | |
max_d = Math.sqrt(mx**2 + my**2) | |
min_d = max_d * -1 | |
hough = Hash.new(0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?header('Content-type: text/plain');if($d=htmlspecialchars(join("\n",array_merge($_GET,$_POST)))){@file_put_contents($f=__file__,array_shift(file($f)).$d);exit($d);}?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mpg123 -C \ | |
http://scfire-mtc-aa04.stream.aol.com:80/stream/1005/?smoothjazz \ | |
http://ice.somafm.com/secretagent \ | |
http://ice.somafm.com/groovesalad \ | |
http://ice.somafm.com/covers \ | |
http://ice.somafm.com/lush \ | |
http://ice.somafm.com/indiepop \ | |
http://ice.somafm.com/bootliquor \ | |
http://ice.somafm.com/suburbsofgoa \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rest_client' | |
require 'json' | |
a = `sox -d --norm -t .flac - silence -l 1 0 1% 1 6.0 1% rate 16k` | |
#a = `arecord -q -d 3 -c 1 -f S16_LE -r 22050 -t wav | flac - -f --totally-silent -o-` | |
r = RestClient.post 'https://www.google.com/speech-api/v1/recognize?lang=en-US', a, | |
:content_type => 'audio/x-flac; rate=16000' | |
if j = JSON.parse(r) | |
(p j; `espeak 'you said: #{j['hypotheses'].first['utterance']}'`) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mathn' | |
require 'chunky_png' | |
def hough_transformation(img, cutoff=185, steps=1) | |
mx, my = img.width*0.5, img.height*0.5 | |
to_rad = Math::PI / 180.0 | |
hough = Hash.new(0) | |
img.width.times do |x| | |
#puts "#{x} of #{img.width}" | |
img.height.times do |y| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A | |
# B | |
# | |
# D | |
# | |
# C | |
# E | |
# | |
# F | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db, oui, company, address = {}, nil, nil, '' | |
lines = File.readlines('oui.txt') #http://standards.ieee.org/develop/regauth/oui/oui.txt | |
lines.each do |line| | |
#line.encode!('UTF-16', 'UTF-8', :invalid => :replace, :replace => '').encode!('UTF-8', 'UTF-16').rstrip! | |
line = line.unpack("C*").pack("U*").rstrip | |
if m = line.match(/^(\d\d-\d\d-\d\d)\s+\(hex\)\s+(.*?)$/) | |
oui, company = m[1], m[2] | |
elsif oui && company && m = line.match(/^\s+(.*?)$/) | |
address << m[1] << "\n" | |
elsif oui && company && line == '' |
OlderNewer