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
/*Classic way*/ // $( document ).ready( handler ) | |
$( document ).ready( function( ) { | |
// do something. | |
} ) | |
/* Short Way */ // $( handler ) | |
$( function( ) { | |
// do something |
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 | |
# This function reads your DATABASE_URL config var and returns a connection | |
# string suitable for pg_connect. Put this in your app. | |
function pg_connection_string_from_database_url() { | |
extract(parse_url($_ENV["DATABASE_URL"])); | |
return "user=$user password=$pass host=$host dbname=" . substr($path, 1); # <- you may want to add sslmode=require there too | |
} | |
# Here we establish the connection. Yes, that's all. | |
$pg_conn = pg_connect(pg_connection_string_from_database_url()); |
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 | |
/* | |
Checks if something is set and not empty | |
Pass the variable as a reference to truly check its | |
legitness. | |
*/ | |
function _islegit(&$variable = null) | |
{ | |
if($variable) { |
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 | |
// App/controllers/components/rest_request.php | |
// shamelessly lifted from: http://www.gen-x-design.com/archives/making-restful-requests-in-php/ | |
// slightly modified | |
class RestRequestComponent extends Object | |
{ | |
var $components = array('Session'); | |
protected $url; | |
protected $verb; |
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
import Realm | |
class ModelName: RLMObject { | |
dynamic name: String = "" | |
dynamic value: Int = 0 | |
} |
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
// | |
// UIBorderedLabel.swift | |
// standToMake | |
// | |
// Created by Karl Oscar Weber on 9/13/14. | |
// Copyright (c) 2014 Karl Oscar Weber. All rights reserved. | |
// | |
// Thanks to: http://userflex.wordpress.com/2012/04/05/uilabel-custom-insets/ | |
import UIKit |
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 | |
$view = new View($this, false); | |
$view->set(compact('some', 'vars')); | |
$html = $view->render('view_name'); |
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
.my-link { | |
text-decoration: underline; | |
} |
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
const sketcher = require('canvas-sketch-tool'); // not yet public | |
// Import geometry & utilities | |
const createRegl = require('regl'); | |
const createPrimitive = require('primitive-icosphere'); | |
const createCamera = require('perspective-camera'); | |
const glslify = require('glslify'); | |
const hexRgb = require('hex-rgb'); | |
// Utility to convert hex string to [ r, g, b] floats |
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
// This will open up a prompt for text to send to a console session on digital ocean | |
// Useful for long passwords | |
(function () { | |
var t = prompt("Enter text to be sent to console, (This wont send the enter keystroke)").split(""); | |
function f() { | |
var character = t.shift(); | |
var i=[]; | |
var code = character.charCodeAt(); | |
var needs_shift = "!@#$%^&*()_+{}:\"<>?~|".indexOf(character) !== -1 |