Skip to content

Instantly share code, notes, and snippets.

@bjhaid
bjhaid / kata.txt
Created October 7, 2013 03:01
Kata for Monday 07-Oct-2013
Before you start:
Try not to read ahead.
Do one task at a time. The trick is to learn to work incrementally.
Make sure you only test for correct inputs. there is no need to test for invalid inputs for this kata
String Calculator
@bjhaid
bjhaid / gist:6794126
Created October 2, 2013 13:51
can this be shorter
a.to_a.map { |x| x.join(" = ") }.join(", ")
@bjhaid
bjhaid / ema.rb
Last active December 23, 2015 23:19 — forked from askinss/ema.rb
require 'net/telnet'
def get_imsi(array_of_msisdns, &block)
ema = Net::Telnet::new("Host" => "#{HOST}",
"Port" => "#{PORT}",
"Timeout" => 10,
"Prompt" => /Enter command:/)
ema.cmd("LOGIN:#{USERNAME}:#{PASSWORD};")
ema.waitfor(/Enter command:/)
@bjhaid
bjhaid / ported.rb
Last active December 23, 2015 19:39 — forked from askinss/ported.rb
require 'oci8'
f = File.open("/home/bblite/ported/portedmsisdn.txt")
conn = OCI8.new(DB_USER, DB_PASSWORD, DB_SERVER)
conn.autocommit = true
f.each_line do |msisdn|
#I think you would need to validate the MSISDN against a particular regular expression
next unless msisdn.match(/^233\d{9}/)
#replace the port with the SDP server port
`curl 127.0.0.1:8051/blackberry/smsservice?msisdn=#{msisdn.chomp}&msg=deactivate` #you need to deactivate the msisdn on Broker
<!DOCTYPE html>
<html>
<head>
<title>Device Properties Example</title>
<script type="text/javascript" charset="utf-8" src="cordova-1.9.0.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
//
@bjhaid
bjhaid / gist:6643515
Created September 20, 2013 20:35
Method_missing madness
2.0.0-p247 :002 > m "2","a","b"
=> ["2", "a", "b"]
2.0.0-p247 :003 > (m "2","a","b").class
=> Array
2.0.0-p247 :004 > def method_missing m,*args; args.class; end
=> nil
2.0.0-p247 :005 > m "2","a","b"
/Users/bjhaid/.rvm/scripts/irbrc.rb:32:in `initialize': can't convert String to Fixnum (String#to_int gives Class) (TypeError)
import java.util.Scanner;
import java.lang.Integer;
public class Test {
public static void main (String args[]) {
Scanner input = new Scanner(System.in);
while(true) {
Integer myint = readWord(input);
if (myint != 100) break;
System.out.println("Entered word is: " + myint);
}
@bjhaid
bjhaid / tony.rb
Last active December 23, 2015 09:49
def send_message(subject,message,sender,to,password)
msg = <<END_OF_MESSAGE
From: #{sender}
To: #{to}
MIME-Version: 1.0
Content-type: text/html
Subject:#{self.load_config['opco']} #{subject}
#{message}
@bjhaid
bjhaid / install.sh
Created September 17, 2013 12:52
self extrator (cat compressed.tar.gz >> install.sh)
#!/bin/bash
if [[ `whoami` != foo ]]
then echo "Please login as foo user to run this script.... Thanks!"
exit 1
fi
echo ""
echo "######################################################################################################################"
echo " ################Extracting DEPENDENCIES##################"
echo "######################################################################################################################"
echo ""
public class OrdBok {
public static void main (String args[]) {
new OrdBok().run();
}
public void run() {
BinNode testnode = new BinNode("Ken");
System.out.println("Tree root node " + testnode.value);
testnode.addChild(new BinNode("Kfen"));