Skip to content

Instantly share code, notes, and snippets.

View anta40's full-sized avatar

Andre anta40

  • Jakarta, Indonesia
  • 10:34 (UTC +07:00)
View GitHub Profile
/**
* I use this method to get contents of JSON formatted file that I put into res
* directory to deliver default data for my application.
* Visit my blog at http://web.durianapp.com
*/
public static String getResFileContent(String filename) {
InputStream is = null;
try {
/**
* To use this example, you need to grap my repository on
* https://github.com/amrishodiq/Blackberry-Development-Tutorial/tree/master/TakingPicture/src/com/durianberry/takingpicture
*/
public final class TakingPictureScreen extends MainScreen implements
PictureTakerListener, FieldChangeListener {
private ButtonField button;
private BitmapField photoField;
public TakingPictureScreen() {
public static synchronized String saveToFile(String basePath, byte[] data)
throws IOException {
try {
if (basePath.startsWith("file://")) {
// do nothing
} else if (!basePath.startsWith("/"))
basePath = "file:///" + basePath;
else if (basePath.startsWith("//"))
basePath = "file:/" + basePath;
else
@anta40
anta40 / textcolor.c
Created November 28, 2014 17:29
How to set different color to each alphabet in C
#include <stdio.h>
#include <windows.h>
#define BLACK 0
#define BLUE FOREGROUND_BLUE
#define GREEN FOREGROUND_GREEN
#define CYAN FOREGROUND_GREEN | FOREGROUND_BLUE
#define RED FOREGROUND_RED
#define MAGENTA FOREGROUND_RED | FOREGROUND_BLUE
#define BROWN FOREGROUND_RED | FOREGROUND_GREEN
@anta40
anta40 / passwd.c
Created December 4, 2014 16:00
Password masking
#include <windows.h>
#include <stdio.h>
#define MAX_LEN 100
char getch(void);
int main(void){
char pswd[MAX_LEN];
char ch;
@anta40
anta40 / BitmapUtil.java
Created May 30, 2015 03:23
Load bitmap from a URL on BlackBerry (pre OS 10)
public static Bitmap loadBitmapFromURL(String url){
TransportManager connManager = TransportManager.getInstance();
HttpConnection httpConnection = null;
DataOutputStream httpDataOutput = null;
InputStream httpInput = null;
int rc;
Bitmap bitmp = null;
try {
httpConnection = (HttpConnection) connManager.getConnection(url, Connector.READ_WRITE, true);
@anta40
anta40 / TransportManager.java
Created May 30, 2015 03:24
Transport manager
package com.semymegis.apps.pingmishop.net;
import java.io.IOException;
import java.rmi.ServerException;
import javax.microedition.io.Connection;
import javax.microedition.io.Connector;
import net.rim.device.api.servicebook.ServiceBook;
import net.rim.device.api.servicebook.ServiceRecord;
@anta40
anta40 / MotionDetector.java
Created December 23, 2016 07:38
a simple motion detection using webcam in Java
import com.github.sarxos.webcam.Webcam;
import com.github.sarxos.webcam.WebcamMotionDetector;
import com.github.sarxos.webcam.WebcamMotionEvent;
import com.github.sarxos.webcam.WebcamMotionListener;
import com.leacox.process.FinalizedProcess;
import com.leacox.process.FinalizedProcessBuilder;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
<?php
class Firebase {
// sending push message to single user by firebase reg id
public function send($to, $message) {
$fields = array(
'to' => $to,
//'data' => $message,
<html>
<head>
<title>Curve Test</title>
</head>
<style>
canvas { border: 1px solid red; }
</style>