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
| // mongo document size | |
| Object.bsonsize(db.forms.find()[0]) |
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
| # Yukarıdaki kod çalıştırıldığında şöyle bir hata alınıyor. | |
| # NoMethodError: undefined method `[]=' for 1:Fixnum | |
| # from (pry):2:in `block in __pry__' | |
| [1,2].inject({}) do |memo, obj| | |
| memo[obj] = obj | |
| end | |
| # Ama aşağıdaki şekilde "merge" ile yazarsam çalışıyor ve şöyle bir çıktı üretiyor beklendiği üzere: {1=>1, 2=>2} | |
| [1,2].inject({}) do |memo, obj| | |
| memo.merge(obj => obj) |
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
| <%# partial'ın adı "_flash.html_erb" OLAMAMALI!!!!! %> | |
| <% unless flash.empty? %> | |
| <div class="flash"> | |
| <% flash.each do |k, v| %> | |
| <%= content_tag :div, v, class: k.to_s %> | |
| <% end %> | |
| </div> | |
| <% 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
| setxkbmap -option ctrl:nocaps |
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
| # Assumptions: | |
| * Rails 3.2.x | |
| * nginx | |
| * capistrano deploy | |
| * "X-Accel-Mapping header missing" messages in nginx error.log file | |
| * You want to serve static files with nginx instead of Rails | |
| # nginx configuration: |
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
| # Assumptions: | |
| * Rails 3.2.x | |
| * nginx | |
| * capistrano deploy | |
| * "X-Accel-Mapping header missing" messages in nginx error.log file | |
| * You want to serve static files with nginx instead of Rails | |
| # nginx configuration: |
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
| # export | |
| $ mongoexport -d database -c collection > filename.json | |
| # import | |
| $ mongoimport -d database -c collection filename.json | |
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
| > db.test.find() | |
| { "_id" : ObjectId("510128ee00000000ffffffff"), "a" : Timestamp(4294967290000, 2864434397), "b" : Timestamp(2005440768000, 287454020), "p" : Timestamp(4259970536000, 4194433536) } |
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
| > db.test_col.find() | |
| { "_id" : ObjectId("51012a6d8d74494bd8000001"), "a" : Timestamp(4294967295000, 4294967295) } |
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
| # encoding: utf-8 | |
| require 'json' | |
| require 'mongo' | |
| @conn = Mongo::Connection.new("localhost", 27017, safe: true) | |
| @db = @conn['timestamp_test'] | |
| @coll = @db['test_col'] | |
| @coll.save({a: BSON::Timestamp.new(4294967295, 4294967295)}) |