Skip to content

Instantly share code, notes, and snippets.

View HussainDerry's full-sized avatar

Hussain Al-Derry HussainDerry

View GitHub Profile
@HussainDerry
HussainDerry / update-postman.sh
Created June 3, 2018 07:58 — forked from Jekis/update-postman.sh
Download and install the latest version of Postman for Ubuntu. Create .desktop file.
#!/bin/bash
INSTALL_DIR=/opt/postman
if [ "$(whoami)" != "root" ]
then
echo "Sorry, you are not root. Use sudo!"
exit 1
fi
@HussainDerry
HussainDerry / PasswordDialog.java
Last active November 6, 2017 11:20 — forked from drguildo/PasswordDialog
JavaFX password dialog.
import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.scene.control.ButtonBar.ButtonData;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.PasswordField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
public class PasswordDialog extends Dialog<String> {
@HussainDerry
HussainDerry / ImageCompressionUtils.java
Last active December 22, 2022 09:19
Helper methods to compress images before storage
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import javax.imageio.stream.ImageOutputStream;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@HussainDerry
HussainDerry / CloneUtils.java
Last active July 10, 2017 12:36
Helper method to deep clone serializable objects
import java.io.*;
/**
* Contains helper method to deep clone serializable objects
* @author Hussain Al-Derry <hussain.derry@gmail.com>
* @version 1.0
*/
public class CloneUtils {
/**
@HussainDerry
HussainDerry / ConcurrentCache.java
Created May 18, 2017 09:10
Cache implementation with a periodic memory clean up process
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
* Cache implementation with a periodic memory clean up process.
* @author Hussain Al-Derry <hussain.derry@gmail.com>
* @version 1.0
*/
public class ConcurrentCache<K, V> {
@HussainDerry
HussainDerry / LuhnChecker.java
Last active April 4, 2017 09:22
Helper class to check the validity of card numbers using the Luhn algorithm.
/**
* A helper class to check number validity using the Luhn algorithm.
* @author Hussain Al-Derry <hussain.derry@gmail.com>
*/
public class LuhnChecker {
/**
* Checks number's validity using the last digit as a check digit.
* @param number The number to check
* @return boolean whether the number is valid or not.
@HussainDerry
HussainDerry / API.md
Created January 24, 2016 05:56 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@HussainDerry
HussainDerry / VolleyMultipartRequest.java
Last active November 20, 2019 15:45
Multipart request for Google's Volley using Square's OkHttp.
import com.android.volley.AuthFailureError;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.NetworkResponse;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.RetryPolicy;
import com.android.volley.VolleyLog;
import com.android.volley.toolbox.HttpHeaderParser;
import com.squareup.okhttp.Headers;