Skip to content

Instantly share code, notes, and snippets.

View francisnnumbi's full-sized avatar
😀
Learn and share

Francis Nduba Numbi francisnnumbi

😀
Learn and share
View GitHub Profile
@francisnnumbi
francisnnumbi / SaveToFileUsingFormatter.txt
Created August 5, 2017 21:34
Did you know that you can save plain text to file using Formatter.class? You need to import java.util package. You'll use format() method for that and specify the format expression to be of type String - "%s".
public void saveText(File file, String content){
try{
Formatter out = new Formatter(file);
out.format("%s", content);
out.close();
}catch(IOException ioe){}
}
@francisnnumbi
francisnnumbi / SimplePromptDialog.java
Created September 9, 2017 11:16
Implementing a simple prompt dialog with internal listener. How to use it: SimplePromptDialog.from(this) .showPrompt("test title", "", new SimplePromptDialog.OnDismissListener(){ @OverRide public void onDismiss(String message) { if(message != null) { // use the message } } });
import android.app.Activity;
import android.support.v7.app.AlertDialog;
import android.content.DialogInterface;
import android.widget.EditText;
import android.app.*;
import android.content.*;
public class SimplePromptDialog {
private static Activity activity;
@francisnnumbi
francisnnumbi / MyDateUtils.java
Last active January 8, 2018 11:03
Converting a String date from one displayable format to another.
import java.text.SimpleDateFormat;
import java.util.Date;
import java.text.ParseException;
public class MyDateUtils {
/**
* Convert from one format to another
* @param date the date in string. e.g. "23/10/2014 23:45.50"
* @param currentFormat the actual format of date. e.g. "dd/MM/yyyy HH:mm.ss"
@francisnnumbi
francisnnumbi / Calculation.java
Created November 4, 2017 09:41
stage 1 : trying to solve math expression such as (12+5)(2-5)/(6-3) it is evolving...
import java.util.*;
public class Calculation {
private static final String OPS = "+*/^%";
private static ArrayList<Character> ops = new ArrayList<>();
private static String[] vars;
private static StringBuilder expression;
@francisnnumbi
francisnnumbi / flash-android-rom-with-heimdall-on-mac.md
Created July 10, 2020 11:25 — forked from kevinpapst/flash-android-rom-with-heimdall-on-mac.md
Flash a new Android ROM on Mac with ADB and Heimdall

Installing an Android ROM with your Mac via Heimdall and bash

Because every time I want to flash a new ROM, I forgot how I did it the last time.

This is how I re-flashed my unbranded Samsung Galaxy S4 (german black edition) with a stock ROM (because Cyanogenmod crashed my phone all the time). The correct Stock ROM for my Galaxy S4 is: I9505XXUHOJ2_I9505OXAHOJ2_I9505XXUHOJ2

Software you need

  • adb
  • heimdall (brew cask install heimdall-suite)
@francisnnumbi
francisnnumbi / gist:410ed55635e8ec68a625ad88f3592c9d
Created July 14, 2020 14:20 — forked from djandyr/gist:3c083bd1790aeecd1c9e
XAMPP Automatically start Apache (MacOS)

Automatically start XAMPP Apache when logging into MacOSX.

  1. Create xampp.startapache.plist in /Library/LaunchDaemons with the following content :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">