Skip to content

Instantly share code, notes, and snippets.

View avesus's full-sized avatar
🎯
Focusing

Brian Cannard avesus

🎯
Focusing
View GitHub Profile
push = (element) -> (stack) ->
newStack = [element].concat stack
{value: element, stack: newStack}
pop = (stack) ->
element = stack[0]
newStack = stack.slice 1
{value: element, stack: newStack}
bind = (stackOperation, continuation) -> (stack) ->
@avesus
avesus / pyproto.py
Last active August 29, 2015 14:08 — forked from foxbunny/pyproto.py
""" https://bitbucket.org/brankovukelic/pyproto """
from copy import copy
__all__ = ['Object']
class Object(object):
"""Base prototype for prototypal object model in Python
To create a new object, simply instantiate an Object instance::
float screenResolution() {
struct utsname systemInfo;
uname(&systemInfo);
char *name = systemInfo.machine;
float ppi;
if ((strstr(name, "iPod") != NULL) && (strstr(name, "iPod4") == NULL)) {
// older ipod touches
ppi = 163;
} else if ((strstr(name, "iPhone") != NULL) && (strstr(name, "iPhone3") == NULL)) {
1. The texture target needs to be GLES20.GL_TEXTURE_EXTERNAL_OES instead of GL_TEXTURE_2D, e.g. in the glBindTexture calls and glTexParameteri calls.
2. In the fragment shader define a requirement to use the extension:
#extension GL_OES_EGL_image_external : require
3. For the texture sampler used in the fragment shader, use samplerExternalOES instead of sampler2D.
Everything below here is all in the C code, no more Java.
4. In the C code, use glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, eglImage) to specify where the data is, instead of using glTexImage2D family of functions.
@avesus
avesus / gcd_timer.m
Last active August 29, 2015 14:14 — forked from codeswimmer/gcd_timer.m
dispatch_queue_t gcdTimerQueue;
dispatch_source_t gcdTimer;
gcdTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, gcdTimerQueue);
if (gcdTimer) {
uint64_t seconds = 30ull;
uint64_t interval = seconds * NSEC_PER_SEC;
uint64_t leeway = 1ull * NSEC_PER_SEC;
__block typeof(self) _self = self;
@avesus
avesus / gist:8fd761ed79fc636d490d
Last active August 29, 2015 14:18 — forked from addyosmani/gist:1057989
A-la interface in JS
/**
Code copyright Dustin Diaz and Ross Harmes, Pro JavaScript Design Patterns.
**/
// Constructor.
var Interface = function (name, methods) {
if (arguments.length != 2) {
throw new Error("Interface constructor called with " + arguments.length + "arguments, but expected exactly 2.");
}
this.name = name;
From ae279bfe194b1b17a6dc18e0720e61d253414154 Mon Sep 17 00:00:00 2001
From: "Daniel St. Jules" <[email protected]>
Date: Thu, 8 May 2014 18:59:20 -0400
Subject: [PATCH] Replace faye-websocket-node with ws
---
package.json | 4 ++--
src/trans-websocket.coffee | 15 +++++++--------
2 files changed, 9 insertions(+), 10 deletions(-)
// You would use this object as follows:
var xhr = XHRFactory.getInstance();
var url = "http://www.xyz.com/someresource/....";
// do the operation
xhr.open("GET", url, true);
xhr.onreadystatechange = function() {
if (xhr.readyState==4) {
// if "OK"
if (xhr.status==200) {
@avesus
avesus / bloop.js
Last active August 29, 2015 14:25 — forked from jlongster/bloop.js
bloop
(function() {
// Do not use this library. This is just a fun example to prove a
// point.
var Bloop = window.Bloop = {};
var mountId = 0;
function newMountId() {
return mountId++;
}
@avesus
avesus / postgres_slave_promote.md
Last active August 29, 2015 14:25 — forked from bartek/postgres_slave_promote.md
What to do when promoting a postgresql slave to master

This example is based on having a cascading setup, where you have a single master, a single "primary" slave, and cascading slaves which are being replicated from the primary slave. For an example of this setup, check out http://bartek.im/blog/2012/12/04/postgresql-92-streaming-primer.html

On the existing master, if accessible, stop postgres.

$ sudo service postgresql stop

And better to be safe than sorry. We can't have two masters running. (I only use this in an automated script. If you're doing this manually, you'd know if it was shutoff)

$ kill -9 `sudo cat /var/lib/postgresql/9.2/main/postmaster.pid | head -n 1` &> /dev/null