Skip to content

Instantly share code, notes, and snippets.

View shurizzle's full-sized avatar
🤌

shurizzle shurizzle

🤌
  • Vodafone, Internet
View GitHub Profile
/*
* Very simple mysql breaker
* DEVELOPER: shura, member of HUF, see https://hackers-uf.org/
*
* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*
#!/usr/bin/env ruby
# who the fuck said Ruby couldn't be hacky, NEVER DO THIS IT IS STUPID
# AND DOING IT WRONG TOO
require 'socket'
# DEBUG {{{
class TCPSocket
alias __gets__ gets
def gets(*args)
@shurizzle
shurizzle / gist:893694
Created March 30, 2011 01:23
FastCGI dispatcher for Padrino in ruby 1.9.x (needed for lighty)
#!/usr/bin/env ruby
# require rack fastcgi {{{
require 'rack/handler/fastcgi'
# support for ruby 1.9.x {{{
class FCGI; class ValuesRecord
def self::read_length(buf)
if buf.getbyte(0) >> 7 == 0
buf.slice!(0, 1).getbyte(0)
@shurizzle
shurizzle / gist:945492
Created April 27, 2011 23:46
cooler redefine method
class Object
def redefine_method(meth)
return unless block_given?
oldmeth = self.instance_method(meth)
self.send(:define_method, meth) {|*args|
yield(oldmeth.bind(self), *args)
}
end
end
@shurizzle
shurizzle / euler.rb
Created April 28, 2011 14:54
Euler Project 1-50 in a cool ruby dsl
# Usage example:
# ruby -r/path/to/this/file 'Euler.execute 1'
# library {{{
require 'benchmark'
require 'fffs'
fs = FFFS::FileSystem.parse(__FILE__ == $0 ? DATA : File.read(__FILE__).split(/^__END__$/, 2).last) #DATA doesn't work if required
class NilClass
@shurizzle
shurizzle / gist:958326
Created May 6, 2011 01:54
Greplin solution
require 'prime'
require 'net/http'
puts "1: " + Net::HTTP.get(URI.parse('http://challenge.greplin.com/static/gettysburg.txt')).tap {|str|
break (0...str.size).flat_map {|i|
(i..str.size).inject([]) {|r, j|
str[i..j].tap {|chunk|
break chunk == chunk.reverse ? r << chunk : r
}
}
@shurizzle
shurizzle / gist:1088225
Created July 17, 2011 23:22
Megavideo simple link generator (just for utility)
require 'cgi'
require 'webrick'
require 'net/http'
class Index < WEBrick::HTTPServlet::AbstractServlet
INDEX = DATA.read
def do_GET(request, response)
response.status = 200
response['Content-Type'] = "text/html"
@shurizzle
shurizzle / gist:1223923
Created September 17, 2011 13:14
Turn a github.com URL into a git.io URL.
#!/usr/bin/env ruby
# Usage: gitio URL [CODE]
#
# Turns a github.com URL
# into a git.io URL
#
# Copies the git.io URL to your clipboard.
require 'net/http'
require 'clipboard'
@shurizzle
shurizzle / gist:1872646
Created February 21, 2012 00:54
Don't blank, power off (or w/e) the screen while flash is playing in fullscreen
#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h>
#include <stdio.h>
#define WINDOW_PROPERTY(prop) XGetWindowProperty(dpy,\
w,\
XInternAtom(dpy, (prop), True),\
0,\
@shurizzle
shurizzle / gist:2171333
Created March 23, 2012 14:46
short, simple version
#!/usr/bin/env ruby
# Please insert this in your crontab
# 0 * * * * /path/to/script
CONFIG = {
host: 'smtp.gmail.com',
port: 587,
user: 'shura1991',
pass: '******',
sender: 'shura1991@gmail.com',