Skip to content

Instantly share code, notes, and snippets.

View svenwin's full-sized avatar

Sven Winkler svenwin

View GitHub Profile
@svenwin
svenwin / default_value_for
Created February 3, 2011 09:33
attributes are set at the end
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|
// 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]);
<?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) {
@svenwin
svenwin / gist:230973
Created November 10, 2009 15:53 — forked from jsierles/gist:29838
#!/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
@svenwin
svenwin / gist:230972
Created November 10, 2009 15:53 — forked from jsierles/gist:29838
#!/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
$z = array(
array(
1,array(9,9,9),2,3,4
),
array(
3,5,6
)
);
$array_flatten = function($array, $flatArray = array()) {
array_walk_recursive(