Skip to content

Instantly share code, notes, and snippets.

View tomekr's full-sized avatar

Tomek Rabczak tomekr

View GitHub Profile
@tomekr
tomekr / gist:1373857
Created November 17, 2011 17:41
great looking code
// Scanner that will read the integer
final Scanner in = new Scanner(System.in);
int inputInt;
do { // Loop until we have correct input
System.out.print("Specify an integer between 0 and 5: ");
try {
inputInt = in.nextInt(); // Blocks for user input
if (inputInt >= 0 && inputInt <= 5) {
break; // Got valid input, stop looping
} else {
==> Downloading https://github.com/b4winckler/macvim/tarball/snapshot-63
File already downloaded in /Users/Tomek/Library/Caches/Homebrew
/usr/bin/tar xf /Users/Tomek/Library/Caches/Homebrew/macvim-7.3-63.tgz
==> ./configure --with-features=huge --with-tlib=ncurses --enable-multibyte --with-macarchs=x86_64 --enable-perlinterp --enable-pythoninterp --enable-rubyinterp --enable-tclinterp
./configure --with-features=huge --with-tlib=ncurses --enable-multibyte --with-macarchs=x86_64 --enable-perlinterp --enable-pythoninterp --enable-rubyinterp --enable-tclinterp
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
@tomekr
tomekr / gist:1629343
Created January 17, 2012 22:17
full beginning to end output
$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]
$ rails -v
Rails 3.1.3
$ rails new test_app
create
create README
create Rakefile
create config.ru
create .gitignore
# it "converts message to upcased, alpha, 5 character groups with pads" do
# pad_message = "Code in Ruby, live long!"
# conversion = encrypter.convert_to_padded_alpha(pad_message)
# conversion.should == "CODEI NRUBY LIVEL ONGXX"
# end
def convert_to_padded_alpha(message)
end
def subtract(secret_num, keystream_num)
secret_num.zip(keystream_num).map do |secret, keystream|
secret = secret + 26 if keystream >= secret
secret - keystream
end
end
@tomekr
tomekr / gist:2954967
Created June 19, 2012 15:59
Evented redis with evented http request
EM.run do
# Create both an evented and non evented redis handle
@evented_redis = EM::Protocols::Redis.connect
@non_evented_redis = Redis.new
# Setup lambda in order to properly rerun code using EventMachine's next_tick method
(popper = lambda do
@evented_redis.blpop("blpop:queue", 0) do |msg|
url = msg.last
#!/usr/bin/env ruby
require 'rubygems' # if you use RubyGems
require 'daemons'
task1 = Daemons.call(:multiple => true) do
loop {
File.open("/tmp/daemon_test.log", "w") {|f| f.write(Time.now.to_s + "\n")}
sleep 5
}
end
function getFrontPage() {
var req = new XMLHttpRequest();
console.log("about to attempt a get!");
req.open("GET", "http://www.reddit.com/r/listentothis.json", true);
req.onreadystatechange = function() {
console.log(req.status);
@tomekr
tomekr / system.py
Created June 15, 2015 22:23
system.py
# If ctypes is available, use it to find system routines for UUID generation.
_uuid_generate_random = _uuid_generate_time = _UuidCreate = None
try:
import ctypes, ctypes.util
# The uuid_generate_* routines are provided by libuuid on at least
# Linux and FreeBSD, and provided by libc on Mac OS X.
for libname in ['uuid', 'c']:
try:
lib = ctypes.CDLL(ctypes.util.find_library(libname))