Skip to content

Instantly share code, notes, and snippets.

View rjsvaljean's full-sized avatar
❤️

Ratan Sebastian rjsvaljean

❤️
View GitHub Profile
#!/usr/bin/env ruby
#
require 'rubygems'
require 'net/ssh'
require 'net/ssh/proxy/http'
local_host = "localhost"
local_port = "5444"
username = "test"
require 'rubygems'
require 'ffi-ncurses'
require 'twitter'
require 'yaml'
require 'singleton'
module WorkingTitle
class AuthStore
include Singleton
@rjsvaljean
rjsvaljean / game_of_life.rb
Created August 1, 2010 04:21
Submission for RPCFN #11
class Board < Array
attr_reader :height, :width
attr_accessor :occupied
# The convention is (row, col)
def initialize(width, height, occupied = [])
@height, @width = height, width
@occupied = occupied
board= []
@rjsvaljean
rjsvaljean / so.hs
Last active December 19, 2015 16:39
so alerter
{-# LANGUAGE OverloadedStrings #-}
import Network.URI
import Network.HTTP
import Network.Curl
import Control.Monad.Maybe
import Control.Applicative
import Control.Monad.Trans
import Text.CSV
import Data.Time.Clock.POSIX
@rjsvaljean
rjsvaljean / GOption
Last active August 29, 2015 14:24
GOption - obfuscate
sealed trait MyOption[+A] {
def map[B](f: A => B): MyOption[B] = this match {
case MySome(a) => MySome(f(a))
case MyNone => MyNone
}
def flatMap[B](f: A => MyOption[B]): MyOption[B] = this match {
case MySome(a) => f(a)
case MyNone => MyNone
}
@rjsvaljean
rjsvaljean / TypedPipelineComposition.scala
Last active February 8, 2016 19:44
Implicit context passing between stages of a pipeline with shapeless
package com.xdotai
import shapeless._
import shapeless.ops.hlist.{Prepend, Align, Remove}
object TypedPipelineComposition {
import ShapelessExt._
#!/bin/sh
killSBT() {
SBT_PID=$(jps | grep sbt-launch | awk '{print $1}')
if [ -z "$SBT_PID" ]
then
echo SBT session not found
else
echo Killing SBT: $SBT_PID && kill -9 $SBT_PID
fi
#!/bin/sh
# Requires `jq`
searchLogs() {
USER=$2
PASSWORD=$3
ORG=$4
MSG_ID="$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$1")"
RSID=$(curl -s -u $USER:$PASSWORD "https://$ORG.loggly.com/apiv2/search?q=$MSG_ID&from=-9h&until=now&size=30" | jq -r '.rsid.id' 2>/dev/null)
sleep 5
#!/bin/sh
# Requires `jq`
searchEC2 () {
aws ec2 describe-instances |
jq ".Reservations [].Instances[0] |
select(contains({Tags: [{Value: \"$1\", Key: \"Name\"}], State: {Name: \"running\"}}))"
}
#!/bin/sh
getOrElse() {
if [ -z "$1" ]
then echo $2
else
echo $1
fi
}