This file contains 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
hash = {'a' => 1, 'b' => 2} | |
# => {"a"=>1, "b"=>2} | |
hash.merge hash.symbolize_keys | |
# => {"a"=>1, "b"=>2, :a=>1, :b=>2} | |
hash.to_json | |
# => "{\"a\":1,\"b\":2}" | |
hash[:a] = 3 |
This file contains 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
# to execute this gist, run the line bellow in terminal | |
\curl -L https://raw.github.com/gist/3875946/install_source_code_pro.sh | sh |
This file contains 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
'pt-BR': | |
activerecord: | |
attributes: | |
student: | |
name: 'Nome' | |
student_users: 'Usuários' | |
# ... | |
student/student_users: |
This file contains 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
sudo apt-get install pavucontrol; pavucontrol &; | |
echo "Go to configuration tab and select the correct profile" |
This file contains 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
sql="select 1" | |
for tenant_name in tenant_1 tenant_2 tenant_3 tenant_4 | |
do | |
psql -d $tenant_name -c "$sql" | |
done |
This file contains 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
<%= simple_form_for @product do |f| %> | |
<%= f.simple_fields_for :attributes do |d| %> | |
<% f.object.attributes.try(:each) do |key, value| %> | |
<%= d.input key, :input_html => {:value => value } %> | |
<% end %> | |
<% end %> | |
<% end %> |
This file contains 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
$jruby_bin = '/path/to/jruby/bin/jruby' | |
$children_script = File.join File.expand_path('.'), 'children.rb' | |
def call_children command = '' | |
full_command = "#{$jruby_bin} -r#{$children_script} -e '#{command}'" | |
puts "Executing command: #{full_command}" | |
system full_command | |
end | |
puts "Hello from parent!" |
This file contains 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
// example from book "Head First Design Patterns". | |
// without factory pattern | |
public class PizzaStore { | |
public Pizza orderPizza(String type) { | |
Pizza pizza; | |
// bad! we have a lot of ifs here... | |
if (type.equals("cheese")) { |
This file contains 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
# enable security manager checks | |
export VERIFY_JRUBY="yes" | |
jruby sandbox.rb |
This file contains 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
<?php | |
// util function to be used by sortArrayByKey function | |
function _arraySorterByKey($key, $array, $otherArray) { | |
$a = $array[$key]; | |
$b = $otherArray[$key]; | |
if ($a == $b) | |
return 0; |