Skip to content

Instantly share code, notes, and snippets.

View lrq3000's full-sized avatar
🎵

Stephen Karl Larroque lrq3000

🎵
View GitHub Profile
@lrq3000
lrq3000 / getnargs.m
Last active August 29, 2015 14:02
GETNARGS an Octave/MatLab function to use named optional arguments
function argStruct = getnargs(varargin, defaults, restrict_flag)
%GETNARGS Converts name/value pairs to a struct (this allows to process named optional arguments).
%
% ARGSTRUCT = GETNARGS(VARARGIN, DEFAULTS, restrict_flag) converts
% name/value pairs to a struct, with defaults. The function expects an
% even number of arguments in VARARGIN, alternating NAME then VALUE.
% (Each NAME should be a valid variable name and is case sensitive.)
% Also VARARGIN should be a cell, and defaults should be a struct().
% Optionally: you can set restrict_flag to true if you want that only arguments names specified in defaults be allowed. Also, if restrict_flag = 2, arguments that aren't in the defaults will just be ignored.
% After calling this function, you can access your arguments using: argstruct.your_argument_name
@lrq3000
lrq3000 / blaze-webinar-continuum-analytics-2014-10-08-QA.txt
Created October 8, 2014 18:18
blaze-webinar-continuum-analytics-2014-10-08-QA
Q&A Session for Getting Started with Blaze
Session number: 665410874
Date: wednesday 8 october 2014
Starting time: 18:48
________________________________________________________________
Flemming Stark - 19:12
Q: earlier this year blz grew apart from blaze and i don't see it here or anywhere. is blz dead?
@lrq3000
lrq3000 / zip-import.php
Created December 6, 2014 19:12
Quickly coded zip importer in PHP with multiple methods, including one with chunking and auto-reloading for webhosts with agressive limits
<?php // Import a zip file and extract it
$custom_max_time = 10;
$custom_wait_time = 45;
$random_wait_time = 5; // plus or minus this value. Set to 0 or false to disable.
$time_start = time();
$max_time = ini_get("max_execution_time");
$wait_time = 5;
if (!empty($custom_max_time) and $custom_max_time > 0 and $custom_max_time < $max_time) $max_time = $custom_max_time;
@lrq3000
lrq3000 / odf.php
Created July 29, 2012 13:19
ODF with conditionals substitution
<?php
require 'Segment.php';
class OdfException extends Exception
{}
/**
* Templating class for odt file
* You need PHP 5.2 at least
* You need Zip Extension or PclZip library
* Encoding : ISO-8859-1
*
@lrq3000
lrq3000 / gist:5267581
Created March 28, 2013 23:11
Launch an IPython Notebook interface from a python script
#!/usr/bin/env python
# encoding: utf-8
## @package oacs.interactive
# Manage the interactive interface using IPython Notebook
import sys
import IPython.frontend.terminal.ipapp as ipapp
#from IPython.frontend.html.notebook import notebookapp # if you want to just import the notebook, but some commandline switches like --ipython-dir won't work
@lrq3000
lrq3000 / AntNeighbourhoodFunction.py
Created August 6, 2016 12:06 — forked from StuartGordonReid/AntNeighbourhoodFunction.py
Ant Colony Neighbourhood Function
def get_probability(self, d, y, x, n, c):
"""
This gets the probability of drop / pickup for any given Datum, d
:param d: the datum
:param x: the x location of the datum / ant carrying datum
:param y: the y location of the datum / ant carrying datum
:param n: the size of the neighbourhood function
:param c: constant for convergence control
:return: the probability of
"""
import os
import math
import time
import numpy
import pandas
import random
import matplotlib
import numpy.random as nrand
import matplotlib.pylab as plt
from sklearn.preprocessing import normalize
@lrq3000
lrq3000 / PDF-Testing.md
Created February 17, 2017 13:33 — forked from tiarno/PDF-Testing.md
PDF Checking

PDF Testing Gist

These two files, pdf_linkchecker.py and pdf_fontchecker.py are code examples to go along with a blog article: http://reachtim.com/articles/PDF-Testing.html

See the article for details on how to test your PDFs for broken internal and external links and for unembedded fonts.

@lrq3000
lrq3000 / trk2tck.py
Created December 1, 2018 23:55 — forked from MarcCote/trk2tck.py
Script that converts TRK to TCK using https://github.com/MarcCote/nibabel/tree/streamlines_tck
import os
import argparse
import nibabel as nib
def build_argparser():
DESCRIPTION = "Convert tractograms (TRK -> TCK)."
p = argparse.ArgumentParser(description=DESCRIPTION)
p.add_argument('tractograms', metavar='bundle', nargs="+", help='list of tractograms.')
p.add_argument('-f', '--force', action="store_true", help='overwrite existing output files.')
@lrq3000
lrq3000 / win_subprocess.py
Created January 1, 2019 15:04 — forked from vaab/win_subprocess.py
Fixing python 2.7 windows unicode issue with ``subprocess.Popen``.
## issue: https://bugs.python.org/issue19264
import ctypes
import subprocess
import _subprocess
from ctypes import byref, windll, c_char_p, c_wchar_p, c_void_p, \
Structure, sizeof, c_wchar, WinError
from ctypes.wintypes import BYTE, WORD, LPWSTR, BOOL, DWORD, LPVOID, \
HANDLE