This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'erb' | |
class Namespace | |
def initialize(hash) | |
hash.each do |key, value| | |
singleton_class.send(:define_method, key) { value } | |
end | |
end | |
def get_binding |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before = "h1. Ruby\nHello world" | |
puts "Before: #{before}" | |
res = before.gsub(/h1\..+\n/) {|c| "\n#{c}\n" } | |
puts "After: #{res}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before = "* Ruby\nHello world" | |
puts "Before: #{before}" | |
res = before.gsub(/\*.+\n+\s*[^\*]/) {|c| c.gsub(/\n+\s*/, "\n\n") } | |
puts "After: #{res}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select * from | |
( | |
select | |
CASE | |
WHEN days < (current_date - date_trunc('year', current_date)) THEN days + interval '366 days' | |
ELSE days | |
END as position, birthday | |
from | |
(select birthday, birthday - date_trunc('year', birthday) as days from birthdays) bd_in_days | |
) bd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#path can be different. For Red Hat it is /opt/PostgreSQL/9.3/share/postgresql/tsearch_data | |
iconv -f koi8-r -t utf-8 < ru_RU.aff > /usr/share/postgresql/tsearch_data/russian.affix | |
iconv -f koi8-r -t utf-8 < ru_RU.dic > /usr/share/postgresql/tsearch_data/russian.dict |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'java' | |
class Profiler | |
def initialize(name) | |
@name = name | |
@metrics = {} | |
@start_times = {} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
non empty {[Product].[All Products].Children} ON COLUMNS, | |
non empty {[Time].[Quarter].members, [Time].[Year].members} ON ROWS | |
FROM [Sales] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
if __name__ == "__main__": | |
# Initialize a names dictionary as empty to start with. | |
# Each key in this dictionary will be a name and the value | |
# will be the number of times that name appears. | |
names = {} | |
# sys.stdin is a file object. All the same functions that | |
# can be applied to a file object can be applied to sys.stdin. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ru.examples; | |
import org.jgroups.JChannel; | |
import org.jgroups.blocks.locking.LockService; | |
import java.util.concurrent.locks.Lock; | |
public class SimpleLock { | |
/** You should provide one parameter - node name */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mike@rbci:~$ psql -U postgres | |
psql (9.0.3) | |
Type "help" for help. | |
postgres=# update pg_database set datallowconn = TRUE where datname = 'template0'; | |
UPDATE 1 | |
postgres=# \c template0 | |
You are now connected to database "template0". | |
template0=# update pg_database set datistemplate = FALSE where datname = 'template1'; | |
UPDATE 1 |
OlderNewer