Skip to content

Instantly share code, notes, and snippets.

Avatar

Kian Ryan kianryan

View GitHub Profile
View twitter_message.rb
require 'mechanize'
module CCCB::Core::TwitterMessage
extend Module::Requirements
TWITTER_REGEX = /twitter.com\/(?<name>[A-Za-z0-9_]*)\//i
needs :bot, :links
View twitter_message.rb
require 'mechanize'
module CCCB::Core::TwitterMessage
extend Module::Requirements
TWITTER_REGEX = /twitter.com\/(?<name>[A-Za-z0-9_]*)\//i
needs :bot, :links
@kianryan
kianryan / search_epub.sh
Created Apr 29, 2014
Search for a given word in a sentence in a collection of epubs
View search_epub.sh
for file in Terry*.epub; do echo $file; unzip -p "$file" | egrep -no '(\w+\s+)+force(\s+\w+)+'; done
@kianryan
kianryan / xml-curl.sh
Created Jun 24, 2014
Post XML Payload from Curl
View xml-curl.sh
curl -k -X POST -d @filename.xml -H "Content-Type: application/xml" URL
@kianryan
kianryan / gist:2157669
Created Mar 22, 2012
Attempting to circumvent the 4ms setTimeout restriction
View gist:2157669
var ts = new Date();
var diff = 0;
var count = 0;
var callMe = function() {
var localTs = new Date();
diff = localTs.getTime() - ts.getTime();
ts = localTs;
console.log('Diff:' + diff);
@kianryan
kianryan / gist:2695573
Created May 14, 2012
Replacing MBUnit tests with XUnit tests - some regexs.
View gist:2695573
Assert.Equal\({.+}, {.+}, .+\);
Assert.Equal(\1, \2);
Assert.NotNull\({.+}, .+\);
Assert.NotNull(\1);
Assert.GreaterThan\({.+}, {.+}\);
Assert.True(\1 > \2);
--
View gist:3424744
C:\Users\kian>tracert www.twitter.com
Tracing route to twitter.com [199.59.148.10]
over a maximum of 30 hops:
1 <1 ms <1 ms <1 ms 172.16.155.2
2 * * * Request timed out.
3 * * * Request timed out.
4 * ^C
View soapclient_debug
echo "====== REQUEST HEADERS =====" . PHP_EOL;
var_dump($client->__getLastRequestHeaders());
echo "========= REQUEST ==========" . PHP_EOL;
var_dump($client->__getLastRequest());
echo "========= RESPONSE =========" . PHP_EOL;
var_dump($response);
@kianryan
kianryan / headerfooter.html
Created Aug 21, 2013
CSS/HTML Header Footer Demo
View headerfooter.html
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Test2</title>
<style type="text/css" media="all">
div.page {
@kianryan
kianryan / geocoding.cs
Last active Dec 22, 2015
Google Geocoding Example API v3
View geocoding.cs
public void GoogleGeoCode(string address, out double lat, out double lon)
{
string url = "http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=" + address;
var req = (HttpWebRequest)WebRequest.Create(url);
var reader = new StreamReader(req.GetResponse().GetResponseStream());
var body = reader.ReadToEnd();
lat = double.Parse(Regex.Match(body, @"""lat\"" : ([\d\.]+)").Groups[1].Value);