This file contains 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
export ROOT="${HOME}/wii-linux" | |
export BUILDDIR="${PWD}" | |
export LFS_TGT=powerpc-linux | |
export PATH="${PATH}:${BUILDDIR}/tools/bin:${ROOT}/bin" | |
( | |
wget -c 'http://www.linuxfromscratch.org/patches/lfs/7.2/binutils-2.22-build_fix-1.patch' | |
wget -c 'http://ftp.gnu.org/gnu/binutils/binutils-2.22.tar.gz' | |
wget -c 'http://ftp.gnu.org/gnu/mpfr/mpfr-3.1.1.tar.xz' | |
wget -c 'http://ftp.gnu.org/gnu/gmp/gmp-5.0.5.tar.xz' |
This file contains 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
#!/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: '[email protected]', |
This file contains 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
#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,\ |
This file contains 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
#!/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' |
This file contains 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 '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" |
This file contains 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 '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 | |
} | |
} |
This file contains 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
# 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 |
This file contains 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 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 |
This file contains 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
#!/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) |
This file contains 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
#!/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) |