Skip to content

Instantly share code, notes, and snippets.

View skinofstars's full-sized avatar

Kevin Carmody skinofstars

View GitHub Profile
function Challenge(name){
var self = this;
self.name;
}
function GBKAuthedViewModel() {
var self = this;
// other stuff...
@skinofstars
skinofstars / gist:2965626
Created June 21, 2012 13:01
Update all MySQL ENGINE TYPE .sql within a collection of Zips. For updating legacy update files.
#!/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
// 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 August 14, 2012 15:35
Orchestra Timezone Error
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 September 4, 2012 13:29
Knockout js computed - For conversions in form fields between date objects and strings
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 September 24, 2012 15:10
quick function comparison example
// js
var helloParam = function(param) {
return "hello "+param;
}
console.log(helloParam("world"));
// php
function helloPram($param) {
return "hello ".param;
@skinofstars
skinofstars / gist:3913408
Last active October 11, 2015 20:17
my .bashrc
# ~/.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
@skinofstars
skinofstars / gist:4067215
Created November 13, 2012 17:40
sf2.1 form errors
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 December 4, 2012 18:29
Whitespace python for loop - for when you don't want to use split( )
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 December 5, 2012 16:43
Count DOM injections
var insertCount = 0;
document.addEventListener("DOMNodeInserted", function( e ) {
insertCount++;
console.log(insertCount);
}, false);