Skip to content

Instantly share code, notes, and snippets.

View avesus's full-sized avatar
🎯
Focusing

Brian Cannard avesus

🎯
Focusing
View GitHub Profile
@avesus
avesus / gist:7d66e837c1cf52c68f49
Created September 26, 2014 11:52
Yii migration cache disable
public function up()
{
$this->addColumn('post', 'alias', 'varchar(255) NOT NULL');
Yii::app()->cache->flush();
Yii::app()->db->schema->getTables();
Yii::app()->db->schema->refresh();
foreach (Post::model()->findAll() as $post) {
$post->save();
(def a ["qwe",
"asd"
"zxc",
"rty"])
(def b ["qwe"
"asd",
"zxc"
"rty"])
@avesus
avesus / gist:394fea04b34471fdf23d
Last active October 28, 2023 23:24
Unix style
program > file # write program stdout to file
program1 | program2 # send stdout of program1 to stdin of program2
program < file # write file to program stdin
program1 && program2 # exec program2 only if program1 returns 0
program1; program2 # exec program2 ever if program1 failed
cmd1; cmd2; cmd3 & - will only execute cmd3 in the background
cmd1 && cmd2 && cmd3 & - will execute the entire chain in the background IF there are no errors.
To cater for unconditional execution, using parenthesis solves this :
XTerm*Background: #3465A4
XTerm*Foreground: #EEEEEC
XTerm*font: 7x13
XTerm*faceName: Terminus:size=10:antialias=false
XTerm*saveLines: 16000
XTerm*HiForeColor: #EEEEEC
XTerm*HiBackColor: #3465A4
XTerm*geometry: +35+120
!tango color scheme
xterm*faceName: Terminus:size=10:antialias=false
xterm*font: 7x13
xterm*inputMethod:ibus
xterm*termName: xterm-256color
xterm*utf8: 1
xterm*locale: true
xterm*utf8Title: true
xterm*renderFont: true
!tango color scheme
# PLEASE READ THE MAN PAGE BEFORE EDITING THIS FILE!
# http://opensource.conformal.com/cgi-bin/man-cgi?spectrwm
# colors for focussed and unfocussed window borders
# NOTE: all colors in this file are in hex! see XQueryColor for examples
# color_focus = red
# color_unfocus = rgb:88/88/88
# bar settings
bar_enabled = 1
How to convert a CVImageBufferRef to an OpenGL texture
outputImageProviderFromTextureWithPixelFormat:pixelsWide:pixelsHigh:name:flipped:releaseCallback:releaseContext:colorSpace:shouldColorMatch
CVImageBufferRef imageBuffer = CVBufferRetain(mCurrentImageBuffer);
GLuint texture = CVOpenGLTextureGetName(imageBuffer);
id provider= [context outputImageProviderFromTextureWithPixelFormat:QCPlugInPixelFormatARGB8
pixelsWide:CVPixelBufferGetWidth(imageBuffer)
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)) {