Skip to content

Instantly share code, notes, and snippets.

View sgrankin's full-sized avatar
🎏

Sergey Grankin sgrankin

🎏
  • 18:33 (UTC -04:00)
View GitHub Profile
@sgrankin
sgrankin / gist:2776376
Created May 23, 2012 17:00
Remove delay for bad passwords in ubuntu
diff --git i/pam.d/common-auth w/pam.d/common-auth
index dc84b87..ff34113 100644
--- i/pam.d/common-auth
+++ w/pam.d/common-auth
@@ -14,7 +14,7 @@
# pam-auth-update(8) for details.
# here are the per-package modules (the "Primary" block)
-auth [success=1 default=ignore] pam_unix.so nullok_secure
+auth [success=1 default=ignore] pam_unix.so nullok_secure nodelay
@sgrankin
sgrankin / Rakefile
Created October 2, 2012 06:44
Testflight deployment rake script (obsolete)
# encoding: UTF-8
require 'pathname'
namespace :deploy do
desc 'Deploy archive to TestFlight'
task :testflight do
# Only useful if we're re-signing the app with a different cert.
# SIGNING_IDENTITY = ENV['CODE_SIGN_IDENTITY']
# PROVISIONING_PROFILE = Pathname.new(ENV['BUILT_PRODUCTS_DIR']) + ENV['CONTENTS_FOLDER_PATH'] + ENV['EMBEDDED_PROFILE_NAME']
raise 'This task can only be run as part of Xcode Archive build' if !ENV['ARCHIVE_PATH']
@sgrankin
sgrankin / ssh-proxy.rb
Created October 20, 2012 23:56
SSH local/remote proxy
#!/usr/bin/env ruby
require 'resolv'
require 'optparse'
require 'ostruct'
require 'pp'
$opts = OpenStruct.new
parser = OptionParser.new do |parser|
parser.banner = <<-EOS
#$0:
@sgrankin
sgrankin / gist:4282046
Created December 14, 2012 02:26
iOS5/6 shouldAutorotateToInterfaceOrientation compatibility
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
@sgrankin
sgrankin / macvim.rb
Created February 6, 2013 00:55
Hombrew's macvim formula using brew-installed python and ruby
require 'formula'
class Macvim < Formula
homepage 'http://code.google.com/p/macvim/'
url 'https://github.com/b4winckler/macvim/tarball/snapshot-66'
version '7.3-66'
sha1 'd11696f7089688fa96a45fc57410c60f6ca5a394'
head 'https://github.com/b4winckler/macvim.git', :branch => 'master'
@sgrankin
sgrankin / .bashrc
Created December 9, 2013 22:44
Show current command; current directory in terminal title. Source: http://unix.stackexchange.com/questions/91555/how-do-i-make-the-xterm-window-title-switch-between-the-current-running-command Includes semicolon fixup for PROMPT_COMMAND: bugs: tmux shows 'show_name'; possibly conflicting with something...
trap 'echo -ne "\033]0;${BASH_COMMAND%% *}\007"' DEBUG
function show_name {
if [[ -n "$BASH_COMMAND" ]]; then
echo -en "\033]0;`basename ${PWD}`\007"
fi
}
export PROMPT_COMMAND=${PROMPT_COMMAND:+${PROMPT_COMMAND%%;*( )};}'history -a;show_name'
@sgrankin
sgrankin / gist:7995231
Last active December 31, 2015 13:49
95% of a sorted file
function 95p { tail -n +$((` wc -l $1 | cut -d ' ' -f 2 `*95/100)) $1 | head -n 1 ; };
@sgrankin
sgrankin / gist:7997492
Last active December 31, 2015 13:59
Add trailing new line to files
sed -e '$a\' *
import logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s %(levelname)7s: %(message)s', # [%(name)s +%(lineno)d]',
datefmt='%Y-%m-%dT%H:%M:%S%z',
)
logger = logging.getLogger(__name__)
#!/bin/sh
OUT="${1%.*}.pdf"
$(dirname "$0")/gprof2dot.py -f pstats "$@" | dot -Tpdf > $OUT
open $OUT