Skip to content

Instantly share code, notes, and snippets.

@jrochkind
jrochkind / gist:2161449
Created March 22, 2012 18:40
A Capistrano Rails Guide

A Capistrano Rails Guide

by Jonathan Rochkind, http://bibwild.wordpress.com

why cap?

Capistrano automates pushing out a new version of your application to a deployment location.

I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".

@edsu
edsu / gist:3353380
Created August 14, 2012 21:58
top RDF classes used in million most widely held books in Worldcat http://www.oclc.org/us/en/news/releases/2012/201252.htm
ed@taylor:~$ zcat WorldCatMostHighlyHeld-2012-05-15.nt.gz | rdfsum
5834638 <http://schema.org/Intangible>
3164779 <http://schema.org/Place>
2422712 <http://schema.org/CreativeWork/Manifestation>
2422712 <http://purl.org/library/Manifestation>
1570772 <http://schema.org/Organization>
1121498 <http://schema.org/Book>
980152 <http://schema.org/Person>
398778 <http://schema.org/Event>
101060 <http://schema.org/CreativeWork>
PREFIX core: <http://purl.uniprot.org/core/>
SELECT *
WHERE {
?protein rdf:type core:Protein .
?protein core:annotation ?functionAnn .
?functionAnn a core:Function_Annotation .
}
@cshirky
cshirky / itp_debugging.md
Created November 12, 2012 19:27
A Brief Guide to Debugging

A BRIEF INTRODUCTION TO DEBUGGING

“As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right 
as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that 
a large part of my life from then on was going to be spent in finding mistakes in my own programs.”
— Maurice Wilkes, 1949

This is a guide to debugging your projects at ITP and beyond. It is not a guide to specific techniques for debugging Processing sketches or physical computing projects; it is a guide to the basic ideas and goals of debugging.

anonymous
anonymous / LinearRegression.java
Created January 31, 2013 13:38
import org.apache.commons.math3.stat.regression.OLSMultipleLinearRegression;
public class LinearRegression {
public static void main(String[] args) {
double [] y = {-0.48812477, 0.33458213,
-0.52754476, -0.79863471,
-0.68544309, -0.12970239,
0.02355622, -0.31890850,
0.34725819, 0.08108851};
double [][] x = {{1,0}, {0,0},
{1,0}, {2,1},
@wacko
wacko / gist:5577187
Last active July 13, 2024 00:48
SSH between Mac OS X host and Virtual Box guest

On Mac OS (host):

Shutdown your VM and do:

VirtualBox > Settings > Network > Add (you will get vboxnet0)

On a terminal ifconfig will show you new interface vboxnet0

VM's Settings > System > check "Enable I/O APIC." VM's Settings > Network > Adapter 2 > host-only vboxnet0

Overview

In general, it seems there are roughly five (5) ways to get "file data" (e.g. a GeoTIFF) out of a PostGIS geoprocessing workflow:

  • Export just the raster field as an ASCII grid
  • Connect to the database using a desktop client (e.g. QGIS) [1]
  • Use a procedural language (like PLPGSQL or PLPYthon) [2]
  • Use the COPY declaration to get a hex dump out and convert it to a binary file
  • Fill a 2D NumPy array with a byte array and serialize it to a binary file using GDAL or psycopg2 [3, 4]
  • Use ST_AsTiff() or the more general ST_AsGDALRaster() to get a byte array, which can be written to a binary file
@pepperbob
pepperbob / rdfbean-2-#56
Last active December 26, 2015 17:29
"Streaming approach": RDFHandler for Rio will flush the cached STMTs if a (currently hard coded) limit is reached.
diff --git a/rdfbean-virtuoso/pom.xml b/rdfbean-virtuoso/pom.xml
index b410b7d..5ad612e 100644
--- a/rdfbean-virtuoso/pom.xml
+++ b/rdfbean-virtuoso/pom.xml
@@ -23,6 +23,11 @@
<artifactId>rdfbean-core</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>com.mysema.rdf</groupId>
@raphw
raphw / UnsafeTest.java
Last active January 9, 2025 12:20
A demonstration of sun.misc.Unsafe
import org.junit.Before;
import org.junit.Test;
import sun.misc.Unsafe;
import sun.reflect.ReflectionFactory;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import static org.junit.Assert.assertEquals;
@aslakknutsen
aslakknutsen / start_testing_java8_today.asciidoc
Last active October 2, 2024 15:10
Example of how to use both JDK 7 and JDK 8 in one build.

JDK 8 Released

Most of us won’t be able to use/deploy JDK 8 in production for a looong time. But that shouldn’t stop us from using it, right?

It should be possible to sneak in JDK 8 in the back way, the same way we snuck in Groovy and other libraries we wanted to use.

The Test Suite to the rescue

The Maven compiler plugin run in two separate lifecycles, compile and testCompile. Those can be configured separately.