Skip to content

Instantly share code, notes, and snippets.

View pokle's full-sized avatar

Tushar Pokle pokle

View GitHub Profile
@pokle
pokle / RubyStructs.irb
Created November 22, 2009 12:14
How to use Structs in Ruby
% irb
>> struct = Struct.new('Fabulous', :name, :id)
=> Struct::Fabulous
>> struct
=> Struct::Fabulous
>> class Foo < Struct::Fabulous
>> end
=> nil
>> f = Foo.new
=> #<struct Foo name=nil, id=nil>
@pokle
pokle / dusort.pl
Created May 29, 2010 01:53
Sort the output of du -h
#!/usr/bin/perl
#
# Sorts the output of du -h
use strict;
my $multip = {
'G' => 1024*1024*1024,
'M' => 1024*1024,
'K' => 1024,
@pokle
pokle / gist:417962
Created May 29, 2010 02:10
Don't catch this!
try {
x = you.getKnife().getRun().getCut();
} catch (NullPointerException e) {
x = null;
}
@pokle
pokle / twitter-tweets.html
Created September 20, 2012 06:19
How to display your tweets without a plugin
<!DOCTYPE html>
<html>
<head>
<title>Just the latest tweet</title>
</head>
<body>
<script>
// From http://twitter.com/javascripts/blogger.js
function tweettweet(twitters) {
var statusHTML = [];
@pokle
pokle / gist:3759663
Created September 21, 2012 04:02
Single line HTTP server on any *nix based computer
python -m SimpleHTTPServer
@pokle
pokle / summary.sh
Created October 24, 2012 06:41
Work out the mean (average), min, max, median and quartiles of number in a plain text file using R
cat > data.csv <<HERE
4
5
6
7.9
HERE
r --slave -e 'summary(scan(file="data.csv"))'
## Results in:
@pokle
pokle / flake-local-public-key
Created December 13, 2013 13:21
My home mac ssh public key
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAluyWosEaMkwlFy/hmxmCRjKLEiiQTvNRT6zz7wPD7FHssAj4xVEi/yNGdHJeHZbqYtOvEn238OC7qUxYh7MtseRkrbgfPraUs4B51S9+9wNZ8wd7LXfLhhsHl8836FmONt+0LCwu4TeOX+3sW4algXuv2sNKQ7Ki+DGGVReA1V84TTch2beluh5aI6QPJ/WK/HOzD+GzN6zEmvn94AZdx3HaUBw/eqML72Hk9r6E5EV2HChQz4HBLabi3l8ijfk9B6kVpp/bVCiZIIVec6cbI0Utc3wHfmZWFMpD/Shok2PdYHc6Yclj8teg89jA4/cU8dFk1ahyQwZqGdZrXRst5Q== tushar@flake.local
@pokle
pokle / APDM-key
Last active December 31, 2015 14:09
My APDM key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDKzQE/X7FYxaGtZ8QXszU1FYNX+YPs5dFiecN3TN48lsXGu/O+9S3DD/0gT3nHTOH9+/MjHFRu4VRCmNUAgfCZIz4wRWiBcGE06AZEMIfriDeci0CI24q79/JN8sNzFpa8JihbaAKHckAOy1TW4qMOTLfoEbc2c5GJ3JLtc2Yh9hH2thyMXXSqKaGPpscYinLLg4lBD6Ui6sMHN1u7mxnN6X6+4cIhzZuqnhjRL12K72ccwHbQlDeW0kDVrgKWpwl+5ou7BxBMKC/oj+Hg2nq9xk1Vp8dSc4o+VSqrRAja63wYp+80JO2dRL4uWYFwuIdAX92wjWVbTkvVXMPlLAxh poklet@tushmac.local
@pokle
pokle / jenkins-build-flow-external.groovy
Last active April 25, 2017 17:43
How to run an external script from source control in the Jenkins Build Flow plugin DSL
//
// Copy this into your Jenkins Build Flow plugin DSL, and call run_workspace_script() with the name of your checked in script
//
// Based on code at http://jorgemanrubia.net/2009/10/10/evaluating-code-dynamically-in-groovy
//
def run_workspace_script(filename) {
def code = new File(build.workspace.child(filename).toString()).text
def code_as_closure = "{->${code}}"
def closure = evaluate(code_as_closure)
closure.delegate=this
#!/usr/bin/env bash
usermod -aG docker ubuntu
echo 'DOCKER_OPTS="-H tcp://0.0.0.0:4243/"' >> /etc/default/docker