Skip to content

Instantly share code, notes, and snippets.

View andriisoldatenko's full-sized avatar
🏠
Working from home

Andrii Soldatenko andriisoldatenko

🏠
Working from home
View GitHub Profile
@jarib
jarib / tryselenium.rb
Created April 5, 2011 20:44
Nested LoadableComponents in Ruby
require 'selenium-webdriver'
#
# Read more about LoadableComponent here:
#
# http://code.google.com/p/selenium/wiki/LoadableComponent
#
class LoadableComponent
attr_reader :driver
@remi
remi / commit-msg
Created August 30, 2011 20:56
Git commit message spell check hook (kind of a proof of concept, but still usable)
#!/usr/bin/env ruby
# 1. Install hunspell
# $ brew install hunspell
# 2. Download a dictionary and install it in a path listed by `hunspell -D`
# $ open http://wiki.services.openoffice.org/wiki/Dictionaries
# 3. Move this file into your repository
# $ mv commit-msg /path/to/repo/.git/hooks

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@jboner
jboner / latency.txt
Last active November 15, 2024 14:00
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
@ndarville
ndarville / secret-key-gen.py
Created August 24, 2012 17:01
Generating a properly secure SECRET_KEY in Django
"""
Two things are wrong with Django's default `SECRET_KEY` system:
1. It is not random but pseudo-random
2. It saves and displays the SECRET_KEY in `settings.py`
This snippet
1. uses `SystemRandom()` instead to generate a random key
2. saves a local `secret.txt`
@cellofellow
cellofellow / b64field.py
Last active December 16, 2015 20:29 — forked from klipstein/b64field.py
import base64
import os
import mimetypes
from django.core.files.uploadedfile import SimpleUploadedFile
from tastypie import fields
class Base64FileField(fields.FileField):
"""
A django-tastypie field for handling file-uploads through raw post data.
@christianroman
christianroman / gist:6516864
Last active February 10, 2020 16:28
Install PostgreSQL 9.3.1 + PostGIS + PGRouting on CentOS 6.4
rpm -Uvh http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm
yum install postgresql93 postgresql93-server postgresql93-contrib postgresql93-devel postgis2_93 postgis2_93-utils
#Configure PostgreSQL
chkconfig postgresql-9.3 on
service postgresql-9.3 initdb
service postgresql-9.3 start
# Create PostGIS template
import base64
import os
import mimetypes
from django.core.files.uploadedfile import SimpleUploadedFile
from tastypie import fields
class Base64FileField(fields.FileField):
"""
A django-tastypie field for handling file-uploads through raw post data.
@guilu
guilu / windows terminal - Solarized Dark.reg
Created August 21, 2014 07:06
windows terminal Solarized Dark
Windows Registry Editor Version 5.00
; Registry file that maps the solarized palette to the 16 avaliable colors
; in a Windows command prompt. Note, hex values in the table are RGB but byte
; ordering of a DWORD is BGR, e.g. "ColorTable<##>"=dword:00<B><G><R>
;
; Solarized color table from http://ethanschoonover.com/solarized.
;
; NR cmd.exe PowerShell SOLARIZED HEX DWORD
; -- ------- ----------- --------- ------- --------
@obikag
obikag / PascalTriangle.py
Last active January 9, 2019 17:14
Pascal's Triangle calculated using a recursive function in Python
'''
Created on Feb 24, 2015
'''
import sys
# Recursive method to create the mathematical series
def pascal(col,row):
if(col == 0) or (col == row):
return 1
else: