Skip to content

Instantly share code, notes, and snippets.

View sial-ari's full-sized avatar
☠️

Vladimir (sial) Todorov sial-ari

☠️
View GitHub Profile
@sial-ari
sial-ari / postgres-cheatsheet.md
Created June 2, 2017 08:23 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

If run with -E flag, it will describe the underlaying queries of the \ commands (cool for learning!).

Most \d commands support additional param of __schema__.name__ and accept wildcards like *.*

#!/bin/bash
# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo 'This script must be run as root!' 1>&2
exit 1
fi
# Add needed repositories
if ! add-apt-repository -y ppa:openjdk-r/ppa; then

Keybase proof

I hereby claim:

  • I am sial-ari on github.
  • I am sial (https://keybase.io/sial) on keybase.
  • I have a public key ASBRSiEh0rbj5S_yi65GLuSp9VfijttGWli0lixFuD3hmgo

To claim this, I am signing this object:

@sial-ari
sial-ari / gist:f96d8485ca783f7d7d54
Last active September 14, 2015 10:15 — forked from atcuno/gist:3425484ac5cce5298932
HowTo: Privacy & Security Conscious Browsing

The purpose of this document is to make recommendations on how to browse in a privacy and security conscious manner. This information is compiled from a number of sources, which are referenced throughout the document, as well as my own experiences with the described technologies.

I welcome contributions and comments on the information contained. Please see the How to Contribute section for information on contributing your own knowledge.

Table of Contents

@sial-ari
sial-ari / latency.markdown
Last active August 29, 2015 19:54 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

altwin:menu = +altwin(menu)
altwin:meta_alt = +altwin(meta_alt)
altwin:ctrl_win = +altwin(ctrl_win)
altwin:meta_win = +altwin(meta_win)
altwin:left_meta_win = +altwin(left_meta_win)
altwin:super_win = +altwin(super_win)
altwin:hyper_win = +altwin(hyper_win)
altwin:alt_super_win = +altwin(alt_super_win)
altwin:swap_lalt_lwin = +altwin(swap_lalt_lwin)
grp:switch = +group(switch)
cd wkhtmltopdf
1908 ls
1909 wget http://wkhtmltopdf.googlecode.com/files/wkhtmltoimage-0.11.0_rc1-static-amd64.tar.bz2
1910* cd ..
1911* cd downloads
1912* ls
1913* cd wkhtmltopdf-qt
1914* ls
1915* git checkout staging
1916* ./configure -release -static -fast -exceptions -no-accessibility -no-stl -no-sql-ibase -no-sql-mysql -no-sql-odbc -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-qt3support -xmlpatterns -no-phonon -no-phonon-backend -webkit -no-scripttools -no-mmx -no-3dnow -no-sse -no-sse2 -qt-zlib -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -graphicssystem raster -opensource -nomake tools -nomake examples -nomake demos -nomake docs -nomake translations -no-opengl -no-dbus -no-multimedia -no-openssl -no-declarative -largefile -rpath -no-nis -no-cups -no-iconv -no-pch -no-gtkstyle -no-nas-sound -no-sm -no-xshape -no-xinerama -no-xcursor -no-xfixes -no-xrandr -no-mitshm -no-xinput -no-xkb -no-glib -no-openvg -no-xsync -no-audio-backend -no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 -no-avx -no-ne
@sial-ari
sial-ari / filter_remove_plus.py
Created March 31, 2012 20:38
function that removes plus sign from given text
import re
def filter_remove_plus(text):
pattern = re.compile('^\+')
lines = text.split('\n')
new_text = ""
for line in lines:
filtered_text = pattern.sub("", line)
new_text = new_text + filtered_text + "\n"
return new_text
Rehearsal ----------------------------------------
ruby
1.940000
0.020000
1.960000 ( 2.255809)
c
0.170000
0.000000
0.170000 ( 0.189972)
------------------------------- total: 2.130000sec
require "benchmark"
require "inline"
class Integer
def count_set_bits(use_c = false)
return csb(self) if use_c
return 0 if self.zero?
bits, x = 1, self
bits += 1 while (x = x & (x - 1)).nonzero?
bits
end