Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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 / 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 / smartmove.rb
Created April 3, 2012 16:17
Smart move video files to series or movie folder...
#!/usr/bin/env ruby
require 'rubygems'
require 'fileutils'
exit -1 if ARGV.size == 0
filename = ARGV[0]
basename = File.basename(filename)
@edsono
edsono / xterm-256color-italic.terminfo
Created August 24, 2012 15:23 — forked from sos4nt/xterm-256color-italic.terminfo
A xterm-256color based TERMINFO that adds the escape sequences for italic
# A xterm-256color based TERMINFO that adds the escape sequences for italic.
#
# Install:
#
# tic xterm-256color-italic.terminfo
#
# Usage:
#
# export TERM=xterm-256color-italic
#
@edsono
edsono / .tmux.clipboard
Created October 2, 2012 14:27 — forked from napcs/.tmux.clipboard
My tmux config
# configuration for osx clipboard support
set-option -g default-command "reattach-to-user-namespace -l sh"
#!/usr/bin/ruby
=begin
Usage: rtftomarkdown.rb FILENAME.rtf
Uses textutil, available on Mac only (installed by default)
Outputs to STDOUT
Notes:
Links are replaced with Markdown references (duplicate links combined).
%!TEX TS-program = xelatex
\documentclass[12pt]{scrartcl}
% The declaration of the document class:
% The second line here, i.e.
% \documentclass[12pt]{scrartcl}
% is a standard LaTeX document class declaration:
% we say what kind of document we are making in curly brackets,
% and specify any options in square brackets.