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
| bash -c ' | |
| # | |
| # make sure sudo users have the full path... | |
| # | |
| # sudo visudo | |
| # Defaults env_keep += "PATH" | |
| # Defaults !secure_path | |
| # |
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
| # let's dig the server | |
| dig example.com | |
| # from the DNS answer we are interested in the authority section | |
| #;; AUTHORITY SECTION: | |
| #example.com. 79275 IN NS a.iana-servers.net. | |
| #example.com. 79275 IN NS b.iana-servers.net. | |
| # now we find out all subdomains | |
| dig @a.iana-servers.net example.com axfr |
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
| module ApiPageHelper | |
| PAGINATE_OPTIONS = { | |
| :default_page_size => 10 | |
| } | |
| PAGINATE_PARAMS = [ "page", "offset", "size" ] | |
| def paginate(coll, options = {}) | |
| options = PAGINATE_OPTIONS.merge(options) | |
| if params[:page] | |
| page = params[:page].to_i | |
| size = (params[:size] || options[:default_page_size]).to_i |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js'></script> | |
| <script> | |
| $(document).ready(function(){ | |
| function debug(str){ $("#debug").append("<p>"+str+"</p>"); }; | |
| if(typeof WebSocket === 'undefined') { | |
| alert("Your browser does not support websockets.") | |
| } |
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
| location ~* ^/remote-files/(http[s]*://)(.*?)/(.*) { | |
| # Do not allow people to mess with this location directly | |
| # Only internal redirects are allowed | |
| internal; | |
| # nginx has to be able to resolve the remote URLs | |
| resolver 8.8.8.8; | |
| # Location-specific logging | |
| #access_log /usr/local/etc/nginx/logs/internal_redirect.access.log main; |
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=/path/to/your/app/current | |
| PID=$APP_ROOT/tmp/pids/unicorn.pid | |
| ENVIRONMENT=production |
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 'bundler/vlad' | |
| require 'vlad/rvm' | |
| set :default_stage, 'production' | |
| set :shared_paths, { | |
| 'log' => 'log', | |
| 'system' => 'public/system', | |
| 'pids' => 'tmp/pids', | |
| 'sockets' => 'tmp/sockets', |
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
| # Simple JOIN | |
| User.joins(:account) # User -> Account | |
| # Will produce | |
| # SELECT `users`.* FROM `users` INNER JOIN `accounts` ON `accounts`.`user_id` = `users`.`id` | |
| # Complicated JOIN | |
| Trait.joins(:user => :account) # Trait -> User -> Account | |
| # Will produce | |
| # SELECT `traits`.* FROM `traits` INNER JOIN `users` ON `users`.`id` = `traits`.`user_id` INNER JOIN `accounts` ON `accounts`.`user_id` = `users`.`id` |
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
| if test -z $1 | |
| then | |
| echo "$0 : You must set a project name" | |
| exit 1 | |
| else | |
| if test -d /srv/sites/$1/www/ | |
| then | |
| if test -d /srv/sites/$1/www/bitrix/modules/main/ | |
| then | |
| echo 'packing site...' |