Skip to content

Instantly share code, notes, and snippets.

View asilachev's full-sized avatar
🤖

Alex Silachev asilachev

🤖
View GitHub Profile
# Show git branch
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/'
}
# Show hg branch
function parse_hg_branch {
if [ "$(hg root 2> /dev/null)" ]; then
printf "[$(hg branch)]"
fi
@asilachev
asilachev / gist:3447577
Created August 24, 2012 08:37
JavaScript horizontal sliding effect
$(".news-wall._photos").hide("slide", { direction: "left" }, 500, function() {
$(".news-wall._list").show("slide", { direction: "right" }, 250, function() {
$(".news-wall._list").hide("slide", { direction: "left" }, 250, function() {
$(".news-wall._map").show("slide", { direction: "right" }, 500, function() {
});
});
});
});
@asilachev
asilachev / gist:3529026
Created August 30, 2012 13:55
Facebook access token service usage example
import urllib2
import urllib
FACEBOOK_ID = None
ENCODED_ACCESS_TOKEN = None
ACCESS_TOKEN_MD5 = None
GET_URL = 'http://127.0.0.1:8000/api/facebook/access_token/%s/get'
@asilachev
asilachev / .bash_profile
Last active December 15, 2015 06:49
Displaying Git and Mercurial branches in command prompt
# Show git branch
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/'
}
# Show hg branch
function parse_hg_branch {
if [ "$(hg root 2> /dev/null)" ]; then
printf "[$(hg branch)]"
fi
@asilachev
asilachev / hb-test.py
Created May 31, 2014 11:00
HeartBleed test
#!/usr/bin/env python2
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford (jspenguin@jspenguin.org)
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select
@asilachev
asilachev / gitcompletion.sh
Created May 31, 2014 11:01
Git completion
#!bash
#
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
@asilachev
asilachev / excel_vb_tools.vb
Last active November 4, 2016 07:27
Excel VB tools
Sub UnhideAllSheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Visible = xlSheetVisible
Next ws
End Sub
Sub HideAllSheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
#include <stdio.h>
void find_deviation(int *v, int v_length, int d) {
int i;
int j;
int max_deviation = 0;
int value;
int min;
/usr/bin/plutil -convert xml1 -o - ~/Library/Safari/Bookmarks.plist | grep -E -o '<string>http[s]{0,1}://.*</string>' | grep -v icloud | sed -E 's/<\/{0,1}string>//g'
from django.conf import settings
# Defining alphabet of custom base as [a-z] + [A-Z] + [0-9]
alphabet = map(chr, range(97, 123) + range(65, 91)) + map(str, range(0, 10))
base = len(alphabet)
def encode(str):
reversed_str = str[::-1]
pow_num = 0