Skip to content

Instantly share code, notes, and snippets.

View JoshRosen's full-sized avatar

Josh Rosen JoshRosen

View GitHub Profile
pygmentize -S native -f html -a .syntax > syntax.css
diff --git a/hydeengine/siteinfo.py b/hydeengine/siteinfo.py
index 24018dc..9aff833 100644
--- a/hydeengine/siteinfo.py
+++ b/hydeengine/siteinfo.py
@@ -363,12 +363,12 @@ class ContentNode(SiteNode):
@property
def target_folder(self):
deploy_folder = self.site.target_folder
- return deploy_folder.child_folder_with_fragment(self.url)
+ return deploy_folder.child_folder_with_fragment(self.fragment)
@JoshRosen
JoshRosen / pygments.css
Created August 11, 2010 22:55
Test of Hyde Syntax Highlighting for PHP
.highlight .hll { background-color: #404040 }
.highlight { background: #202020; color: #d0d0d0 }
.highlight .c { color: #999999; font-style: italic } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .g { color: #d0d0d0 } /* Generic */
.highlight .k { color: #6ab825; font-weight: bold } /* Keyword */
.highlight .l { color: #d0d0d0 } /* Literal */
.highlight .n { color: #d0d0d0 } /* Name */
.highlight .o { color: #d0d0d0 } /* Operator */
.highlight .x { color: #d0d0d0 } /* Other */
@JoshRosen
JoshRosen / JavaTest.java
Created July 9, 2012 22:21
Scala NoSuchMethodError when using traits from Java
public class JavaTest {
public static void main(String[] args) {
MyClass<Integer> x = new MyClass<Integer>();
x.hello();
x.myVal();
}
}
@JoshRosen
JoshRosen / JavaTypeParamNamespace.java
Created July 11, 2012 01:45
Do Scala type parameter names matter?
public class JavaTypeParamNamespace {
public static void main(String[] args) {
// This should compile:
new MyClassRenamedTypes<Integer>().map(1, new MyArgument<String>("String"));
// This fails with the error
// JavaTypeParamNamespace.java:8: <U>map(U,MyArgument<U>) in MyClass<java.lang.Integer> cannot be applied to (int,MyArgument<java.lang.String>)
new MyClass<Integer>().map(1, new MyArgument<String>("String"));
}
}
@JoshRosen
JoshRosen / Errors when compiling
Created July 19, 2012 18:09
Wildcard upper type bounds in Scala and Java
JavaTest.java:11: g(java.lang.Class<? extends java.lang.Iterable<?>>) in ScalaTest cannot be applied to (java.lang.Class<java.util.ArrayList>)
ScalaTest.g(ArrayList.class);
^
JavaTest.java:15: <T>f(java.lang.Class<T>) in ScalaTest cannot be applied to (java.lang.Class<java.lang.Object>)
ScalaTest.f(Object.class);
^
JavaTest.java:16: g(java.lang.Class<? extends java.lang.Iterable<?>>) in ScalaTest cannot be applied to (java.lang.Class<java.lang.Object>)
ScalaTest.g(Object.class);
^
JavaTest.java:17: <T>f(java.lang.Class<T>) in JavaTest cannot be applied to (java.lang.Class<java.lang.Object>)
@JoshRosen
JoshRosen / flatten_pickle.py
Created August 18, 2012 03:39
Flattening data structures that contain Pickled objects
"""
Say that we're storing pickled Python objects in a complicated Java data
structure, which might contain nested scala.Tuple2s and java.util.Lists.
We may be able to create a pickled representation of the Java data structure
based on the pickled objects that it contains, allowing the Python consumer to
deserialized the nested object in a single unpickle call.
This file contains a prototype of this idea. It has only been tested with
Pickle protocol version 2.
@JoshRosen
JoshRosen / bulk_depickle.py
Created August 20, 2012 05:44
Bulk de-pickling of Python objects
"""
Given a Python list containing pickled objects, joining the pickles into
a single pickled list and deserializing it can be faster than deserializing
each pickle individually, despite the extra string processing that this
requires.
The performance difference is much more pronounced if pickle is used instead of
cPickle.
NOTE: this code is specific to Pickle protocol 2; I'm not sure if these results
@JoshRosen
JoshRosen / gist:3984822
Created October 31, 2012 04:39
Stacktrace from hanging Shark worker
[root@a-worker-machine ~]# jstack -F 5945
Attaching to process ID 5945, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 20.0-b12
Deadlock Detection:
java.lang.NullPointerException
at sun.jvm.hotspot.oops.InstanceKlass.computeSubtypeOf(InstanceKlass.java:426)
at sun.jvm.hotspot.oops.Klass.isSubtypeOf(Klass.java:137)
@JoshRosen
JoshRosen / gist:4187604
Created December 2, 2012 07:28
spark-ec2 security group deletion
diff --git a/ec2/spark_ec2.py b/ec2/spark_ec2.py
index 2ab11db..b29d0c3 100755
--- a/ec2/spark_ec2.py
+++ b/ec2/spark_ec2.py
@@ -557,18 +557,18 @@ def main():
inst.terminate()
# Delete security groups as well
group_names = [cluster_name + "-master", cluster_name + "-slaves", cluster_name + "-zoo"]
- groups = conn.get_all_security_groups()
+ groups = [g for g in conn.get_all_security_groups() if g.name in group_names]