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
int | |
add (int a, int b) | |
{ | |
int gen = a & b; // carries | |
int pro = a ^ b; // sum | |
gen |= pro & (gen << 1); | |
pro = pro & (pro << 1); | |
gen |= pro & (gen << 2); | |
pro = pro & (pro << 2); | |
gen |= pro & (gen << 4); |
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 'rubygems' | |
require 'mechanize' | |
require 'nokogiri' | |
agent = Mechanize.new | |
# Do login | |
page = agent.get('http://monster-wow.com/') | |
form = page.form_with(:name => 'login_form') | |
form.username = ARGV[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
require 'win32ole' | |
def inputbox(message, title = '') | |
sc = WIN32OLE.new("ScriptControl") | |
sc.language = "VBScript" | |
sc.eval("Inputbox(\"#{message}\", \"#{title}\")") | |
end | |
def popup(message) | |
wsh = WIN32OLE.new('WScript.Shell') |
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
ENV['RAILS_ENV'] = 'development' | |
require '/Users/pioz/Code/ecommerce/config/application.rb' | |
app = Megiston::Application.initialize! | |
session = ActionDispatch::Integration::Session.new(app) | |
session.get '/' | |
puts session.body |
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 'tweetstream' | |
TweetStream.configure do |config| | |
config.consumer_key = 'AA' | |
config.consumer_secret = 'BB' | |
config.oauth_token = 'CC' | |
config.oauth_token_secret = 'DD' | |
config.auth_method = :oauth | |
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
s.gsub(/(.{1,78})(?: +|$)\n?|(.{78})/, "\\1\\2\n") |
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
# Written by Pioz. | |
# | |
# Deps: | |
# sudo apt-get install libgtk2.0-dev libgstreamer0.10-dev gstreamer0.10-plugins-base | |
# gem install gtk2 gstreamer | |
require 'gtk2' | |
require 'gst' | |
if ARGV.size != 1 |
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 'curses' | |
include Curses | |
init_screen | |
curs_set(frame = 0) | |
Thread.new { system "say -v Alex the rofl copter says #{'siff ' * 1000}" } |
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
# simple preforking echo server in Ruby | |
require 'socket' | |
# Create a socket, bind it to localhost:4242, and start listening. | |
# Runs once in the parent; all forked children inherit the socket's | |
# file descriptor. | |
acceptor = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0) | |
address = Socket.pack_sockaddr_in(4242, 'localhost') | |
acceptor.bind(address) | |
acceptor.listen(10) |
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
2.0.0-p0 :001 > require 'gst' | |
=> true | |
2.0.0-p0 :002 > bin = Gst::ElementFactory.make('playbin') | |
NameError: uninitialized constant Gst::ElementFactory | |
from (irb):2 |