Skip to content

Instantly share code, notes, and snippets.

View larryv's full-sized avatar

Lawrence Velázquez larryv

View GitHub Profile
@larryv
larryv / ads-cft.txt
Last active December 31, 2015 04:59
The AdS/CFT correspondence for political scientists
In a vastly oversimplified nutshell:
String theories are theoretical physics frameworks in which particles
have one dimension ("strings") instead of zero-dimensions ("points").
The different particles we observe arise from these strings being in
different quantum states. In order to be consistent with quantum
mechanics, string theories require the existence of higher dimensions,
beyond the classical 3 spatial and 1 temporal dimensions. (The original
bosonic string theory postulated 26 dimensions; superstring theories use
10; M-theory, the new hotness, has 11.)
@larryv
larryv / diet.data
Created September 11, 2013 20:54
The diet problem in GNU MathProg.
set Foods := Rice Quinoa Tortilla Lentils Broccoli;
set NutrientTypes := Carbs Proteins Fat;
param Nutrients:
Carbs Proteins Fat :=
Rice 53 4.4 0.4
Quinoa 40 8 3.6
Tortilla 12 3 2
Lentils 53 12 0.9
Broccoli 6 1.9 0.3
function s:CalculateChecksum(file, hash)
let [f, h] = [shellescape(a:file), shellescape(a:hash)]
let cmd = printf('openssl dgst -%s %s', h, f)
return matchstr(system(cmd), '\X\zs\x\+\ze\n$')
endfunction
function s:ChecksumDistfile(name, path, urls, hashes)
let tmp = tempname()
if filereadable(a:path)
call system(printf('ln -s %s %s', shellescape(a:path), tmp))
else
[08:18:44] <irker657> larryv at macports dot org * https://trac.macports.org/changeset/102473 /trunk/dports/devel/pcre/ (files/configure.diff files Portfile):
[08:18:44] <irker657> pcre: Avoid unnecessary -pthread flag (#37916).
[08:21:37] *** yue has quit IRC
[08:27:53] <egallager_> larryv: could that patchfile be conditionally applied, only if configure.compiler == clang? iirc the original issue said it was only a clang issue...
[08:31:38] <larryv> as far as i can tell, -pthread is unnecessary across the board
[08:31:49] <larryv> libSystem provides it
[08:32:26] <larryv> to be sure, i tested with apple-gcc42 and gcc47, and neither complained
[08:32:36] *** JaRoel|4d has quit IRC
[08:32:41] <egallager_> ok, fair enough
[08:33:47] <larryv> and even if they did need it, the configure script would figure that out eventually. just after a couple more failed attempts than before
@larryv
larryv / gist:4694727
Created February 1, 2013 22:50
that's not right
[23:21:55] *** LordDeath has joined #macports
[23:22:04] <LordDeath> hi, is macports 2.1.3 out?
[23:22:19] <neverpanic> yes
[23:22:28] <LordDeath> I can't install it :-S
[23:22:31] <neverpanic> Raim: jmr_mp: can one of you fix the topic?
[23:22:42] <neverpanic> LordDeath: any error message?
[23:25:54] <LordDeath> http://pastebin.com/0mgBYNJH
[23:27:04] <larryv> can you run "port -d selfupdate" instead
[23:27:16] <LordDeath> as root?
[23:27:30] <larryv> as whatever you were doing before
Index: src/port1.0/portconfigure.tcl
===================================================================
--- src/port1.0/portconfigure.tcl (revision 102270)
+++ src/port1.0/portconfigure.tcl (working copy)
@@ -170,11 +170,44 @@
default configure.universal_cxxflags {[portconfigure::configure_get_universal_cflags]}
default configure.universal_ldflags {[portconfigure::configure_get_universal_ldflags]}
+# Internal function to set port dependencies for configure.compiler.
+# Defined up here so that it is available when setting the default value.
unsigned int count_inversions(unsigned int *ary, size_t len)
{
if (len <= 1) {
printf("base: %u\n", ary[0]);
return 0;
}
size_t i;
size_t l_len = len / 2;
#!/usr/bin/env ruby1.9
def merge_sort(a)
return a if a.length <= 1
l = (merge_sort(a[0...(a.length / 2)]) << Float::INFINITY).each
r = (merge_sort(a[(a.length / 2)...a.length]) << Float::INFINITY).each
Array.new(a.length) {|i| l.peek < r.peek ? l.next : r.next}
end
@larryv
larryv / ex5-1.cc
Created May 16, 2012 21:47
Convoluted C++ declarations
/*
"The C++ Programming Language", Special Edition
Chapter 5, "Pointers, Arrays, and Structures"
Exercise 1
"Write declarations for the following: a pointer to a character, an
array of 10 integers, a reference to an array of 10 integers, a
pointer to an array of character strings, a pointer to a pointer to
a character, a constant integer, a pointer to a constant integer,
and a constant pointer to an integer. Initialize each one."
@larryv
larryv / ex5.cc
Created May 12, 2012 04:49
Chapter 4, Exercise 5 from Stroustrup's "The C++ Programming Language"
/*
"The C++ Programming Language", Special Edition
Chapter 4, "Types and Declarations"
Exercise 5
"What, on your system, are the largest and the smallest values of the
following types: char, short, int, long, float, double, long double, and
unsigned."
12 May 2012