Skip to content

Instantly share code, notes, and snippets.

View rupak's full-sized avatar

Rupak Das rupak

  • Germany
View GitHub Profile
@rupak
rupak / taskkiller.go
Created May 4, 2017 14:42
Kills all processes with a given name in Windows
package main
import (
"bytes"
"fmt"
"log"
"os"
"os/exec"
"strconv"
"strings"
@rupak
rupak / DataLoader.java
Created September 11, 2012 14:16
HTTP Utility class for sending a POST request.
package com.jsi.http;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
@rupak
rupak / BGDemo.java
Created August 3, 2012 14:51
Background Demo
Bitmap bmBg = Bitmap.getBitmapResource("background.png");
Background bg = BackgroundFactory.createBitmapBackground(bmBg, Background.POSITION_X_LEFT, Background.POSITION_Y_TOP, Background.REPEAT_SCALE_TO_FIT);
VerticalFieldManager myVfm = new VerticalFieldManager(USE_ALL_WIDTH | USE_ALL_HEIGHT | VERTICAL_SCROLL);
myVfm.setBackground(bg);
@rupak
rupak / gist:2944865
Created June 17, 2012 15:35
BlackBerry - format a decimal number with specified precision.
Formatter myFormatter = new Formatter();
double piOld = 3.14159265;
int decimals = 4;
double piFormatted = Double.parseDouble(myFormatter.formatNumber(piOld, decimals));
System.out.println(piOld + " " + piFormatted);
// Output
@rupak
rupak / MyApp.java
Created May 23, 2012 11:59
BlackBerry Simple Splash Screen Implementation
package mypackage;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
public class MyApp extends UiApplication {
@rupak
rupak / BinarySearchTree.java
Created May 18, 2012 18:39
Simple Binary Search Tree, Insertion implemented only.
import java.util.Random;
public class BinarySearchTreeDemo {
public static void main(String args[]) {
Random r = new Random();
int numOfElements = 5;
// Construct tree
BinarySearchTree tree = new BinarySearchTree();
for (int i = 0; i < numOfElements; i++) {
@rupak
rupak / BaseConverter.java
Created May 18, 2012 08:50
Converts a decimal number to other bases.
public class NumberConversionDemo {
public static void main(String[] args) {
BaseConverter baseConverter = new BaseConverter();
int targetBase = BaseConverter.HEXADECIMAL;
String convertedNumber;
for (int i = -100; i < 100; i++) {
convertedNumber = baseConverter.convert(i, targetBase);
System.out.println(i + "(10) = " + convertedNumber + "(targetBase)");
}
}