Skip to content

Instantly share code, notes, and snippets.

View urjitbhatia's full-sized avatar

Urjit Singh Bhatia urjitbhatia

View GitHub Profile
@shiki
shiki / beanstalkd
Created August 9, 2010 13:41
For CentOS, a modified /etc/init.d/beanstlkd file which creates a pid file in /var/run/beanstalkd.pid
#!/bin/sh
#
# beanstalkd - a simple, fast workqueue service
#
# chkconfig: - 57 47
# description: a simple, fast workqueue service
# processname: beanstalkd
# config: /etc/sysconfig/beanstalkd
#
@rxin
rxin / ramdisk.sh
Last active December 13, 2023 02:40
ramdisk create/delete on Mac OS X.
#!/bin/bash
# From http://tech.serbinn.net/2010/shell-script-to-create-ramdisk-on-mac-os-x/
#
ARGS=2
E_BADARGS=99
if [ $# -ne $ARGS ] # correct number of arguments to the script;
then
@burnash
burnash / get_oauth2_token.py
Last active August 11, 2021 21:16
Simple command line script to fetch a Google API's access token.
'''
This script will attempt to open your webbrowser,
perform OAuth 2 authentication and print your access token.
It depends on two libraries: oauth2client and gflags.
To install dependencies from PyPI:
$ pip install python-gflags oauth2client
@adrianlzt
adrianlzt / gist:6864843
Created October 7, 2013 09:07
Netcat testing 3306 tcp connexion
[root@centos mysql]# nc -vz localhost 3306
nc: connect to localhost port 3306 (tcp) failed: Connection refused
Connection to localhost 3306 port [tcp/mysql] succeeded!
The reason is the first connection is against ::1 (IPv6), and the second to 127.0.0.1.
This could be seen with: tcpdump -i lo -n
[root@centos mysql]# grep localhost /etc/hosts
@jmoiron
jmoiron / valuer.go
Created October 14, 2013 18:03
Example uses of sql.Scanner and driver.Valuer
package main
import (
"bytes"
"compress/gzip"
"database/sql/driver"
"errors"
"fmt"
"github.com/jmoiron/sqlx"
_ "github.com/mattn/go-sqlite3"
@torsten
torsten / expanding-json-arrays-to-rows.sql
Last active April 8, 2021 15:35
Expanding JSON arrays to rows with SQL on RedShift: All queries to reproduce the technique from my blog post https://torsten.io/stdout/expanding-json-arrays-to-rows
-- Related blog post to this Gist:
-- https://torsten.io/stdout/expanding-json-arrays-to-rows
-- Run these commands on a interactive RedShift session:
CREATE TEMP TABLE clusters AS (
SELECT 1 AS id, '[1, 2]' AS node_sizes UNION ALL
SELECT 2 AS id, '[5, 1, 3]' AS node_sizes UNION ALL
SELECT 3 AS id, '[2]' AS node_sizes
);
@wenzhixin
wenzhixin / ubuntu14.04-command-line-install-android-sdk
Last active January 16, 2024 21:15
Ubuntu 14.04 command line install android sdk
# install openjdk
sudo apt-get install openjdk-7-jdk
# download android sdk
wget http://dl.google.com/android/android-sdk_r24.2-linux.tgz
tar -xvf android-sdk_r24.2-linux.tgz
cd android-sdk-linux/tools
# install all sdk packages
@htp
htp / curl-websocket.sh
Last active April 25, 2024 14:57
Test a WebSocket using curl.
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: example.com:80" \
--header "Origin: http://example.com:80" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
http://example.com:80/
@kainam00
kainam00 / slowserver.py
Created November 4, 2016 18:36
A simple HTTP server designed to be slow. Useful for testing LB timeouts and such.
#!/usr/bin/env python
# Includes
import getopt
import sys
import os.path
import subprocess
import BaseHTTPServer
import SocketServer
import time
@zz
zz / UbuntuCongestionControlBBR.md
Last active February 12, 2022 16:46 — forked from chalos/UbuntuCongestionControlBBR.md
Ubuntu using BBR