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
| class Hash | |
| def rename_keys(mapping) | |
| result = {} | |
| self.map do |k,v| | |
| mapped_key = mapping[k] ? mapping[k] : k | |
| result[mapped_key] = v.kind_of?(Hash) ? v.rename_keys(mapping) : v | |
| result[mapped_key] = v.collect{ |obj| obj.rename_keys(mapping) if obj.kind_of?(Hash)} if v.kind_of?(Array) | |
| end | |
| result | |
| 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
| upstream unicorn { | |
| server unix:/tmp/.sock fail_timeout=0; | |
| #server 127.0.0.1:8080 fail_timeout=0; | |
| } | |
| server { | |
| listen 80 default deferred; | |
| server_name 54.187.156.63; | |
| root /var/www/apps/points_of_light/current/public; #your project public path | |
| try_files $uri/index.html $uri @unicorn; |
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
| #!/bin/sh | |
| set -e | |
| # Example init script, this can be used with nginx, too, | |
| # since nginx and unicorn accept the same signals | |
| # Feel free to change any of the following variables for your app: | |
| TIMEOUT=${TIMEOUT-60} | |
| APP_ROOT='/var/www/apps/points_of_light/current' | |
| APP_ENV='staging' | |
| PID="/var/www/apps/points_of_light/shared/pids/unicorn.rb.pid" |
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
| working_directory "/var/www/apps/points_of_light/current" | |
| pid "/var/www/apps/points_of_light/shared/pids/unicorn.rb.pid" | |
| stderr_path "/var/www/apps/points_of_light/shared/log/unicorn.rb.log" | |
| stdout_path "/var/www/apps/points_of_light/shared/log/unicorn.rb.log" | |
| listen "/tmp/.sock", :backlog => 64; | |
| worker_processes 4 | |
| timeout 30 |
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
| #!/bin/sh | |
| set -e | |
| # Example init script, this can be used with nginx, too, | |
| # since nginx and unicorn accept the same signals | |
| # Feel free to change any of the following variables for your app: | |
| TIMEOUT=${TIMEOUT-60} | |
| APP_ROOT=/var/www/my_app | |
| APP_ENV=development | |
| PID=$APP_ROOT/tmp/pids/unicorn.pid |
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
| working_directory "/var/www/my_app" | |
| pid "/var/www/my_app/tmp/pids/unicorn.rb.pid" | |
| stderr_path "/var/www/my_app/log/unicorn.rb.log" | |
| stdout_path "/var/www/my_app/log/unicorn.rb.log" | |
| listen "/tmp/unicorn.my_app.sock" | |
| worker_processes 4 | |
| timeout 30 |
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
| upstream unicorn { | |
| server unix:/tmp/unicorn.my_app.sock fail_timeout=0; | |
| } | |
| server { | |
| listen 80 default deferred; | |
| # server_name example.com; | |
| root /var/www/my_app/public; #your project public path | |
| try_files $uri/index.html $uri @unicorn; | |
| location @unicorn { |
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
| __author__ = 'naim' | |
| squares = [] | |
| squares.append(lambda n: n*n) # list have only one element and it's index is 0 and content is lambda! | |
| print squares[0](2) |
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
| __author__ = 'naim' | |
| class MyClass: | |
| def __init__(self): | |
| self.x = 1 | |
| self.my_hash = {'fname': ('n', 'a', 'i', 'm'), 'lname': 'rajib'} | |
| def getVal(self): | |
| return self.x |
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
| __author__ = 'naim' | |
| def iteration(): | |
| count = [0] # caution of scoping variable when it is immutable like count = 0, it will local scope for | |
| # iteration() so that used mutable data type like list | |
| def increment_value(): | |
| count[0] += 1 | |
| return count[0] | |
| return increment_value |