Skip to content

Instantly share code, notes, and snippets.

@cevaris
cevaris / generate_key.sh
Last active May 5, 2024 19:34
Sign and Verify using Python pycrypto
#!/usr/bin/env bash
# Generate RSA private key
openssl genrsa -out private_key.pem 1024
@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 / 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 / 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 / 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 / Dockerfile
Created November 19, 2014 01:36
Dockerfile for installing the latest puppet
FROM ubuntu:12.04
MAINTAINER Adam Cardenas "[email protected]"
# Prepwork
RUN apt-get -y -q update \
&& apt-get -y -q install wget curl
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;
}