Skip to content

Instantly share code, notes, and snippets.

@sprintingdev
sprintingdev / blockchain.txt
Created January 20, 2016 12:51
Verifying blockchain
Verifying that +vivekkrishna is my blockchain ID. https://onename.com/vivekkrishna
@sprintingdev
sprintingdev / scraper.js
Created May 29, 2015 00:30
jasmine-node Asynchronous callback unit testing
var request = require("require"); //request npm module
var Scraper = function() {
};
Scraper.prototype.scrape = function(url, callback) {
request(url, function responseCallback(error, response, html) {
if(error) {
callback(error);
} else {
console.log(html);
@sprintingdev
sprintingdev / FizzBuzz.groovy
Last active August 29, 2015 13:58
The Standard Fizz Buzz program in Groovy
def fizz = "fizz"
def buzz = "buzz"
(1..100).collect {Integer i ->
String s = "";
s += i%3==0?fizz:""
s += i%5==0?buzz:""
return s?:i
@sprintingdev
sprintingdev / mapper.py
Created March 15, 2014 12:15
MapReduce : Find hashtags and counts.
#!/usr/bin/python
import sys
import csv
import re
for line in sys.stdin:
for hashtag in re.findall(r"#[a-zA-Z_]+", line):
print "{0}\t{1}".format(hashtag.lower(), 1)
@sprintingdev
sprintingdev / relative_to_absolute_path.py
Created February 6, 2014 12:47
A python script to replace relative paths in src/href attributes of HTML with absolute paths. Created with help from http://stackoverflow.com/questions/3836644/c-sharp-convert-relative-to-absolute-links-in-html-string and http://docs.python.org/2/howto/regex.html
#!/usr/bin/env python
import re
import os
def srcrepl(match):
"Return the file contents with paths replaced"
absolutePath = "http://www.example.com/" #update the URL to be prefixed here.
print "<" + match.group(1) + match.group(2) + "=" + "\"" + absolutePath + match.group(3) + match.group(4) + "\"" + ">"
return "<" + match.group(1) + match.group(2) + "=" + "\"" + absolutePath + match.group(3) + match.group(4) + "\"" + ">"
#