Skip to content

Instantly share code, notes, and snippets.

Avatar

Igor Davydenko playpauseandstop

View GitHub Profile
@playpauseandstop
playpauseandstop / fb-friends-diff.py
Created Feb 7, 2012
Script to check who of your Facebook friends were removed from FB or unfriend you.
View fb-friends-diff.py
#!/usr/bin/env python
#
# Script to check who of your Facebook friends were removed from FB or unfriend
# you.
#
# Requirements
# ============
#
# * Linux / Mac OS X / other Unix
# * `Python <http://www.python.org/>`_ 2.6 or 2.7
@playpauseandstop
playpauseandstop / Integer.rb
Created Feb 8, 2012
Hey, javascript! Are you fucking kidding me?!
View Integer.rb
>> ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09'].map! {|x| Integer(x)}
ArgumentError: invalid value for Integer: "08"
from (irb):1:in `Integer'
from (irb):1
from (irb):1:in `map!'
from (irb):1
>> ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09'].map! {|x| Integer(Float(x))}
=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
@playpauseandstop
playpauseandstop / gist:1818351
Created Feb 13, 2012
Logout all active Django sessions
View gist:1818351
import datetime
from django.conf import settings
from django.contrib.auth import logout
from django.contrib.auth.models import User
from django.contrib.sessions.models import Session
from django.http import HttpRequest
from django.utils.importlib import import_module
@playpauseandstop
playpauseandstop / settings.py
Created May 2, 2012
Disable Flask's debug logger if testing mode enabled
View settings.py
import logging
import os
DEBUG = False
TESTING = 'TESTING' in os.environ or 'nosetests' in os.environ.get('_', '')
try:
from settings_local import *
@playpauseandstop
playpauseandstop / archive-repo.sh
Created May 28, 2012
Simple script to archive git repository
View archive-repo.sh
#!/bin/sh
#
# Simple script to archive git repository.
#
branch=HEAD
dest=`echo ~/Projects`
format=zip
prefix=`basename $(pwd)`
@playpauseandstop
playpauseandstop / output
Created Jul 13, 2012
Playing with cloned virtual environments
View output
Checking env_base virtual environment...
ordereddict exists
minimock exists
0.9
Checking env_child virtual environment...
ordereddict exists
minimock exists
0.8
View pbs-redirect-output.py
#!/usr/bin/env python
#
# Redirect outputs from pbs command result to file.
#
import os
import pbs
@playpauseandstop
playpauseandstop / multiprocessing-demo.py
Created Jul 20, 2012
Run X processes in background and wait before each of this processes will end.
View multiprocessing-demo.py
#!/usr/bin/env python
#
# Run X processes in background and wait before each of this processes will
# end.
#
import sys
import time
from argparse import ArgumentParser
@playpauseandstop
playpauseandstop / app.py
Created Oct 17, 2012
Improve registering blueprints in Flask application
View app.py
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
class App(Flask):
"""
Custom ``Flask`` class.
"""
def register_blueprint(self, mixed, **kwargs):
"""
@playpauseandstop
playpauseandstop / CouchBase
Created Oct 26, 2012
CouchBase vs. Memcached vs. Redis vs. Redis Pipelined
View CouchBase
$ DRIVER=couchbase THREADS=10 make benchmark
env/bin/python ./benchmark.py
324 operations completed in 2.1607 s
2256 operations completed in 10.7558 s
1068 operations completed in 5.7570 s
2037 operations completed in 9.5393 s
2493 operations completed in 11.0871 s
2910 operations completed in 12.1000 s
2961 operations completed in 12.1318 s
2193 operations completed in 10.3703 s