Skip to content

Instantly share code, notes, and snippets.

View nezda's full-sized avatar
🤠
That’s good now double it again.

Luke Nezda nezda

🤠
That’s good now double it again.
View GitHub Profile
import bisect
class NFA(object):
EPSILON = object()
ANY = object()
def __init__(self, start_state):
self.transitions = {}
self.final_states = set()
self._start_state = start_state
@rednaxelafx
rednaxelafx / Notes
Created May 29, 2011 20:47
Example of HotSpot's PrintCompressedOopsMode's output. It's clear that UseCompressedOops can only be used with heap size < 32GB
The "size" field shows total reserved GC heap size in MB, which includes all generations (including PermGen).
"32-bits Oops" means the shift is zero; otherwise it'd be non-zero.
If UseCompressedOops is false, or if the heap is too big to use compressed oops, then PrintCompressedOopsMode won't print anything. The -Xmx32g example below show that ergonomics didn't set UseCompressedOops to true.
If the heap is too big, HotSpot would print a warning message and set UseCompressedOops to false.
@sorenmacbeth
sorenmacbeth / gist:1340665
Created November 4, 2011 22:32
The rest of our utility functions
(defn tokenizer-seq
"Build a lazy-seq out of a tokenizer with TermAttribute"
[^TokenStream tokenizer ^TermAttribute term-att]
(lazy-seq
(when (.incrementToken tokenizer)
(cons (.term term-att) (tokenizer-seq tokenizer term-att)))))
(defn load-analyzer [^java.util.Set stopwords]
(StandardAnalyzer. Version/LUCENE_CURRENT stopwords))
@simonw
simonw / gist:7000493
Created October 15, 2013 23:53
How to use custom Python JSON serializers and deserializers to automatically roundtrip complex types.
import json, datetime
class RoundTripEncoder(json.JSONEncoder):
DATE_FORMAT = "%Y-%m-%d"
TIME_FORMAT = "%H:%M:%S"
def default(self, obj):
if isinstance(obj, datetime.datetime):
return {
"_type": "datetime",
"value": obj.strftime("%s %s" % (
package test;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Spliterator;
import java.util.function.Consumer;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
{
page(url:"http://www.eventbrite.com/") {
title: text(selector:"title")
cards: query(selector:"div.poster-card") {
name: text(selector:"[itemprop=name]")
url: attr(selector:"meta[itemprop=url]", name:"content")
image_src: attr(selector:".js-poster-image", name:"src")
}
}
}
@reborg
reborg / rich-already-answered-that.md
Last active September 25, 2024 17:06
A curated collection of answers that Rich gave throughout the history of Clojure

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.

How to use:

  • The link in the table of content jumps at the copy of the answer on this page.
  • The link on the answer itself points back at the original post.

Table of Content