Skip to content

Instantly share code, notes, and snippets.

@observerss
observerss / gist:3786658
Created September 26, 2012 07:51 — forked from padolsey/gist:527683
JavaScript: Detect IE
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@observerss
observerss / gevent-multiprocess.py
Created September 26, 2012 07:55 — forked from denik/gevent-multiprocess.py
Python: Gevent multiprocessing server
import sys
from gevent import server
from gevent.baseserver import _tcp_listener
from gevent.monkey import patch_all; patch_all()
from multiprocessing import Process, current_process, cpu_count
def note(format, *args):
sys.stderr.write('[%s]\t%s\n' % (current_process().name, format%args))
@observerss
observerss / gist:3798896
Last active May 8, 2020 03:50
Google Keyword Tool Scraper(selenium+python version)
# EDIT: 2013/10/20
# google has updated its kwt UI, this script doesn't work any more!
# may be I will update this script when I have time to investigate their new Interface.
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
import selenium.webdriver.support.wait
selenium.webdriver.support.wait.POLL_FREQUENCY = 0.05
import re
@observerss
observerss / gist:3798922
Last active August 6, 2023 12:03
Google Keyword Tool Scraper(casperjs version)
// EDIT: 2013/10/20
// google has updated its kwt UI, this script doesn't work any more!
// may be I will update this script when I have time to investigate their new Interface.
// requires
var utils = require('utils');
var casper = require('casper').create()
var casper = require('casper').create({
verbose: true,
@observerss
observerss / s3put
Created October 9, 2012 09:38 — forked from mattbillenstein/s3put
boto parallel s3 upload script
#!/usr/bin/env python
import gevent.monkey
gevent.monkey.patch_all()
import boto
import config
import gevent
import gevent.pool
import os
@observerss
observerss / setup.sh
Created October 10, 2012 09:04
ubuntu initialize script
#!/bin/sh
apt-get update
apt-get -y upgrade
apt-get -y install build-essential python-dev libevent-dev libxslt-dev uuid-dev python-setuptools dtach libzmq-dev
apt-get -y install sysstat vnstat redis-server mysql-server
easy_install pip
pip install virtualenvwrapper
pip install cython
pip install zerorpc lxml requests pymongo mongoengine redis redisco fabric ipython sqlalchemy bottle django flask
@observerss
observerss / gist:4142775
Created November 25, 2012 07:56
My Favorite Bash Prompt
PS1="\[\033[01;32m\]\u\[\033[00m\] \[\033[01;34m\]\w\[\033[01;31m\]\`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(git:\1)/'\`\[\033[00m\]\$ "
/*
Pretty Date script modified from John Resig here http://ejohn.org/blog/javascript-pretty-date
*/
function relativeDateTime (tdate) {
var system_date;
if (typeof (tdate) === "number") {
tdate = new Date(tdate).toString();
}
if (navigator.userAgent.match(/MSIE\s([^;]*)/)) {
@observerss
observerss / etc-init-elasticsearch.conf
Last active December 19, 2015 19:19 — forked from jaytaylor/etc-init-elasticsearch.conf
elasticsearch upstart script for official deb packages (tested with 0.90.2)
# ElasticSearch Service
description "ElasticSearch"
start on (net-device-up
and local-filesystems
and runlevel [2345])
stop on runlevel [016]
respawn
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db