Skip to content

Instantly share code, notes, and snippets.

View luke-gru's full-sized avatar

Luke Gruber luke-gru

  • Montreal, Quebec
View GitHub Profile
@luke-gru
luke-gru / gist:1009529
Created June 5, 2011 23:16
commandline browser opening
xdg-open http://www.google.com works on linux
or, on debian: /etc/alternatives/x-www-browser
#!/usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
if ARGV.empty?
repo_name = File.expand_path(".").split("/").last
elsif ARGV.count == 1 && !ARGV[0].match(/-[-]?/)
repo_name = ARGV[0]
end
#!/usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
if ARGV.empty?
repo_name = File.expand_path(".").split("/").last
elsif ARGV.count == 1 && !ARGV[0].match(/-[-]?/)
repo_name = ARGV[0]
end
#!/usr/bin/env ruby
#puts "what dir are you in?"
#$gitdir = $stdin.gets.chomp #should work off of cd and then check for .git dir
if File.exists?('.git')
$gitdir = `pwd`.chomp
else
begin
# Dir::chdir($gitdir)
rd, wr = IO::pipe
#!/usr/bin/env ruby
require 'socket'
host = 'localhost'
port = 2000
begin
# Give the user some feedback while connecting.
STDOUT.print "Connecting..." # Say what we're doing
STDOUT.flush # Make it visible right away
s = TCPSocket.open(host, port) # Connect
#!/usr/bin/env ruby
#puts "what dir are you in?"
#$gitdir = $stdin.gets.chomp #should work off of cd and then check for .git dir
if File.exists?('.git')
$gitdir = `pwd`.chomp
else
begin
# Dir::chdir($gitdir)
rd, wr = IO::pipe
#!/usr/bin/env ruby
def quit?
begin
# See if a 'Q' has been typed yet
while c = STDIN.read_nonblock(1)
puts "I found a #{c}"
return true if c == 'Q'
end
# No 'Q' found
#!/usr/bin/env ruby
require 'webrick'
include WEBrick
s = HTTPServer.new(:Port => 2002)
class MyServlet < HTTPServlet::AbstractServlet
def do_GET(req, res)
<html>
<head>
<script>
var debug = true;
var main = function display_time( ) {
var d = new Date( );
var h = d.getHours( );
var m = d.getMinutes( );
var ampm = (h >= 12) ? "PM" : "AM";
function child_of(o) {
function F() {}
F.prototype = o;
return new F();
}
function Obj() {
this.speed = 10;
}