Skip to content

Instantly share code, notes, and snippets.

@andrewcsmith
andrewcsmith / text_render_dump.txt
Created April 11, 2016 20:40
apitrace dump for gfx-rs/gfx issue #940
0 CGLChoosePixelFormat(attribs = {kCGLPFADoubleBuffer, kCGLPFAClosestPolicy, kCGLPFAColorSize, 32, kCGLPFAAlphaSize, 8, kCGLPFADepthSize, 24, kCGLPFAStencilSize, 8, kCGLPFAOpenGLProfile, kCGLOGLPVersion_GL4_Core, 0}, pix = &0x7ff593d1f1e0, npix = &2) = kCGLNoError
1 CGLRetainPixelFormat(pix = 0x7ff593d1f1e0) = 0x7ff593d1f1e0
2 CGLReleasePixelFormat(pix = 0x7ff593d1f1e0)
3 CGLCreateContext(pix = 0x7ff593d1f1e0, share = NULL, ctx = &0x7ff596850a00) = kCGLNoError
4 CGLRetainContext(ctx = 0x7ff596850a00) = 0x7ff596850a00
5 CGLReleaseContext(ctx = 0x7ff596850a00)
6 CGLGetVirtualScreen(ctx = 0x7ff596850a00, screen = &0) = kCGLNoError
7 CGLDescribePixelFormat(pix = 0x7ff593d1f1e0, pix_num = 0, attrib = kCGLPFAAccelerated, value = &1) = kCGLNoError
8 CGLGetVirtualScreen(ctx = 0x7ff596850a00, screen = &0) = kCGLNoError
9 CGLDescribePixelFormat(pix = 0x7ff593d1f1e0, pix_num = 0, attrib = kCGLPFAColorSize, value = &32) = kCGLNoError
extern crate piston;
extern crate piston_window;
extern crate graphics;
extern crate gfx_graphics;
use piston::input::*;
use piston::window::{Window as Win, AdvancedWindow, WindowSettings};
use piston_window::{PistonWindow as Window};
fn main() {
@andrewcsmith
andrewcsmith / .vimrc
Created December 30, 2014 03:11
Command to send whatever line you're on to the right tmux pane. Great for complicated ipython/pry work.
function! g:SendRight(...) range
if a:0 > 0
let start = a:1
let end = a:1
else
let start = a:firstline
let end = a:lastline
endif
for line in getline(start, end)
@andrewcsmith
andrewcsmith / main.cpp
Last active August 29, 2015 14:06
xgetrf results and proper specs
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <Accelerate/Accelerate.h>
void print_matrix(const int row_count, const int col_count, __CLPK_real* matrix) {
for(int i = 0; i < row_count; i++) {
for(int j = 0; j < col_count; j++) {
printf("% 7.3f", matrix[i*row_count + j]);
@andrewcsmith
andrewcsmith / gist:10342529
Created April 10, 2014 04:27
#rank, :reference assignment
[331] pry(main)> out
=>
{ layers:
[
[0, 1]
[0, 0]
]
[
[1, 0]
@andrewcsmith
andrewcsmith / UnitTest.sc
Last active January 4, 2016 05:19
UnitTest class and usage that I'm working on
UnitTest {
var <assertionCount = 0, <successCount = 0, <failureCount = 0;
test {
arg name, func;
("Testing: " ++ name).postln;
func.value(this);
("Assertions: " ++ assertionCount ++ "\t Successes: " ++ successCount ++ "\t Failures: " ++ failureCount).postln;
}
@andrewcsmith
andrewcsmith / Random Envelope Selection
Created August 18, 2013 17:46
Random envelope selection
(
SynthDef(\cloudin, {
arg freq = 440, env_input = 0;
var signal, envs;
// env_input is the number of the control-rate channel with the env signal
signal = Saw.ar(400 * 1) * In.kr(env_input);
Out.ar(0, signal);
}).add;
)
@andrewcsmith
andrewcsmith / sinatrauthentication.rb
Last active December 20, 2015 04:59
A quick and dirty way to authenticate users in a Sinatra app. Probably not secure.
require 'sinatra'
require 'sinatra/reloader' if development?
require 'digest/md5'
require 'haml'
# enable :sessions
use Rack::Session::Cookie, :key => 'rack.session', :path => '/', :secret => 'change_me'
auth_dir = "./auth"
x = {|gate=1| Out.ar([0,1], EnvGen.ar(Env.asr(0.1, 1, 0.1), gate, doneAction: 2) * Splay.ar({[SinOsc.ar(80, 0, 0.05)] ++ Resonz.ar(WhiteNoise.ar(1), ExpRand(310,330), 0.01)}.dup(20) ++ {SinOsc.ar(ExpRand(200,280), 0, 0.01)}.dup(20) ++ [SinOsc.ar(84, 0, 0.1)] ));}.play;
@andrewcsmith
andrewcsmith / olm search excerpt
Created August 9, 2012 01:08
Search algorithm that slows way, way down after around 40,000 iterations
max_iterations.times do |iter|
begin
# puts "Iteration #{iter}"
# puts "Now #{current_cost} away at #{current_point.to_a}"
print "\rIteration #{iter}: #{current_cost} away at #{current_point.to_a}"
cost = NMath.sqrt(((tuneable_data[true,1,true,true] - goal_vector) ** 2).sum(0))
# If this is the first run-through, keep the interval index the same
if initial_run
interval_index = 0