Skip to content

Instantly share code, notes, and snippets.

View ucarion's full-sized avatar
🌁
I just love enterprise software, man

Ulysse Carion ucarion

🌁
I just love enterprise software, man
View GitHub Profile
@ucarion
ucarion / JOptionPane.java
Last active December 14, 2015 12:38
JOptionPane hackery
public class JOptionPane {
/**
* input is essentially the same array as args
*/
private static String[] input;
/**
* ctr is the index of the value we want from args
* it starts at 0 and is incremented every time showInputDialog is called
*/
@ucarion
ucarion / Matrix.java
Created April 10, 2013 05:44
Java OpenGL matrix utility class ... write once, copypaste everwhere.
public class Matrix {
public static float[] toMatrix(
float m00, float m01, float m02, float m03,
float m10, float m11, float m12, float m13,
float m20, float m21, float m22, float m23,
float m30, float m31, float m32, float m33) {
float[] f = {
m00, m10, m20, m30,
m01, m11, m21, m31,
@ucarion
ucarion / Looper.java
Created July 2, 2013 18:36
loop through atoms in PDB entry
package com.ulyssecarion.pdb.distances.precalculations;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.biojava.bio.structure.Atom;
import org.biojava.bio.structure.Calc;
import org.biojava.bio.structure.Chain;
import org.biojava.bio.structure.Group;
@ucarion
ucarion / nowplus.rb
Created July 2, 2013 18:59
Figure out when things will finish.
#!/usr/bin/env ruby
puts "Usage: nowplus [seconds].\nDefaulting to Time.now:" unless ARGV[0]
puts Time.now + ARGV[0].to_i
@ucarion
ucarion / cal-admissions-bugfix.js
Last active December 19, 2015 10:39
Fix mouseenter / mouseexit bug
function itemOut(event) {
var to = event.relatedTarget;
var from = event.currentTarget;
// Get the first parent of from and to that match the selector ".isotope-item";
// if parents() returns undefined, then simply return from / to.
var parentFrom = $(from).parents(".isotope-item")[0] || from;
var parentTo = $(to).parents(".isotope-item")[0] || to;
// if the two elements are part of the same .isotope-item, then do not do any animation (this avoids shutter effects).
@ucarion
ucarion / foo.mrv
Last active December 20, 2015 02:28
.MRV file
<?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule title="alkyl" molID="m1">
<propertyList>
<property dictRef="rotation.unit" title="rotation.unit">
<scalar>15</scalar>
</property>
<property dictRef="abbreviation" title="abbreviation">
@ucarion
ucarion / dirmagic.sh
Created August 6, 2013 23:11
Count number of files in each subdirectory from '.'
for dir in */
do
find ./$dir -type f | wc -l
done
@ucarion
ucarion / DistanceQuerySearchTool.java
Last active December 21, 2015 02:19
How the project works
package org.pdb.query.simple.distance;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import org.apache.commons.io.FileUtils;
import org.biojava.bio.structure.Element;
@ucarion
ucarion / bash_docker.rb
Created August 22, 2013 03:30
Call Docker image through bash
require 'docker'
require 'shellwords'
image = Docker::Image.all.first
s = IO.read('tmp.rb').shellescape
cmd = [ "/bin/bash", "-c", "echo #{s} > roobee.rb; ruby roobee.rb" ]
puts "Response from Docker: "
@ucarion
ucarion / benchmark.rb
Created January 26, 2014 07:47
Performance of array-averaging in Ruby vs. C
require 'benchmark'
require 'extension_cord'
def average_reduce(arr)
arr.reduce(:+).to_f / arr.size
end
def average_upto(arr)
sum = 0