Skip to content

Instantly share code, notes, and snippets.

View patryk's full-sized avatar
🍊

Patryk Szczygłowski patryk

🍊
View GitHub Profile
@eligrey
eligrey / object-watch.js
Created April 30, 2010 01:38
object.watch polyfill in ES5
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@ongaeshi
ongaeshi / console-dir.js
Created June 1, 2011 17:39
console.dir の Add-on SDK実装
// @file console-dir.js
// @brief
// @author ongaeshi
// @date 2011/06/02
//
// --------------------------------------
// console.dir({a: 1, b: 2, c: 3});
// =>
// info:
// a: 1
@kamermans
kamermans / analyze_haproxy_performance.pl
Created April 6, 2012 15:41
HAProxy log analyzer to show response latency distribution from the console
#!/usr/bin/perl
# HAProxy Performance Statistics
# by Steve Kamerman
#
# To use, pipe your HAProxy log with timing information (like "0/0/1/1/3 200") to
# this script. It will output min, max, med, avg and a latency distribution graph.
#
# Info on timing logging in HAProxy: http://code.google.com/p/haproxy-docs/wiki/TimingEvents
#
@merwok
merwok / gist:2636213
Created May 8, 2012 15:20
ReplicaSetConnection for mongokit
import pymongo
from mongokit.database import Database
# code copied and adapted from mongokit (3-clause BSD license)
class CallableMixin(object):
"""
brings the callable method to a Document. usefull for the connection's
register method
"""
@nicerobot
nicerobot / README.md
Last active June 18, 2024 19:46
Mac OS X uninstall script for packaged install of node.js from https://stackoverflow.com/a/9287292/23056

To run this, you can try:

curl -ksO https://gist.githubusercontent.com/nicerobot/2697848/raw/uninstall-node.sh
chmod +x ./uninstall-node.sh
./uninstall-node.sh
rm uninstall-node.sh
@jboner
jboner / latency.txt
Last active June 23, 2024 14:31
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active June 23, 2024 06:58
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@galex
galex / SherlockMapFragment.java
Created December 27, 2012 21:13
Google Maps v2 + ActionBarSherlock = SherlockMapFragment
package com.actionbarsherlock.app;
import android.app.Activity;
import android.support.v4.app.Watson.OnCreateOptionsMenuListener;
import android.support.v4.app.Watson.OnOptionsItemSelectedListener;
import android.support.v4.app.Watson.OnPrepareOptionsMenuListener;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.internal.view.menu.MenuItemWrapper;
import com.actionbarsherlock.internal.view.menu.MenuWrapper;
@sparanoid-bot
sparanoid-bot / speedtest.sh
Last active February 19, 2020 10:26
Update Speedtest.net Mini automatically to avoid expiring.
# NO LONGER MAINTAINED
# SEE https://gist.github.com/sparanoid/abb6e26d968accef9aa2 FOR UPDATE
DES_PATH=/usr/share
PUB_PATH=/srv/www/domain.tld/public_html
ST_DIR=speedtest
wget http://c.speedtest.net/mini/mini.zip -O $DES_PATH/$ST_DIR.zip --limit-rate=200000k
unzip -o $DES_PATH/$ST_DIR.zip -d $DES_PATH/$ST_DIR
# Remove old public files
@kixorz
kixorz / aws_iam_policy.json
Last active April 11, 2022 10:32
Update Route53 DNS records from your EC2 instance using this simple Ruby script. You can call it from rc.local after setting your hostname locally. First parameter is the desired <hostname>.<domain> Domain and other parameters are hardcoded. This script is useful for handling internal DNS changes in your systems after instance changes. Attached …
{
"Statement": [
{
"Action": [
"route53:ChangeResourceRecordSets",
"route53:GetHostedZone",
"route53:ListResourceRecordSets"
],
"Effect": "Allow",
"Resource": [