Skip to content

Instantly share code, notes, and snippets.

View asakasinsky's full-sized avatar

Vasily Asakasinsky asakasinsky

View GitHub Profile
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
import os
import argparse
import urllib2
from mutagen.id3 import ID3, TIT2, TALB, TPE2, TCOM, TCON, TRCK, APIC
class get_my_radiot(object):
/*
* Vanilla JS - Touch Gestures
* @version 0.1
* @inspired QuoJS - http://quojs.tapquo.com
*
* Supported Gestures: singleTap, doubleTap, hold,
* swipe, swiping, swipeLeft, swipeRight, swipeUp, swipeDown,
* rotate, rotating, rotateLeft, rotateRight, pinch, pinching,
* pinchIn, pinchOut,
* drag, dragLeft, dragRight, dragUp, dragDown
import colorsys
def get_dominant_color(image):
"""
Find a PIL image's dominant color, returning an (r, g, b) tuple.
"""
image = image.convert('RGBA')
# Shrink the image, so we don't spend too long analysing color
class RGBColor(object):
def __init__(self, value):
"""
A representation of an RGB color, allowing color manipulation.
Can take values in the form of strings, integers,
three-element iterables, or another RGBColor object.
>>> print RGBColor('#FFF')
var ArrayModel = function(){};
ArrayModel.prototype = [];
_.extend(ArrayModel.prototype, {
pointer: -1,
next: function ()
{
if (!((this.pointer + 1) in this)) {return false;}
this.pointer = this.pointer + 1;
return this;
if (typeof String.prototype.trim === 'undefined') {
String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g, '');};
String.prototype.ltrim=function(){return this.replace(/^\s+/,'');};
String.prototype.rtrim=function(){return this.replace(/\s+$/,'');};
String.prototype.fulltrim=function(){return this.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,'').replace(/\s+/g,' ');};
}
if (typeof String.prototype.capitaliseFirstLetter === 'undefined') {
String.prototype.capitaliseFirstLetter=function(){return this.charAt(0).toUpperCase() + this.slice(1);};
}
if (typeof String.prototype.transliterate === 'undefined') {

How to make faster scroll effects?

  • Avoid too many reflows (the browser to recalculate everything)
  • Use advanced CSS3 for graphic card rendering
  • Precalculate sizes and positions

Beware of reflows

The reflow appens as many times as there are frames per seconds. It recalculate all positions that change in order to diplay them. Basically, when you scroll you execute a function where you move things between two reflows. But there are functions that triggers reflows such as jQuery offset, scroll... So there are two things to take care about when you dynamically change objects in javascript to avoid too many reflows:

#!/usr/bin/env python
from sys import argv,exit
import urllib2
import urllib
import json
print '\033[1;32m[+]\033[0m Reverse ip lookup by MMxM'
if(len(argv) != 2):
@asakasinsky
asakasinsky / sms_pdu.py
Created April 22, 2014 13:05
Python script to send sms via Siemens CX65 with Prolific PL2303 USB-to-Serial port adapter. Source: http://habrahabr.ru/post/58348/
#!/usr/bin/python
# COM-port settings
# Add this string
# KERNEL=="ttyUSB[0-9]", RUN+="/bin/stty -F /dev/%k speed 9600 -brkint -icrnl ixoff -imaxbel -opost -onlcr -isig -icanon -echo -echoe"
# in /etc/udev/rules.d/50-udev.rules
import os
import sys
@asakasinsky
asakasinsky / guafal.sh
Last active August 29, 2015 14:04
Gather Unique User-Agents from access_log
#!/bin/bash
# GUAFAL
# Gather User-Agents From Access Log
WORK_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ "$1" == "" ]; then
echo "Sorry, i need an access_log path."
exit 1
fi