Skip to content

Instantly share code, notes, and snippets.

View DidahDx's full-sized avatar
:octocat:

Daniel Didah DidahDx

:octocat:
  • Nairobi, Kenya
View GitHub Profile
@aspose-com-gists
aspose-com-gists / disable-write-protection-from-powerpoint-presentation.java
Last active June 19, 2025 19:17
Remove Password Protection from Documents using Java
Presentation pres = new Presentation("write-protected-presentation.pptx");
try {
pres.getProtectionManager().removeWriteProtection();
pres.save("write-protection-removed.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
@keith0591
keith0591 / LargeFileSplit.java
Created October 22, 2022 14:22
Java code to split a large file by size or by into a specified number of files.
import org.apache.commons.io.IOUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
@phortuin
phortuin / postgres.md
Last active August 18, 2025 04:04
Set up postgres + database on MacOS (M1)

Based on this blogpost.

Install with Homebrew:

$ brew install postgresql@14

(The version number 14 needs to be explicitly stated. The @ mark designates a version number is specified. If you need an older version of postgres, use postgresql@13, for example.)

@kannansuresh
kannansuresh / Get Android phone call history.md
Last active December 22, 2025 12:23
Get Android phone call history/log programmatically

Source: AndroidDev

To get call history programmatically first add read contact permission in Manifest file:

<uses-permission android:name="android.permission.READ_CONTACTS" />

Create xml file. Add the below code in xml file:

<Linearlayout android:layout_height="fill_parent"
@jevakallio
jevakallio / readme.md
Last active February 10, 2026 21:13
`adb pull` from app data directory without root access

TL;DR;

com.package.name is your app identifier, and the file path is relative to the app user's home directory, e.g. '/data/user/0/com.package.name.

adb shell run-as com.package.name cp relative/path/file.ext /sdcard
adb pull /sdcard/file.ext

See long explanation below.

@william-reed
william-reed / NavigateSafe.kt
Created May 4, 2020 13:00
prevent “… is unknown to this NavController” caused by double navigation
import android.os.Bundle
import androidx.annotation.IdRes
import androidx.navigation.NavController
import androidx.navigation.NavDirections
import com.busright.watchdog.BuildConfig
import timber.log.Timber
import java.lang.IllegalArgumentException
/**
* This file represents attempts to make my errors in navigation safer.
/**
* Navigates only if this is safely possible; when this Fragment is still the current destination.
*/
fun Fragment.navigateSafe(
@IdRes resId: Int,
args: Bundle? = null,
navOptions: NavOptions? = null,
navigatorExtras: Navigator.Extras? = null
) {
if (mayNavigate()) findNavController().navigate(
@james-muriithi
james-muriithi / send-sms.php
Last active June 9, 2020 08:18
send sms to a number using php (with vaspro api)
<?php
function sendSms($phone, $message){
// required headers
$stkheader = array('Content-Type:application/json','Cache-Control:no-cache');
// url to post the data
$url = 'https://oyaa.co.ke/api/SendSms/';
# initiating curl
$curl = curl_init();
// set curl url
@kuraydev
kuraydev / handle-error-retrofit-android.md
Created December 14, 2019 16:10
How to handle 401 error on RetroFit
// Add other Interceptors
httpClient.addInterceptor(new Interceptor() {
    @Override
    public Response intercept(Interceptor.Chain chain) throws IOException {
        Request original = chain.request();
        Request request = original.newBuilder()
                .header("Authorization", token_type + " " + access_token)
                .method(original.method(), original.body())
 .build();