Skip to content

Instantly share code, notes, and snippets.

View lrq3000's full-sized avatar
🎵

Stephen Karl Larroque lrq3000

🎵
View GitHub Profile
@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 / plwatch.sh
Created May 2, 2013 13:05
A simple bash script to watch packets loss using ping on Unix/Linux
#!/bin/bash
# Packets Loss Watch
# Simple SHELL script for Linux and UNIX system monitoring with
# ping command
#
# Copyright (c) 2006 nixCraft project <http://www.cyberciti.biz/fb/>
# Copyleft 2013 Stephen Larroque
# This script is licensed under GNU GPL version 2.0 or above
#
# This script was inspired by a nixCraft script http://www.cyberciti.biz/tips/simple-linux-and-unix-system-monitoring-with-ping-command-and-scripts.html
@lrq3000
lrq3000 / QVMDisas
Last active October 17, 2021 22:10
QVMDisas v0.3 Python version (older than the Go version), author Macpunk
#!/usr/bin/env python
# encoding: utf-8
"""
QVMDisas.py
Created by Macpunk on 2009-09-20.
Updated by GrosBedo on 2010-04-12
Copyright (c) 2009 Dalton M. Cummings. All rights reserved.
CHANGELOG
@lrq3000
lrq3000 / pylistmodules.py
Last active September 17, 2023 19:27
List recursively all imports of modules along with versions done from your Python application. Tested on Python 2.7. No dependencies except standard Python libs.
#!/usr/bin/env python
# encoding: utf-8
# Copyright (C) 2001-2007 Martin Blais. All Rights Reserved
# Copyright (C) 2010 Bear http://code-bear.com/bearlog/
# Copyright (C) 2013 lrq3000
# Excerpt from SnakeFood to recursively list all imports of modules using AST parsing
# Additions to print the versions of each module if available
@lrq3000
lrq3000 / pylistmodules-modulefinder.py
Last active October 17, 2021 22:10
A simple example to list modules imported in your Python script using ModuleFinder (standard Python module).
from modulefinder import ModuleFinder
finder = ModuleFinder()
finder.run_script('yourscript.py')
moduleslist = {}
for name, mod in finder.modules.iteritems():
filename = mod.__file__
if filename is None:
continue
@lrq3000
lrq3000 / neural-network.nlogo
Last active November 17, 2021 01:06
Efficient n-layers neural network implementation in NetLogo, with some useful matrix extended functions in Octave-style (like matrix:slice and matrix:max)
@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;