Skip to content

Instantly share code, notes, and snippets.

View anta40's full-sized avatar

Andre anta40

  • Jakarta, Indonesia
  • 07:27 (UTC +07:00)
View GitHub Profile
public class NotificationUtil {
private static String TAG = NotificationUtil.class.getSimpleName();
private Context mContext;
public NotificationUtil(Context mContext) {
this.mContext = mContext;
}
@anta40
anta40 / MyFirebaseMessagingService.java
Created July 26, 2017 14:51
Firebase messaging service
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = MyFirebaseMessagingService.class.getSimpleName();
private NotificationUtil notificationUtil;
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.e(TAG, "From: " + remoteMessage.getFrom());
<html>
<head>
<title>Curve Test</title>
</head>
<style>
canvas { border: 1px solid red; }
</style>
<?php
class Firebase {
// sending push message to single user by firebase reg id
public function send($to, $message) {
$fields = array(
'to' => $to,
//'data' => $message,
@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;
@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 / 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 / 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 / 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
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