Skip to content

Instantly share code, notes, and snippets.

function! s:Todo()
call s:OpenBufferFromCommand('ditz todo', function('s:IssueCallback'))
endfunction
function! s:TodoAll()
call s:OpenBufferFromCommand('ditz todo --all', function('s:IssueCallback'))
endfunction
function! s:Grep(args)
call s:OpenBufferFromCommand(printf('ditz grep "%s"', a:args), function('s:IssueCallback'))
Hello #World #in #Whitespace * # # * # # #
+ *[Space]
+ #is #marked #with"#" # #[tab] #with"*" *line-feed #with #"+" * # *so
+it #would
+be #easier #to #write #again... #All *the *non-whitespace-characters #are *ignored... * # #
+ *
+ # # # # # * * # * * # #
+ *
+ # # # # # * * # * * * *
+ *
grammar Example
rule reminder
"tell me " time "to " anything:(.+)
end
rule time
("at" / "on") " " word+ &"to "
end
rule word
ActionController::Base.logger.info "[Base] Loading config/initializers/" + File.basename(__FILE__)
class String
def to_permalink
text = self.dup
replacements = {
# replacement special character(s) to be replaced
"A" => [ "À", "Á", "Â", "Ã", "Å"],
"Ae" => [ "Ä", "Æ" ],
"C" => [ "Ç" ],
@oliyoung
oliyoung / gist:2844
Created July 28, 2008 06:02
backup database and copy it up to a server
#/usr/bin/ruby
require 'net/ftp'
@filename = "date-"+Time.now.strftime("%Y%m%d-%H%M")+".sql"
@db_user = "db6663"
@db_password = "PASSWORD"
@db_host = "my.database-server.com"
@database = "database"
@backupdir = "/path/to/backup/directory"
class Users < Application
def update
@user = User.find(params[:id])
if @user.with_access_to(:staff, :banned).update_attributes(params[:user])
# success
end
@rsanheim
rsanheim / gist:2852
Created July 28, 2008 06:47
stupid simple backup script
#!/usr/bin/env ruby
# Stupid simple rsync backup script
# The first arg is an optional bandwidth limit, and the second is an optional --v (verbose) flag
def run_cmd_with_live_stdout(cmd)
$stdout.sync = true
STDOUT.sync = true
IO.popen(cmd) do |is|
until is.eof?
foo bar ...
bla
...
I want to JOIN only the last item
table_1
------------
id | Name |
============
1 Bob |
============
table_2