Skip to content

Instantly share code, notes, and snippets.

Avatar

Zahid Rasheed ZahidRasheed

View GitHub Profile
View StringUtils.kt
import android.graphics.Color
import android.annotation.SuppressLint
import android.content.Context
import org.json.JSONArray
import org.json.JSONException
import org.json.JSONObject
import java.security.MessageDigest
import java.util.regex.Pattern
val String.creditCardFormatted: String
View styles.xml
//apply using: android:theme="@style/MyCheckboxTheme"
<style name="MyCheckboxTheme" parent="Theme.AppCompat">
<item name="colorAccent">#FFF</item> // Checked color
<item name="android:textColorSecondary">#FFF</item> // Checkbox border color
</style>
View measureTime.kt
inline fun <T> measureTimeMillis(loggingFunction: (Long) -> Unit,
function: () -> T): T {
val startTime = System.currentTimeMillis()
val result: T = function.invoke()
loggingFunction.invoke(System.currentTimeMillis() - startTime)
return result
}
@ZahidRasheed
ZahidRasheed / fish_config.md
Last active Mar 20, 2019
Fish Shell Android Home (Mac OS)
View fish_config.md

1- Create required config files

$ touch ~/.config/fish/config.fish; nano ~/.config/fish/config.fish

Now copy below:

set --export ANDROID_HOME $ANDROID/sdk;
set -gx PATH $ANDROID_HOME/tools $PATH;
set -gx PATH $ANDROID_HOME/tools/bin $PATH;
@ZahidRasheed
ZahidRasheed / how_to_gen_ssl_cert.md
Created Sep 21, 2017 — forked from iansheridan/how_to_gen_ssl_cert.md
How to generate an SSL CSR or self signed SSL certificate
View how_to_gen_ssl_cert.md

How to generate an SSL CSR or self signed SSL certificate

Overview

The following is an extremely simplified view of how SSL is implemented and what part the certificate plays in the entire process.

Normal web traffic is sent unencrypted over the Internet. That is, anyone with access to the right tools can snoop all of that traffic. Obviously, this can lead to problems, especially where security and privacy is necessary, such as in credit card data and bank transactions. The Secure Socket Layer is used to encrypt the data stream between the web server and the web client (the browser).

SSL makes use of what is known as asymmetric cryptography, commonly referred to as public key cryptography (PKI). With public key cryptography, two keys are created, one public, one private. Anything encrypted with either key can only be decrypted with its corresponding key. Thus if a message or data stream were encrypted with the server's private key, it can be decrypted only using its corresponding public key, ensuring

@ZahidRasheed
ZahidRasheed / pre-push
Created Jul 20, 2017
A git pre-push hook to make sure there are no lint errors before pushing code to the remote.
View pre-push
#!/bin/sh
echo "executing post-push hook to make sure lint is not failing the build"
# run the tests with the gradle wrapper
./gradlew lintProductionRelease
# store the last exit code in a variable
RESULT=$?
# return the './gradlew test' exit code
@ZahidRasheed
ZahidRasheed / fix-cpanel-permission.sh
Created May 9, 2017
Fix broken permission for ubuntu php project
View fix-cpanel-permission.sh
cd /home
find /home/*/public_html -type f -name '*.php' | xargs chmod 0644 --
find /home/*/public_html -type d | xargs chmod 0755 --
@ZahidRasheed
ZahidRasheed / TrustedInstallation.java
Created Feb 10, 2017
Find if the app is installed from a trusted source
View TrustedInstallation.java
public static boolean isTrustedInstallation(Application app) {
PackageManager packageManager = app.getPackageManager();
String installerId = packageManager.getInstallerPackageName(app.getPackageName());
if (installerId == null) {
return false;
} else if (installerId.contains("aptoide")) {
return false;
} else if (installerId.contains("xiaomi")) {
return false;
View merge.php
<?php
//Set Variables:
$background = "bg.jpg"; //Background chose by user
$logo = "logo.png"; //This logo will always remain same
$userLogo = "20.png"; //Logo created by user.
$savePath = "/output/"; //Where to Save?
$showNotSave = true;
//No need to change anything below....
$bgImage = imagecreatefromjpeg($background);
@ZahidRasheed
ZahidRasheed / error.java
Created Dec 15, 2016
Retrofit Error Response
View error.java
Response response = Response.error(HttpURLConnection.HTTP_INTERNAL_ERROR, ResponseBody.create(MediaType.parse("application/json"),"Internal Server Error"));
You can’t perform that action at this time.