Skip to content

Instantly share code, notes, and snippets.

View playpauseandstop's full-sized avatar

Igor Davydenko playpauseandstop

View GitHub Profile
@playpauseandstop
playpauseandstop / fb-friends-diff.py
Created February 7, 2012 01:24
Script to check who of your Facebook friends were removed from FB or unfriend you.
#!/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 February 8, 2012 20:38
Hey, javascript! Are you fucking kidding me?!
>> ['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 February 13, 2012 17:08
Logout all active Django sessions
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 09:55
Disable Flask's debug logger if testing mode enabled
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 19:08
Simple script to archive git repository
#!/bin/sh
#
# Simple script to archive git repository.
#
branch=HEAD
dest=`echo ~/Projects`
format=zip
prefix=`basename $(pwd)`
@playpauseandstop
playpauseandstop / output
Created July 13, 2012 08:01
Playing with cloned virtual environments
Checking env_base virtual environment...
ordereddict exists
minimock exists
0.9
Checking env_child virtual environment...
ordereddict exists
minimock exists
0.8
#!/usr/bin/env python
#
# Redirect outputs from pbs command result to file.
#
import os
import pbs
@playpauseandstop
playpauseandstop / multiprocessing-demo.py
Created July 20, 2012 12:40
Run X processes in background and wait before each of this processes will end.
#!/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 October 17, 2012 09:31
Improve registering blueprints in Flask application
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 October 26, 2012 09:30
CouchBase vs. Memcached vs. Redis vs. Redis Pipelined
$ 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