Skip to content

Instantly share code, notes, and snippets.

@mkroman
mkroman / gist:1420936
Created December 2, 2011 00:23 — forked from fender21/gist:1420876
Better way to route?
post :index do
if params.key?("create")
path = Padrino.root("tmp")
File.open(File.join(path, "#{params[:docId]}.pdf"), "w") do |file|
file.write request.body.read.force_encoding("UTF-8")
status 200
end
end
end
@mkroman
mkroman / sync.rb
Created July 19, 2011 00:20 — forked from kirkegaard/sync.rb
quick and dirty rsync backup script in ruby
#!/usr/bin/env ruby
# encoding: utf-8
require 'colored'
folders = %w{~/Development ~/Documents ~/Pictures ~/Music ~/Sites ~/Work}
log_path = ".sync/log"
destination = "/Volumes/Drobo/BACKUP/"
if Directory.exists? destination
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache" />
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache" />
<META HTTP-EQUIV="Content-Language" CONTENT="da" />
<META HTTP-EQUIV="Content-Type" content="text/html;charset=ISO-8859-1" />
</head>
<body>
<!--<div align="right">
@mkroman
mkroman / Ulla
Created January 10, 2011 20:19 — forked from Elevina/Ulla
#!/usr/bin/env ruby
# encoding: utf-8
require 'pulse'
Pulse.connect hostname: 'uplink.io', nickname: 'Ulla2' do
catch :connection_ready do
join "#uplink"
end
#!/usr/bin/env ruby
# encoding: utf-8
require 'socket'
DefaultHost = 'dpmaster.deathmask.net'
DefaultPort = 27950
ChunkSize = 2**16
UDPSocket.new.tap do |socket|
#include <iostream>
void blablabla();
using namespace std;
int main() {
blablabla();
cin.get();
return 0;
#!/usr/bin/env ruby
# encoding: utf-8
oldrev, newrev, refname = gets.split
repository = File.expand_path($0)[/([^\/]*?)\.git/]
refs, type, name = refname.split ?/