Skip to content

Instantly share code, notes, and snippets.

@edsono
edsono / automove.rb
Created October 3, 2011 22:37
Automove files to right folder...
#!/usr/bin/env ruby
require 'rubygems'
require 'fileutils'
series = {}
Dir['/home/xbmc/series/*'].each do |dirname|
series["^#{File.basename(dirname).downcase}.*"] = dirname
end
@edsono
edsono / automove.rb
Created July 21, 2011 20:44
EM automove after download complete...
#!/usr/bin/env ruby
require 'rubygems'
require 'fileutils'
require 'eventmachine'
trap("INT") do
EM.stop
end
@edsono
edsono / skel.vim
Created June 16, 2011 19:53
Create new files from template
" Vim global plugin for creating files from templates
" Last Change: 15/06/2011
" Maintainer: Edson César <[email protected]>
" License: This file is placed in the public domain.
function! s:Skel(template, filename)
if !empty(fnamemodify(a:filename, ":e"))
let l:fn = a:filename
else
let l:fn = a:filename . "." . fnamemodify(a:template, ":e")
@edsono
edsono / gist:776828
Created January 12, 2011 20:38
Generate DATE values for a year (2012 in example below) in Oracle
SELECT level n, TO_DATE('1/1/' || '2012','DD/MM/YYYY') - 1 + NUMTODSINTERVAL(level,'day') as data
FROM dual
WHERE TO_CHAR(TO_DATE('1/1/' || '2012','DD/MM/YYYY') - 1 + NUMTODSINTERVAL(level,'day'), 'YYYY') = '2012'
CONNECT BY LEVEL <= 366
@edsono
edsono / unzip_in_mem.rb
Created August 4, 2008 18:35
A little 'patch' to rubzip making possible to unzip files with StringIO
# To make possible unzip in-memory Zip files with StringIO
module Zip
class ZipInputStream
def initialize(filename, offset = 0)
super()
@archiveIO = filename.class == String ? File.open(filename, "rb") : filename
@archiveIO.seek(offset, IO::SEEK_SET)
@decompressor = NullDecompressor.instance
@currentEntry = nil