Skip to content

Instantly share code, notes, and snippets.

@nowhereman
nowhereman / windows_to_unix_to_ruby_time.rb
Created September 18, 2009 15:27
Ruby Util - Convert Windows NT Epoch Timestamp to Unix Timestamp to Ruby Time
#Convert Windows NT Epoch Timestamp to Unix Timestamp to Ruby Time
begin
windows_time = (ARGV[0].to_i if ARGV[0]) || 128976739610612366 #default value
unix_time = windows_time/10000000-11644473600
ruby_time = Time.at(unix_time)
puts ruby_time.strftime("le %d/%m/%Y à %H:%M:%S GMT %z")#French date format
unix_time2 = ruby_time.to_i
puts "Unix time: #{unix_time}"
@nowhereman
nowhereman / Better solution.sh
Created October 1, 2009 15:36
Fix ruby-oci8 gem install on Ubuntu 8.10
sudo env LD_LIBRARY_PATH=$LD_LIBRARY_PATH ORACLE_HOME=$ORACLE_HOME gem install ruby-oci8
@nowhereman
nowhereman / open_current_directory_in_git_cola.bash
Created October 14, 2009 12:13
Nautilus - Open the current directory in Git Cola
#Put this file in ~/.gnome2/nautilus-scripts directory
#!/bin/bash
#Open the current directory of Nautilus in git cola
if [ "x$NAUTILUS_SCRIPT_CURRENT_URI" = "x" ]; then
workdir=$(pwd) #FIXME
else
workdir=$(echo $NAUTILUS_SCRIPT_CURRENT_URI| sed 's/file:\/\///g')
fi
@nowhereman
nowhereman / rewrite_a_specific_commit_message_in_git.bash
Created October 14, 2009 13:45
Git - Rewriting a specific commit message in history
#!/bin/bash
#Rewriting a specific commit message in Git history
#If you have this message 'Namespace refs/original/ not empty'
#Remove the sub folders of your $GIT_REPO_ROOT/.git/refs/original
#Replace <commit-id> by your commit id !
git filter-branch --msg-filter '
test $GIT_COMMIT = <commit-id> && echo "My new commit message" || cat
' HEAD
@nowhereman
nowhereman / netbeans_in_english.sh
Created October 16, 2009 07:49
Netbeans ML always in English local
#!/bin/sh
netbeans --locale en:US
@nowhereman
nowhereman / rails_footnotes_with_netbeans_on_linux.rb
Created October 25, 2009 21:10
Rails Footnotes with Netbeans on Linux
#Rails Footnotes with Netbeans on Linux
#Put these lines in environment.rb
if defined?(Footnotes)
Footnotes::Filter.prefix = "editor://open?url=file://%s&amp;line=%d"
end
@nowhereman
nowhereman / autotest_installation.sh
Created October 26, 2009 11:44
Install Autotest with notifications on Ubuntu
#!/usr/sh
#Install Autotest on Ubuntu with notifications
sudo apt-get install libnotify-bin
sudo gem install ZenTest autotest-rails autotest-notification redgreen phocus
#Run
an-install
#In ~/.autotest, add :
require 'redgreen/autotest'
@nowhereman
nowhereman / inherited_resources_controller_instead_of_application_controller.diff
Created January 25, 2010 16:04
Patch nifty scaffold generator to add --skip-actions option for controller only. Patch nifty layout generator to used jQuery and Jammit
# Use Inherited Resources controller instead of Application controller
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
--- /opt/ree/lib/ruby/gems/1.8/gems/nifty-generators-0.3.0/rails_generators/nifty_scaffold/templates/controller.rb
+++ /home/nowhereman/project1/vendor/generators/nifty_scaffold/templates/controller.rb
@@ -1,3 +1,4 @@
-class <%= plural_class_name %>Controller < ApplicationController
+class <%= plural_class_name %>Controller < InheritedResources::Base
+ respond_to :html, :xml, :json
@nowhereman
nowhereman / README.md
Created April 23, 2010 15:08
Transform TextMate Snippets into NetBeans Code Templates

!!! Obselete Gist !!! Go to http://github.com/nowhereman/snippets-converter

Convert TextMate Snippets into NetBeans Code Templates.

How to use (for Ubuntu):

Copy your TextMate Snippets directory into the tmsnippets2netbeans folder, run ruby tmsnippets2netbeans.rb This will convert all you need and create a XML file.

@nowhereman
nowhereman / awesome_nested_set_helper.rb
Created August 26, 2010 12:32
Awesome Nested Set Helper who returns options for select with only one DB query.
# Copy this file in RAILS_ROOT/config/initializers/awesome_nested_set_helper.rb
module CollectiveIdea::Acts::NestedSet::Helper
# Like #nested_set_options helper but with only one DB query
#
# Returns options for select.
# You can exclude some items from the tree.
# You can pass a block receiving an item and returning the string displayed in the select.
#
# == Params