var gcloud = require('gcloud');
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
/** | |
* Privileged methods. | |
* | |
* From http://www.crockford.com/javascript/private.html | |
*/ | |
function Container(param) { | |
function dec() { | |
if (secret > 0) { | |
secret -= 1; | |
return true; |
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
void checkShaderForErrors(GLuint shaderID) { | |
// check shader for errors | |
glGetShaderiv(shaderID, GL_COMPILE_STATUS, &compile_status); | |
glGetShaderiv(shaderID, GL_INFO_LOG_LENGTH, &logLength); | |
logMsg = new GLchar[logLength + 1]; | |
glGetShaderInfoLog(shaderID, logLength, NULL, logMsg); | |
if (compile_status != GL_TRUE) { |
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
var gaObj = window['GoogleAnalyticsObject']; | |
window[gaObj](function(tracker) { | |
return tracker.get('clientId'); | |
}); |
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
#!/bin/bash | |
# Homebrew | |
brew update | |
brew upgrade | |
brew cleanup | |
brew doctor | |
# Ohmyzsh | |
upgrade_oh_my_zsh |
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
function googlesort(a, b) { | |
var order = ['1', 'S', 'Galaxy', 'Q', '7', '4', '10', '5', '6']; | |
return order.indexOf(a) > order.indexOf(b); | |
} | |
console.log(['10', '6', '5', '4'].sort(googlesort)); | |
// [ '4', '10', '5', '6' ] |
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
function Graph() { | |
this.nodes = []; | |
this.edges = []; | |
}; | |
Graph.prototype.addNode = function(node) { | |
if(node) { | |
this.nodes.push(node); | |
} | |
}; |
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
"use strict"; | |
var util = require("util"), | |
_ = require("underscore"), | |
events = require("events"), | |
request = require("request"), | |
AppAuthClient = require("../google/AppAuthClient"); //thin wrapper around the google oauth2client - simply initializing it with app's client id and secret | |
var SimpleAuthTransporter= (function () { |
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 | |
$db = new mysqli("localhost", "root", "password", "courses"); | |
$sql = "INSERT INTO prerequisites VALUES('elec2501', 'phys1004', 'math1005', '')"; | |
$db->query($sql); | |
echo "done"; | |
$sql2 = "SELECT * FROM prerequisites"; | |
$rows = $db->query($sql2); | |
while($row = $rows->fetch_object()) { |
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 | |
// file_put_contents("file1.txt", "this is a message", FILE_APPEND | LOCK_EX); | |
$fp = fopen("file1.txt", "w+"); | |
/* open the file */ | |
if (flock($fp, LOCK_EX | LOCK_NB)) { | |
fwrite($fp, "another message"); | |
sleep(3); // sleep for 3 seconds | |
flock($fp, LOCK_UN); // unlock |