Skip to content

Instantly share code, notes, and snippets.

View savonarola's full-sized avatar
🏠
Working from home

Ilia Averianov savonarola

🏠
Working from home
View GitHub Profile
Element.addMethods({
png_fix: function(el) {
var el = $(el);
var pos = navigator.userAgent.indexOf("MSIE ");
if (!(Prototype.Browser.IE && el.match('img') && el.src.include('png')) || pos == -1 ) return el;
var version = navigator.userAgent.substring(pos + 5);
if (! (((version.indexOf("5.5") == 0) || (version.indexOf("6") == 0)) && (navigator.platform == ("Win32"))) ) return el;
#!/usr/bin/perl -w
use strict;
use AnyEvent::HTTP;
use Time::HiRes qw/time/;
use constant LOGGER_INTERVAL => 1;
use constant USAGE => "$0 [requests_count] [threads_count] [url]\n";
my ( $max_requests, $max_threads, $url ) = @ARGV;
die USAGE unless $max_requests && $max_threads && $url;
<?xml version="1.0" encoding="UTF-8"?>
<items>
<item>
<TmpId>1</TmpId>
<Id>123</Id>
</item>
<item>
<TmpId>1</TmpId>
<Id>124</Id>
</item>
@savonarola
savonarola / b.pl
Created July 26, 2010 11:03 — forked from anonymous/b.pl
#!/usr/bin/perl -w
use strict;
use Benchmark;
my $h = { map { $_, $_ } 1..10000 };
timethese( 1000, {
each => sub{ my $i = 0; while( my ($k, $v) = each %$h ) { $i++ } },
#include <X11/Xlib.h>
void move(int dx, int dy) {
Display* d;
d = XOpenDisplay(0);
XWarpPointer(d,0,0,0,0,0,0,dx,dy);
XCloseDisplay(d);
}
int main(void) {
// scala -P:continuations:enable cont.scala
import scala.util.continuations.{reset,shift,cpsParam}
def saveCont[A,B](resetFun : (Unit => A @cpsParam[B,Unit] ) => B @cpsParam[B,Unit]) : A => B = {
var cc : A => B = null;
val switchFun : (Unit => A @cpsParam[B,Unit] )= Unit => {
shift{ k : (A => B) =>
cc = k
}
}
module Models
module Connections
extend ActiveSupport::Concern
included do
class_attribute :using_database, :_database_config
end
module ClassMethods
@savonarola
savonarola / rspec-syntax-cheat-sheet.rb
Created April 9, 2012 18:45 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
#!/usr/bin/env ruby
#
# Proof-of-Concept exploit for Rails Remote Code Execution (CVE-2013-0156)
#
# ## Advisory
#
# https://groups.google.com/forum/#!topic/rubyonrails-security/61bkgvnSGTQ/discussion
#
# ## Caveats
#
require 'rubygems'
require 'nokogiri'
require 'fileutils'
require 'date'
require 'uri'
# usage: ruby import.rb my-blog.xml
# my-blog.xml is a file from Settings -> Basic -> Export in blogger.
data = File.read ARGV[0]