Skip to content

Instantly share code, notes, and snippets.

c0ldlimit

Block or report user

Report or block c0ldlimit

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View tornado_cookie_secret_generator.py
View gist:923089083b5c603397d0
import base64
import uuid
import hashlib
def hash_password(password, salt=None):
if salt is None:
salt = uuid.uuid4().hex
hashed_password = hashlib.sha512(password + salt).hexdigest()
View gist:4cee831a36cbd80a638c
# show the contents of the index
git ls-files --stage
# look at contents of a git object
git show [hash]
@c0ldlimit
c0ldlimit / da.py
Created May 6, 2015
#python formatting floats in python without superfluous zeros
View da.py
#http://stackoverflow.com/questions/2440692/formatting-floats-in-python-without-superfluous-zeros
#https://docs.python.org/2/library/string.html#format-specification-mini-language
'{0:g}'.format(3.140)
@c0ldlimit
c0ldlimit / s.py
Created May 5, 2015
#python generate dates for every third friday
View s.py
#http://stackoverflow.com/questions/2295765/generating-recurring-dates-using-python
import dateutil.rrule as dr
import dateutil.parser as dp
import dateutil.relativedelta as drel
rr = dr.rrule(dr.MONTHLY,byweekday=drel.FR(3),dtstart=start, count=10)
print map(str,rr)
print map(str,rr[::2])
View fib.cpp
#include<iostream>
// primary template
template<int i>
struct Fib {
static int const value = Fib<i-1>::value + Fib<i-2>::value;
};
// specializations to stop recursion
// specialization is indicated
@c0ldlimit
c0ldlimit / gist:17d5e2ba913b6e564693
Last active Aug 29, 2015
#youcompleteme vim install
View gist:17d5e2ba913b6e564693
sudo apt-get update
sudo apt-get install build-essential cmake
sudo apt-get install python-dev
#install vundle https://github.com/gmarik/Vundle.vim#about
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
#modify .virmc to use Vundle per https://github.com/gmarik/Vundle.vim#about
#Add a line like 'Plugin "Valloric/YouCompleteMe"' in bet
# run :PluginInstall to install all the specified plugins from VIM
@c0ldlimit
c0ldlimit / gist:22b636302e79b8a64a30
Created Mar 18, 2015
#phantomjs nodejs and selenium install notes
View gist:22b636302e79b8a64a30
sudo apt-get install nodejs
sudo apt-get install npm
sudo ln -s /usr/bin/nodejs /usr/bin/node
npm -g install phantomjs
pip install selenium
@c0ldlimit
c0ldlimit / gist:5095b384db3595869ebb
Last active Aug 29, 2015
#python #windows install notes
View gist:5095b384db3595869ebb
cannot find vcvarsall.bat when trying to build Python libraries. Python 2.7 is built with the Visual Studio 2008 compiler and so extension modules must be build with the same compiler. So install VS C++ 2008 Express which will set the VS90COMNTOOLS environment variable.
http://go.microsoft.com/?linkid=7729279 - by default this version will only give you a 32-bit compiler - so it will only work for installing into a 32-bit Python.
http://stackoverflow.com/questions/2817869/error-unable-to-find-vcvarsall-bat
http://stackoverflow.com/a/18045219
Update for x64 Compilers: By default this will only give you a 32-bit compiler. I learned (from here and here) that you can download specifically the Windows SDK for Windows 7 and .NET Framework 3.5 SP1 which gives you a x64 compiler for VC++ 2008 (VC++ 9.0) if you need it. Just when you are installed it, you can uncheck everything except Developer Tools >> Visual C++ Compilers which will keep you from installing all the extra SDK tools that you may not need.
View lockfreestack.h
void
Stack::push(int val)
{
StackHead expected = head.load();
StackItem *newItem = new StackItem(val);
StackHead newHead;
newHead.link = newItem;
do {
newItem->next = expected.link;
newHead.count = expected.count + 1;
You can’t perform that action at this time.