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
#!/usr/bin/env ruby | |
require 'uri' | |
require 'open-uri' | |
require 'tmpdir' | |
require 'open3' | |
module MacOS | |
module Desktop | |
BACKGROUND_TEMPLATE = "tell application \"Finder\"\n set myFile to POSIX file %s as string\n set desktop picture to file myFile\nend tell" |
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
#include <stdio.h> | |
char const * template[] = { | |
"%i", | |
"Buzz", | |
"Fizz", | |
"FizzBuzz" | |
}; | |
const int __donotuseme3[] = { 2, 0, 0 }; | |
const int __donotuseme5[] = { 1, 0, 0, 0, 0 }; |
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
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 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
#!/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 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
#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 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
#!/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 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 '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 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 '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 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
# 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 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 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 |