Skip to content

Instantly share code, notes, and snippets.

@porterjamesj
porterjamesj / static_arrays_are_contiguous.c
Created October 28, 2013 22:20
demonstration that static arrays are allocated as contiguous blocks of memory
#include <stdio.h>
int main (int argc, char ** argv) {
int A[10][10];
A[3][3] = 10;
printf("i am ten: %d\n", *(((int*) A)+33));
}
@porterjamesj
porterjamesj / josh-nav.el
Created November 12, 2013 09:02
love you josh <3
(defun josh/navigate (p s)
(interactive "P\nsWhere to my prince? :")
(let* ((move (if p #'next-line #'previous-line))
(char-to-pos (lambda (c) (- c 96)))
(nums (string-to-list s))
(first (car nums))
(count (apply '+ (mapcar (lambda (c) (if (equalp first c) 1 0)) nums))))
;; (ignore-errors
(progn
(funcall move (+ (funcall char-to-pos first) (* 26 (- count 1))))
@porterjamesj
porterjamesj / dict_subset.py
Created November 14, 2013 07:33
cute python function to tell if one dict is a subset of another that took me way too long to write
def dict_subset(d1, d2):
"""Return true if d2 is contained within d1."""
if type(d1) is not dict or type(d2) is not dict:
return False
res = []
for key, val in d2.items():
if key in d1.keys():
if type(val) is dict:
res.append(dict_subset(d1[key], val))
elif val != d1[key]:
@porterjamesj
porterjamesj / build_fail.txt
Created November 16, 2013 01:22
julia 10.9 build faliure
LINK usr/lib/libjulia.dylib
Undefined symbols for architecture x86_64:
"llvm::TargetRegistry::lookupTarget(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&)", referenced from:
_jl_dump_function_asm in codegen.o
"std::string::find_last_not_of(char, unsigned long) const", referenced from:
llvm::SMDiagnostic::print(char const*, llvm::raw_ostream&, bool) const in libLLVMSupport.a(SourceMgr.o)
"std::string::copy(char*, unsigned long, unsigned long) const", referenced from:
llvm::sys::Path::makeUnique(bool, std::string*) in libLLVMSupport.a(Path.o)
"std::string::find(char const*, unsigned long, unsigned long) const", referenced from:
llvm::TernOpInit::Fold(llvm::Record*, llvm::MultiClass*) const in libLLVMTableGen.a(Record.o)
@porterjamesj
porterjamesj / newick.jl
Last active December 29, 2015 12:39
silly hack to parse newick strings
type PhyloNode
label::String
children::Vector{PhyloNode}
length::Real
end
function parsenewick(newick::String)
newick = rstrip(newick,';')
newick = replace(newick,":","+")
newick_expr = parse(newick)
@porterjamesj
porterjamesj / _.jl
Last active December 31, 2015 07:19
some sort of threading macro
function replace_(rep,expr::Expr)
i = findfirst(x->x==:_,expr.args)
if i == 0
# recurse on subexprs one at a time
# subexprs = expr.args[]
error("dun goofed")
else
return Expr(expr.head,
[expr.args[1:i-1]
rep
@porterjamesj
porterjamesj / cufflinks.log
Created December 30, 2013 19:23
cufflinks warnings
@porterjamesj
porterjamesj / maui_license.txt
Last active January 3, 2016 22:29
wierdo license for maui
Maui Scheduler General Public License
This product includes software developed for The University of New Mexico High Performance Computing Education and Research Center for use in the Maui Scheduler software. Copyright (C) 2000 Science and Technology Corporation @ UNM, Software developed for The University of New Mexico. All Rights Reserved.
Maui Scheduler is a trademark of Science & Technology Corporation @ UNM
THE SOFTWARE IS PROVIDED AS IS AND SCIENCE & TECHNOLOGY CORPORATION @ UNM (STC) AND THE UNIVERSITY OF NEW MEXICO (UNM) DISCLAIM ALL WARRANTIES RELATING TO THE SOFTWARE, WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. NEITHER UNM,
STC, NOR ANYONE INVOLVED IN THE CREATION, PRODUCTION, OR DELIVERY OF THE SOFTWARE SHALL BE LIABLE FOR ANY INDIRECT, CONSEQUENTIAL, OR INCIDENTAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE EVEN IF UNM OR STC HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES OR
@porterjamesj
porterjamesj / .emacs.min
Created February 6, 2014 01:07
the minimal configuration I need to be able to use emacs effectively
(setq inhibit-startup-message t)
(global-set-key (kbd "M-n") 'forward-paragraph)
(global-set-key (kbd "M-p") 'backward-paragraph)
(setq backup-inhibited t)
(setq auto-save-default nil)
(setq create-lockfiles nil)
(defalias 'yes-or-no-p 'y-or-n-p)
@porterjamesj
porterjamesj / packets.txt
Last active August 29, 2015 13:56
debug all day
[2014-02-27 16:02:13] DEBUG lt-chitcpd <<< New state: CLOSING
[2014-02-27 16:02:13] DEBUG lt-chitcpd <<< Finished handling event PACKET_ARRIVAL on state FIN_WAIT_1
[2014-02-27 16:02:13] DEBUG lt-chitcpd >>> Handling event PACKET_ARRIVAL on state CLOSING
[2014-02-27 16:02:13] DEBUG lt-chitcpd <<< New state: CLOSING
[2014-02-27 16:02:13] DEBUG lt-chitcpd >>> TCP data BEFORE handling:
[2014-02-27 16:02:13] DEBUG lt-chitcpd ······················································
[2014-02-27 16:02:13] DEBUG lt-chitcpd CLOSING
[2014-02-27 16:02:13] DEBUG lt-chitcpd
[2014-02-27 16:02:13] DEBUG lt-chitcpd ISS: 3949 IRS: 3949
[2014-02-27 16:02:13] DEBUG lt-chitcpd SND.UNA: 3950