Skip to content

Instantly share code, notes, and snippets.

View tadasv's full-sized avatar
👾
Building

Tadas Vilkeliskis tadasv

👾
Building
View GitHub Profile
@tadasv
tadasv / .screenrc
Created November 13, 2011 17:28
screen rc
term xterm-color
termcapinfo xterm* ti@:te@
startup_message off
vbell off
autodetach on
altscreen on
shelltitle "$ |bash"
defscrollback 10000
defutf8 on
nonblock on
@tadasv
tadasv / gist:1400728
Created November 28, 2011 15:13
bash git prompt
alias ls='ls -G'
c_cyan=`tput setaf 6`
c_red=`tput setaf 1`
c_green=`tput setaf 2`
c_sgr0=`tput sgr0`
parse_git_branch ()
{
if git rev-parse --git-dir >/dev/null 2>&1
@tadasv
tadasv / gist:1469422
Created December 12, 2011 22:25
detecting targets
16:12:27 wolfkit | vptr: #include <TargetConditionals.h> │ AkumaStreak
16:12:36 <-- | abstract (~abstract@c-98-246-165-168.hsd1.or.comcast.net) has quit (Quit: abstract) │ alex__c2022
16:12:38 +jweinberg | jer: I didn't know even rms gave up on it │ Amun-Ra
16:13:11 wolfkit | vptr: then you'll have TARGET_OS_IPHONE, TARGET_OS_MAC, etc defined
@tadasv
tadasv / gist:1929170
Created February 28, 2012 03:22
Get directory of the currently executing script
# Get dir of the script
DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@tadasv
tadasv / My settings.terminal
Created June 2, 2012 20:26
Colors settings of Mac Terminal.app
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlueColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAB
TxAQMCAwLjUwMTk2MDgxNCAxANIQERITWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xv
cqISFFhOU09iamVjdF8QD05TS2V5ZWRBcmNoaXZlctEXGFRyb290gAEIERojLTI3O0FI
Mac OS X has only 16K ports available that won't be released until socket
TIME_WAIT is passed. The default timeout for TIME_WAIT is 15 seconds.
Consider reducing in case of available port bottleneck.
You can check whether this is a problem with netstat:
# sysctl net.inet.tcp.msl
net.inet.tcp.msl: 15000
# sudo sysctl -w net.inet.tcp.msl=1000
@tadasv
tadasv / gist:5367051
Created April 11, 2013 20:49
Prime check
from math import sqrt
def is_prime(n):
if n is 2 or n is 3 or n is 5:
return True
if n % 2 == 0 or n % 3 == 0:
return False
sq = sqrt(n)
@tadasv
tadasv / gist:5461753
Created April 25, 2013 18:00
generators vs lists
[] tadas@tadascb-2 ~/tmp: cat generators.py
def munge(i):
return i ** 2 + i
def func1():
return ( munge(i) for i in xrange(10) )
def func2():
return [ munge(i) for i in xrange(10) ]
@tadasv
tadasv / rsyslogd.conf
Created May 15, 2013 21:10
rsyslog 4.x config for monitoring file contents and pushing them to loggly/papertrail
$InputFileName file.log
$InputFileTag file_tag:
$InputFileStateFile /var/spool/rsyslog/file.log_spool
$InputFileFacility local7
$InputFileMaxLinesAtOnce 100000
$InputRunFileMonitor
#
# Include all config files in /etc/rsyslog.d/
#
@tadasv
tadasv / redshift_notes.rst
Created August 2, 2013 15:18
Redshift notes

Migration

  • Altering tables requires exclusive lock on the table. If you have long running queries on a table plan ahead of time when is the right time to run the alter statements.
  • When loading data from S3 run COPY command with FILLRECORD, so that old data could be loaded if your table schema changes before your ETL process.