Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin Carmody skinofstars

View GitHub Profile
View gist:2634670
function Challenge(name){
var self = this;
self.name;
}
function GBKAuthedViewModel() {
var self = this;
// other stuff...
@skinofstars
skinofstars / gist:2965626
Created Jun 21, 2012
Update all MySQL ENGINE TYPE .sql within a collection of Zips. For updating legacy update files.
View gist:2965626
#!/usr/bin/env bash
# for each zip in the folder
# unpack to temp loc
# for each sql
# find "TYPE=" and replace with "ENGINE="
# repack and replace original
# remove temp loc
FILES=$1
View gist:2995747
// we have two counters, so we can tie people while still incrementing the pos
$rank = 1;
$pos_count = 1;
// set the initial visit count
$visit_count = $leaderboard[0]['visit_count'];
foreach ($leaderboard as $lUser) {
if ($lUser['visit_count'] != $visit_count) {
$visit_count = $lUser['visit_count'];
@skinofstars
skinofstars / gist:3350336
Created Aug 14, 2012
Orchestra Timezone Error
View gist:3350336
PHP Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead' in /tmp/sf2standard/cache/classes.php:9010#012Stack trace:#012#0 /tmp/sf2standard/cache/classes.php(9010): DateTime->__construct()#012#1 /tmp/sf2standard/cache/classes.php(9110): Monolog\Logger->addRecord(500, 'Exception: Date...', Array)#012#2 /var/www/e079e8ba3a84ff32f9515c7d222542ba7afe74e2/app-server/vendor/symfony/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php(53): Monolog\Logger->crit('Exception: Date...')#012#3 [internal function]: Symfony\Component\HttpKernel\EventListener\ExceptionListener->onKernelException(Object(Symfony\Component\HttpKernel\Event\GetResponseForExc
@skinofstars
skinofstars / gist:3621158
Created Sep 4, 2012
Knockout js computed - For conversions in form fields between date objects and strings
View gist:3621158
function User() {
var self = this;
self.dob = ko.observable('');
}
function UserViewModel() {
self.user = ko.observable(new User);
self.dobEdittable = ko.computed({
read: function() {
@skinofstars
skinofstars / gist:3776450
Created Sep 24, 2012
quick function comparison example
View gist:3776450
// js
var helloParam = function(param) {
return "hello "+param;
}
console.log(helloParam("world"));
// php
function helloPram($param) {
return "hello ".param;
View gist:3913408
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
HISTCONTROL=$HISTCONTROL${HISTCONTROL+:}ignoredups
View gist:4067215
class UserController extends Controller
{
public function editAction()
{
$user = $this->container->get('security.context')->getToken()->getUser();
$form->setData($user);
$req = $this->container->get("request");
if($req->getMethod() == 'POST'){
$reqObj = $req->request;
$form->bind($reqObj);
@skinofstars
skinofstars / gist:4207221
Created Dec 4, 2012
Whitespace python for loop - for when you don't want to use split( )
View gist:4207221
entry = input("Enter a Mayan date: ")
i=0 # this is used to track our position in the string
output = "" # start with output set to nothing
while entry[i:]:
# if we hit a space, then we've got to the end of that number
# print it out and reset the output
if entry[i] == " ":
print (output)
@skinofstars
skinofstars / gist:4217271
Created Dec 5, 2012
Count DOM injections
View gist:4217271
var insertCount = 0;
document.addEventListener("DOMNodeInserted", function( e ) {
insertCount++;
console.log(insertCount);
}, false);