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 'benchmark' | |
| class Hash | |
| def hash_from_1(*keys) | |
| keys.inject({}) { |memo, obj| memo.merge(obj => self[obj]) } | |
| end | |
| def hash_from_2(*keys) | |
| self.dup.delete_if { |k, v| !keys.include? k } |
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
| var | |
| a = [1,2,3,4,5], | |
| b = [2,3], | |
| subset_of = function(arr, arr_sub) { return new RegExp("-" + arr_sub.join('-') + "-").test("-" + arr.join('-') + "-"); }; | |
| console.log(subset_of(a, b)); // true | |
| console.log(subset_of(a, b.reverse())); // false |
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 'json' | |
| require 'hpricot' | |
| require 'open-uri' | |
| module SimpleFlickr | |
| AUTH_URL = 'http://flickr.com/services/auth/'.freeze | |
| API_URL = 'http://api.flickr.com/services/rest/'.freeze | |
| # USAGE |
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
| user nginx; | |
| worker_processes 5; | |
| error_log /var/log/nginx.error.log; | |
| pid /var/run/nginx.pid; | |
| events { | |
| worker_connections 1024; | |
| } | |
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 table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB" | |
| FROM information_schema.TABLES GROUP BY table_schema; |
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
| Index: sapi/cli/config.w32 | |
| =================================================================== | |
| --- sapi/cli/config.w32 (revision 308839) | |
| +++ sapi/cli/config.w32 (working copy) | |
| @@ -6,7 +6,8 @@ | |
| ARG_ENABLE('cli-win32', 'Build console-less CLI version of PHP', 'no'); | |
| if (PHP_CLI == "yes") { | |
| - SAPI('cli', 'php_cli.c', 'php.exe'); | |
| + SAPI('cli', 'php_cli.c php_http_parser.c php_cli_server.c', 'php.exe'); |
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
| log_format complete '[$time_local] REQ_TIME:$request_time UPS_TIME:$upstream_response_time C:$remote_addr H:$host ' | |
| 'URI:$request_uri ($request_method) ST:$status SZ:$bytes_sent ' | |
| 'REFERER:http_referer AGENT:$http_user_agent'; |
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
| var gCoords = new google.maps.LatLng(-16.698395,-49.26394) | |
| , gmapData = { | |
| center: gCoords, | |
| zoom: 16, | |
| mapTypeId: google.maps.MapTypeId.ROADMAP, | |
| scrollwheel: false | |
| } | |
| , gMap = new google.maps.Map($('#google-map-localizacao').get(0), gmapData) | |
| , gMarker = new google.maps.Marker({ | |
| position: gCoords, |
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
| var body = document.body; | |
| if (body.requestFullScreen) { | |
| body.requestFullScreen(); | |
| } else if (body.mozRequestFullScreen) { | |
| body.mozRequestFullScreen(); | |
| } else if (body.webkitRequestFullScreen) { | |
| body.webkitRequestFullScreen(); | |
| } |
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
| (function($) { | |
| $.extend($.expr[':'], { | |
| inline: function(a) { | |
| return $(a).css('display') == 'inline'; | |
| }, | |
| block: function(a) { | |
| return $(a).css('display') == 'block'; | |
| } | |
| }); | |
| })(jQuery); |