Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jkal on github.
  • I am jkal (https://keybase.io/jkal) on keybase.
  • I have a public key whose fingerprint is D5E5 2A13 A9F8 9363 0304 5462 60A4 FCE4 2F7B 7322

To claim this, I am signing this object:

@jkal
jkal / MyApp.scala
Created July 21, 2014 12:25
Finagle HTTP routing example
import com.twitter.finagle.http.{HttpMuxer, Request, Response}
import com.twitter.finagle.Http
import com.twitter.finagle.Service
import com.twitter.finagle.http.service.RoutingService
import com.twitter.finagle.http.path._
import com.twitter.finagle.http.Method
import com.twitter.util.{Await, Future}
class IndexHandler extends Service[Request, Response] {
def apply(req: Request): Future[Response] = {
osx: app.py
py2applet --make-setup app.py --iconfile icon.icns
python setup.py py2app -A
clean:
rm -rf build/ dist/ setup.py app.log
#!/bin/bash
### ABOUT
### Runs rsync, retrying on errors up to a maximum number of tries.
### Simply edit the rsync line in the script to whatever parameters you need.
# Trap interrupts and exit instead of continuing the loop
trap "echo Exited!; exit;" SIGINT SIGTERM
MAX_RETRIES=50
#!/bin/bash
### ABOUT: See: http://gist.github.com/366269
### Runs rsync, retrying on errors up to a maximum number of tries.
### On failure script waits for internect connection to come back up by pinging google.com before continuing.
###
### Usage: $ ./rsync-retry.sh source destination
### Example: $ ./rsync-retry.sh user@server.example.com:~/* ~/destination/path/
###
### INPORTANT:
@jkal
jkal / parseAndModifyHtml.js
Created July 8, 2012 20:10 — forked from aih/parseAndModifyHtml.js
Using node.js to parse HTML with jsdom and modify it with jQuery
/**
* npm install jsdom
* npm install jquery
*/
var html = "<!doctype html><html><body><h1>Hello world!</h1></body></html>";
/* parse the html and create a dom window */
var window = require('jsdom').jsdom(html, null, {
// standard options: disable loading other assets
Usage
=====
1. Add 'urljs' in INSTALLED_APPS.
2. Hook the view in the URLconf:
url(r'^urljs/$', 'urljs.views.urljs', name='urljs'),
3. Somewhere in your main template, include the necessary JS files:
Incomplete distributed MD5 cracker implementation with Web Workers.
#
# poor man's text index
#
# a simple ruby implementation of the idea descibed in:
# http://playnice.ly/blog/2010/05/05/a-fast-fuzzy-full-text-index-using-redis/
#
require 'rubygems'
require 'text'
require 'set'
require 'redis'
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import eventlet
from eventlet.green import urllib2
from BeautifulSoup import BeautifulSoup as bs
import urlparse
class Crawler(object):