Skip to content

Instantly share code, notes, and snippets.

@khapota
khapota / call_func_method.py
Created February 25, 2016 07:54
Python note
#Assuming module foo with method bar:
import foo
methodToCall = getattr(foo, 'bar')
result = methodToCall()
#As far as that goes, lines 2 and 3 can be compressed to:
result = getattr(foo, 'bar')()
#https://stackoverflow.com/questions/3061/calling-a-function-of-a-module-from-a-string-with-the-functions-name-in-python
@khapota
khapota / redmine_textile2md.rb
Created February 25, 2016 07:50 — forked from yuumi3/redmine_textile2md.rb
Convert Textile to Markdown contents in Redmin
def textile_to_markdown(textile)
d = []
pre = false
table_header = false
text_line = false
textile.each_line do |s|
s.chomp!
@khapota
khapota / .screenrc
Last active February 26, 2016 01:49 — forked from rpherrera/.screenrc
Personal Config
altscreen on
term screen-256color
bind ',' prev
bind '.' next
hardstatus alwayslastline
hardstatus string '%{= kG}%-Lw%{= kW}%50> %n%f* %t%{= kG}%+Lw%< %{= kG}%-=%c:%s%{-}'
@khapota
khapota / tmuxinator.yml
Created January 28, 2016 08:20
tmuxinator profile with specific layout
# ~/.tmuxinator/general.yml
name: general
root: ~/
# Optional tmux socket
# socket_name: foo
# Runs before everything. Use it to start daemons etc.
# pre: sudo /etc/rc.d/mysqld start
@khapota
khapota / runITerm2.scpt
Last active February 19, 2016 04:51
Open some general tabs and do maximum window
-- get screen resolution
-- Finder method does not work with 10.11
set screenWidth to (do shell script "system_profiler SPDisplaysDataType | awk '/Resolution/{print $2}'")
set screenHeight to (do shell script "system_profiler SPDisplaysDataType | awk '/Resolution/{print $4}'")
-- Kill old iTerm2
-- added exit 0 to by pass error code when process did not exist.
do shell script "killall -9 iTerm2; exit 0"
-- get dock size
set-option -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix
# status bar
set-option -g status-utf8 on
set -g set-titles on
# https://github.com/seebi/tmux-colors-solarized/blob/master/tmuxcolors-256.conf
set-option -g status-bg colour235 #base02
@khapota
khapota / mitmproxy pf
Created February 13, 2015 02:17
/etc/pf.anchors/mitm
rdr pass on en0 inet proto tcp to any port 80 -> 127.0.0.1 port 8080
rdr pass on en0 inet proto tcp to any port 443 -> 127.0.0.1 port 8080
@khapota
khapota / pf.conf
Created February 13, 2015 02:17
pf conf mac os 10.10
scrub-anchor "com.apple/*"
nat-anchor "com.apple/*"
rdr-anchor "com.apple/*"
rdr-anchor "forwarding"
dummynet-anchor "com.apple/*"
anchor "com.apple/*"
load anchor "com.apple" from "/etc/pf.anchors/com.apple"
load anchor "forwarding" from "/etc/pf.anchors/mitm"
@khapota
khapota / gist:0a0f5c625e7e40cc9d81
Created August 25, 2014 16:34
PHP LDAP Authentication sample
<?php
// LDAP variables
$ldaphost = ""; // your ldap servers
$ldapport = 389; // your ldap server's port number
// Connecting to LDAP
$ldapconn = ldap_connect($ldaphost, $ldapport)
or die("Could not connect to $ldaphost");
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
if ($ldapconn) {
@khapota
khapota / gist:d6ea6cecc8a57e9eb701
Created August 1, 2014 07:22
OpenVPN Performance
tun-mtu 6000
fragment 0
mssfix 0
cipher aes-256-cbc