Skip to content

Instantly share code, notes, and snippets.

View hemanth's full-sized avatar
🐜
🧘‍♂️

Hemanth HM hemanth

🐜
🧘‍♂️
View GitHub Profile
@hemanth
hemanth / async.py
Created June 14, 2013 03:03
Async subprocess execution in python.
import sys
from subprocess import PIPE, Popen
from threading import Thread
try:
from Queue import Queue, Empty
except ImportError:
from queue import Queue, Empty # python 3.x
ON_POSIX = 'posix' in sys.builtin_module_names
@hemanth
hemanth / watir-webdriver-setup.bash
Created June 3, 2013 04:08
watir-webdriver-setup script for GNU/Linux.
# works for all linux flavours [tested on Ubuntu, Fedora, CentOS]
# Author : Hemanth.HM
#!/bin/bash
shopt -s nocaseglob
set -e
ruby_version="1.9.3"
ruby_version_string="1.9.3-p0"
ruby_source_url="http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz"

I cannot understand how to identify a function with a log time.

The most common attributes of logarithmic running-time function are that:

the choice of the next element on which to perform some action is one of several possibilities, and only one will need to be chosen. or

the elements on which the action is performed are digits of n

@hemanth
hemanth / ccs
Created May 25, 2013 09:25
CSS : must know selectors.
1. *
2. #X
3. .X
4. X Y
5. X
6. X:visited and X:link
7. X + Y
8. X > Y
9. X ~ Y
10. X[title]
function cd() {
async() {
{
$2 $($1)
}&
}
notify_callback() {
[[ $1 > 0 ]] && echo "You have new stuff to pull!"
}
@hemanth
hemanth / link_list
Created April 9, 2013 05:18
Ask HN: What's the best technical talk you've heard? [Links]
@hemanth
hemanth / crawly.py
Created March 29, 2013 18:02
Simple web Crawler with python twisted
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from twisted.web.client import getPage
from twisted.python.util import println
from BeautifulSoup import BeautifulSoup
from twisted.python import log
from twisted.internet import defer, task
import re
# Needs : PyOpenSSL and Twisted 12.3+
@hemanth
hemanth / inline.rb
Created March 8, 2013 14:30
inline C in ruby
require 'rubygems'
require 'inline'
class Say
inline(:C) do |builder|
builder.c 'void hello(char *name) {
printf("Hello %s!",name);
}'
end
end
@hemanth
hemanth / unix-tricks.md
Last active December 14, 2015 15:38
Unix tricks.

I have marked with a * those which I think are absolutely essential Items for each section are sorted by oldest to newest. Come back soon for more!

BASH

  • In bash, 'ctrl-r' searches your command history as you type
  • Add "set -o vi" in your ~/.bashrc to make use the vi keybindings instead of the Emacs ones. Takes some time to get used to, but it's fantastic!
  • Input from the commandline as if it were a file by replacing 'command < file.in' with 'command <<< "some input text"'
  • '^' is a sed-like operator to replace chars from last command
@hemanth
hemanth / capturescreen.js
Last active December 12, 2015 08:48
video capture the page, with getUserMedia()
// chrome://flags and Enable screen capture support in getUserMedia()
navigator.webkitGetUserMedia({
video: {
mandatory: {
chromeMediaSource: 'screen'
}
}
}, function (e) {
console.log(e);