Skip to content

Instantly share code, notes, and snippets.

class Y implements Comparable<X> {
int yTest;
@Override
public int compareTo(X o) {
if(this.yTest < o.xTest) return -1;
if(this.yTest > o.xTest) return 1;
return 0;
}
@cevaris
cevaris / Dockerfile
Created November 19, 2014 01:36
Dockerfile for installing the latest puppet
FROM ubuntu:12.04
MAINTAINER Adam Cardenas "cevaris@gmail.com"
# Prepwork
RUN apt-get -y -q update \
&& apt-get -y -q install wget curl
@cevaris
cevaris / gist:2ece1b1fa1d98800c3a5
Created January 29, 2015 22:40
Life saving Boot2Docker Mac OS X commands
# Grab the boot to docker ip address
function docker-ip() {
boot2docker ip 2> /dev/null
}
# SSH into a running container
# docker-ssh <CONTAINER_ID>
function docker-ssh() {
docker-setup
boot2docker ssh '[ -f /var/lib/boot2docker/nsenter ] || docker run --rm -v /var/lib/boot2docker/:/target jpetazzo/nsenter'
@cevaris
cevaris / main.go
Created March 1, 2015 22:17
Golang Pointers
package main
// Run this in playground
// https://play.golang.org/p/k47thicjzn
import "fmt"
type Item struct {
a *Item
b string
@cevaris
cevaris / main.go
Last active January 24, 2018 09:59
Golang function with interface as argument
package main
import "fmt"
// Play
// http://play.golang.org/p/Hs59f-DNXp
func PrintAll(vals interface{}) {
switch v := vals.(type) {
@cevaris
cevaris / struct_as_map_key.go
Last active October 20, 2023 03:18
Golang: Using structs as key for Maps
package main
import "fmt"
type A struct {
a, b int
}
func MapStructValAsKey(){
// Notice: We are using value of `A`, not `*A`
@cevaris
cevaris / generate_key.sh
Last active October 17, 2023 17:42
Sign and Verify using Python pycrypto
#!/usr/bin/env bash
# Generate RSA private key
openssl genrsa -out private_key.pem 1024
@cevaris
cevaris / build.sh
Created March 8, 2015 22:50
Debugging golang in GDB
go build -gcflags '-N'
@cevaris
cevaris / float.go
Created March 9, 2015 14:09
Golang float64 equality esitimation
var EPSILON float64 = 0.00000001
func floatEquals(a, b float64) bool {
if ((a - b) < EPSILON && (b - a) < EPSILON) {
return true
}
return false
}
@cevaris
cevaris / samplf.sh
Created March 11, 2015 14:58
Naive sampling of file for bash/zsh
# Sample file
samplef() {
# set -x
if [ -z "${1}" ]; then
echo 'Error: Missing file path'
echo
echo 'Usage:'
echo 'samplef <FILEPATH> <SAMPLE_SIZE>'
echo
echo 'Optional paramters: <SAMPLE_SIZE>, default is 0.1'