Skip to content

Instantly share code, notes, and snippets.

View barbuza's full-sized avatar
🇺🇦
Stand with Ukraine

Victor Kotseruba barbuza

🇺🇦
Stand with Ukraine
View GitHub Profile
// ==UserScript==
// @name lepra.newcomments
// @namespace http://leprosorium.ru
// @include http://leprosorium.ru/comments/*
// @include http://*.leprosorium.ru/comments/*
// @include http://leprosorium.ru/my/inbox/*
// ==/UserScript==
(function() {
package ru.barbuza {
import flash.external.ExternalInterface;
public class Logger {
public static const DEBUG:Number = 5;
public static const INFO:Number = 4;
public static const WARNING:Number = 3;
public static const ERROR:Number = 2;
package {
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import mx.logging.Log;
import mx.logging.LogEventLevel;
import org.casalib.display.CasaMovieClip;
require 'rubygems'
require 'optparse'
require 'URI'
require 'Time'
require 'eventmachine'
@fails = 0
@requests = 0
@request_timings = []
function remote-trailing-whitespaces {
read -n 1 -e -p 'are you sure? [y/n] ' answ
if [[ $answ == y ]]; then
echo removing trailing whitespaces from
find . -iname "$1" -type f
find . -iname "$1" -type f -print0 | xargs -0 sed -i .bak -E "s/[[:space:]]*$//"
fi
}
@barbuza
barbuza / gist:302045
Created February 11, 2010 22:30
mailru api
require 'net/http'
require 'cgi'
require 'uri'
require 'md5'
require 'json'
module Mailru
API_METHODS = ['friends.get', 'friends.getAppUsers', 'users.getInfo',
'users.isAppUser', 'users.hasAppPermission', 'payments.openDialog',
Element.implement({
show: function() {
this.setStyle("visibility", "visible");
},
hide: function() {
this.setStyle("visibility", "hidden");
}
});
@barbuza
barbuza / bitoptionsfield.py
Created May 11, 2011 10:43
BitOptionsField holds a short list of predefined options in a single integer field
# -*- coding: utf-8 -*-
from django.db import models
from django.core import exceptions
__all__ = ("BitOptionsField", )
class BitOptionsField(models.Field):
@barbuza
barbuza / contract.py
Created May 11, 2011 14:05
validate arbitrary data structures in python
# -*- coding: utf-8 -*-
import functools
import inspect
"""
Contract is tiny library for data validation
It provides several primitives to validate complex data structures
Look at doctests for usage examples
"""
@barbuza
barbuza / gist:1087877
Created July 17, 2011 18:09
tag tv show episodes from <SHOW NAME>_S<SEASON NUM>_E<EPISODE NUM>_<EPISODE ID>
set seasonNumPattern to "\\d\\d"
set episodeNumPattern to "\\d\\d"
tell application "iTunes"
repeat with I from 1 to count tracks of user playlist "show"
set track_ to track I of user playlist "show"
set name_ to name of track_
set seasonNum to (find text "(?<=S)(" & seasonNumPattern & ")" in name_ with regexp and string result) as integer
set episodeNum to (find text "(?<=E)(" & episodeNumPattern & ")" in name_ with regexp and string result) as integer