Skip to content

Instantly share code, notes, and snippets.

View terabyte's full-sized avatar

Carl Myers terabyte

View GitHub Profile
// BrockA: could we please get this under a BSD or Apache 2.0, or some other compatible license? We'd like to include it in https://github.com/palantir/stash-disapproval-plugin which is apache 2.0.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
@terabyte
terabyte / event_test.rb
Created December 21, 2012 22:06
how do you test something raises an error while also testing activerecord object classes?
require 'test_helper'
class EventTest < ActiveSupport::TestCase
test "event requires a username and a timestamp" do
e1 = Event.new
e1.id = 1
e1.username = nil
e1.timestamp = Time.now
e1.description = "some description"
@terabyte
terabyte / 2013-01-04-using-gist-to-blog.md
Last active December 10, 2015 15:38
Using Gist to blog

Using Gist to Blog

Seems like gists are a great way to quickly publish easily-browseable blog entries using git, which is pretty much the easiest tool for me. Furthermore, github's markdown language is particularly well-suited for blogs which will contain lots of code snippets.

Like this:

    require 'foo'
    puts "Hello, #{World}!"
 exit 0
@terabyte
terabyte / HTTPSTest.java
Created January 8, 2013 01:07
Messing with Java SSL I Created keystore using this command: $ keytool -genkeypair -alias newkey -keystore someKeyStore ==== Keystore looks like this: $ keytool -list -keystore someKeyStore Enter keystore password: Keystore type: JKS Keystore provider: SUN Your keystore contains 1 entry newkey, Jan 7, 2013, PrivateKeyEntry, Certificate fingerpri…
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Writer;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import org.apache.commons.lang.StringUtils;
@terabyte
terabyte / commit graph
Last active December 11, 2015 07:48
Looking at GRD
* e772530b0e89d92d419714c541990439b06ef67a Carl Myers Fri Jan 18 12:37:28 2013 -0800 (HEAD, master)master rolls onward some more
* 97fae5b12018fb5f207c8bf0df92b3e2c08ed237 Carl Myers Fri Jan 18 12:37:14 2013 -0800 master rolls onward
| * 3e5dbc6c10e3fc355106aed1fc1e4cb7206471e7 Carl Myers Fri Jan 18 12:36:52 2013 -0800 (topic2)topic 2
| | * 7a28a91e3b7c99d5705f25c9b4ec2465ae991900 Carl Myers Fri Jan 18 12:36:29 2013 -0800 (topic1)topic commit 1
| |/
| * e3dd2331263e215e5c3bf9839b5c6e860b4ffc3e Carl Myers Fri Jan 18 12:36:09 2013 -0800 (dev)dev commit 2
| * 014c281df82dc0b808442350e9199d28626c9096 Carl Myers Fri Jan 18 12:35:53 2013 -0800 dev commit 1
|/
* e98060f3e0893454c625c1b28844bfc8e2d7c009 Carl Myers Tue Jan 8 10:52:33 2013 -0800 (v6-cmyers-verified)Exmaple chagne
| * dbf294965832f56e72e26b1a37e477fb05b8dfdd Carl Myers Tue Jan 8 10:52:33 2013 -0800 (origin/master, origin/HEAD)Exmaple chagne
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
@terabyte
terabyte / toy_threads.rb
Created March 12, 2013 21:30
If you comment out the Thread.pass in this example, under Ruby 1.9.2 at least, the producer runs forever and the consumers never run (or at least don't run until the producer is completely done). WTF?
#!/usr/bin/env ruby
require 'thread'
work = Queue.new
producer = Thread.new do
(1..10000).each do |i|
work << i
sleep 0.1
puts "P: #{Thread.current.inspect}"
@terabyte
terabyte / gist:5408087
Last active December 16, 2015 08:48
gradle ivy config?
//apply plugin: 'java'
defaultTasks 'buildit'
repositories {
ivy {
url "http://ivy.example.com/modules"
layout "pattern", {
ivy "modules/[organisation]/[module]/[revision]/ivy-[revision].xml"
artifact "modules/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"
import java.util.ArrayList;
class A {
interface Function<B, C> {
C apply(B input);
}
private <B,C> Iterable<C> transform(Iterable<B> iterable, Function<? super B, ? extends C> transform) {
// impl not relevant for bug
@terabyte
terabyte / gist:e839124b853465571085
Created March 6, 2016 01:30
minecraft FTB infinity fail
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f7d493e9bfd, pid=16453, tid=140175065540352
#
# JRE version: Java(TM) SE Runtime Environment (8.0_60-b13) (build 1.8.0_60-ea-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.60-b12 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# J 39323 C2 net.minecraft.world.chunk.Chunk.func_76588_a(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/AxisAlignedBB;Ljava/util/List;Lnet/minecraft/command/IEntitySelector;)V (250 bytes) @ 0x00007f7d493e9bfd [0x00007f7d493e9a60+0x19d]
#