Skip to content

Instantly share code, notes, and snippets.

@isaac-ped
isaac-ped / RAMControl.m
Last active February 2, 2016 16:30 — forked from anonymous/cbmex.cpp
function loop(this, hObject, statusCallback, exitCallback)
% Main loop - acquire samples and call analysis functions
% Get handles used below
stimControl = StimControl.getInstance(); % Singleton instance to analyis code
% This starts data zooming through the buffer. Set an onCleanup handler in case of error
% so that data acquisition can be stopped prior to releasing MATLAB memory used by cbmex.
this.setupTrialConfigMemory();
@isaac-ped
isaac-ped / launch.scpt
Created October 24, 2017 21:34
Launch split iTerm windows
on readFile( unixPath )
return (do shell script "cat '" & unixPath & "'")
end
on getSess(sessions_, names, name)
repeat with i from 1 to count of names
repeat with j from 1 to count of (item i of names)
if item j of (item i of names) equals name
return item j of (item i of sessions_)
end if
@isaac-ped
isaac-ped / if_not_disabled.c
Last active February 15, 2018 18:27
Macro fanciness for detecting disabled feature
#include <stdio.h>
#define STRINGIFY(X) "" #X
#define STRINGIFY2(X) STRINGIFY(X)
#define IF_NOT_DISABLED(ID, FN, ...) \
(!strcmp("DISABLE_" #ID, STRINGIFY2(DISABLE_##ID))) ? FN(ID, ##__VA_ARGS__) : 0
enum my_enum {
FOO,
@isaac-ped
isaac-ped / __init__.py
Last active January 4, 2019 18:30
Python decorators that will memoize the results of a computation-heavy function to a pickle file for later use
from .permanent_memoization import memoize_to_file, memoize_to_folder
@isaac-ped
isaac-ped / ring
Created June 16, 2018 15:56
Trigger shell to continuously ring the bell after job completion
#!/bin/bash
while [[ 1 ]]; do
for i in `seq 1 10`; do
echo -e '\a\c'
sleep .1
done
sleep 1;
done
## Example:
import urllib2
from BeautifulSoup import BeautifulSoup
import re
#specify the url you want to query
url = "https://en.wikipedia.org/wiki/List_of_Off_the_Air_episodes"
#Query the website and return the html to the variable 'page'
page = urllib2.urlopen(url)
import itertools
import logging
import re
import random
import curses
import time
import locale
import codecs
import sys
@isaac-ped
isaac-ped / example_crtp.cpp
Created September 28, 2018 18:03
Example of how I'm using CRTP
#include <vector>
#include <string>
#include <iostream>
class BaseCommand {
public:
virtual void execute() = 0;
};
class BaseExecutor {
@isaac-ped
isaac-ped / tsget.py
Created October 5, 2018 19:32
Download streams of .ts files
import re
import argparse
import os
import time
import subprocess
from subprocess import Popen
parser = argparse.ArgumentParser(description='get panopto files')
parser.add_argument('curl', type=str)
parser.add_argument('out', type=str)
int rt_id_routing(struct msu_type *type, struct local_msu *sender,
struct msu_msg *msg, struct msu_endpoint *output) {
struct routing_table *table = get_type_from_route_set(&sender->routes, type->id);
if (table == NULL) {
log_error("No routes available from msu %d to type %s (%d)",
sender->id, type->name, type->id);
return -1;
}
// Line MAX_ENDPOINTS could be replaced by a call to get_n_endpoints()