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
$z = array( | |
array( | |
1,array(9,9,9),2,3,4 | |
), | |
array( | |
3,5,6 | |
) | |
); | |
$array_flatten = function($array, $flatArray = array()) { | |
array_walk_recursive( |
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
#!/usr/bin/env ruby | |
# | |
# Find bloating passengers and kill them gracefully. Run from cron every minute. | |
# | |
# required for passenger since cron has no environment | |
ENV['HTTPD'] = 'httpd' | |
MEM_LIMIT = ARGV[0] || 500 | |
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
#!/usr/bin/env ruby | |
# | |
# Find bloating passengers and kill them gracefully. Run from cron every minute. | |
# | |
# required for passenger since cron has no environment | |
ENV['HTTPD'] = 'httpd' | |
MEM_LIMIT = ARGV[0] || 500 | |
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 | |
$queryArr = array(); | |
foreach(array("agent","subagent1","subagent2") as $index) { | |
$queryArr[$index] = array_key_exists($index, $_GET) ? $_GET[$index] : null; | |
} | |
$queryArr["secure"] = array_key_exists("HTTPS", $_SERVER) ? 1 : 0; | |
$query = array(); | |
foreach($queryArr as $k => $v) { |
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
// Chrome specialities | |
x.name = uki.newProperty('_name'); // assings a closure to name | |
// Uki model code: | |
addFields: function(target, names) { | |
for (var i=0; i < names.length; i++) { | |
target[names[i]] = uki.data.model._newProp(names[i]); | |
console.log(i, target[names[i]], names[i]); |
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
def initialize_with_defaults(attrs = nil) | |
initialize_without_defaults() do | |
if attrs | |
stringified_attrs = attrs.stringify_keys | |
safe_attrs = sanitize_for_mass_assignment(stringified_attrs) | |
safe_attribute_names = safe_attrs.keys.map do |x| | |
x.to_s | |
end | |
end | |
self.class._default_attribute_values.each do |attribute, container| |
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
rake routes | awk 'NR>1{gsub("^[^/]*", "");r[$1]=0} END{for(i in r)print i}' | sort |
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
map fc <Esc>:call CleanClose() | |
function! CleanClose() | |
let todelbufNr = bufnr("%") | |
let newbufNr = bufnr("#") | |
if ((newbufNr != -1) && (newbufNr != todelbufNr) && buflisted(newbufNr)) | |
exe "b".newbufNr | |
else | |
bnext | |
endif |
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
#!/usr/bin/env ruby | |
# in reference to http://tammersaleh.com/posts/the-modern-vim-config-with-pathogen | |
git_bundles = [ | |
"git://github.com/astashov/vim-ruby-debugger.git", | |
"git://github.com/msanders/snipmate.vim.git", | |
"git://github.com/scrooloose/nerdtree.git", | |
"git://github.com/timcharper/textile.vim.git", | |
"git://github.com/tpope/vim-cucumber.git", | |
"git://github.com/tpope/vim-fugitive.git", |
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
# you will need to "export rvm_verbose_flag=" after using "rvm use" to shutup verbose Hook message | |
path_prepend () { path_remove $1; export PATH="$1:$PATH"; } | |
path_remove () { export PATH=`echo -n $PATH | awk -v RS=: -v ORS=: '$0 != "'$1'"' | sed 's/:$//'`; } | |
if [[ -f "Gemfile" && -d "bin" ]]; then | |
[ ! -z "$gemfiled_project_path" ] && path_remove ${gemfiled_project_path}/bin | |
export gemfiled_project_path=`pwd` | |
path_prepend ${gemfiled_project_path}/bin | |
echo "Bundler binstubs is in $gemfiled_project_path/bin" 1>&2 |
OlderNewer