Skip to content

Instantly share code, notes, and snippets.

Avatar

Abdelhady Muhammad Abdelhady

View GitHub Profile
@Abdelhady
Abdelhady / AppHelper.java
Last active Mar 14, 2020 — forked from anggadarkprince/AppHelper.java
Upload file with Multipart Request Volley Android - Supporting UTF-8 Encoding
View AppHelper.java
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import java.io.ByteArrayOutputStream;
/**
* Sketch Project Studio
* Created by Angga on 12/04/2016 14.27.
*/
public class AppHelper {
@Abdelhady
Abdelhady / TusController.php
Created Nov 17, 2018
Tus implementation - Final version
View TusController.php
<?php
class TusController {
public function indexAction() {
// Disable views/layout the way suites your framework
$server = $this->_getTusServer();
$response = $server->serve();
$this->_fixNonSecureLocationHeader($response);
$response->send();
@Abdelhady
Abdelhady / TusController.php
Last active Nov 17, 2018
Initial Tus implementation
View TusController.php
<?php
class TusController {
public function indexAction() {
// Disable views/layout the way suites your framework
$server = new TusPhp\Tus\Server(); // Using File Cache (over Redis) for simpler setup
$server->setApiPath('/tus/index') // tus server endpoint.
->setUploadDir('/tmp'); // uploads dir.
$response = $server->serve();
@Abdelhady
Abdelhady / FileController.php
Last active Nov 16, 2018
Traditional way of uploading files
View FileController.php
<?php
class FileController {
public function postAction() {
// Disable views/layout the way suites your framework
if (!isset($_FILES['imageFile'])) {
// Throw an exception or handle it your way
}
// Nginx already did all the work for us, & received the file in the `/tmp` folder
$uploadedFile = $_FILES['imageFile'];
$OriginalFileName = $uploadedFile['name'];
@Abdelhady
Abdelhady / EmailCampaignParameters.php
Last active Jan 29, 2017
Use this utility function to append GA's campaign (or any other parameters with a small modification) to all links in your email at once, in an efficient way which uses `DOMDocument::loadHTML` instead of using custom regex.
View EmailCampaignParameters.php
<?php
/**
* appending campaign parameters to every single link `<a href=''></a>`
* in the given $bodyHtml
*
* @param type $bodyHtml
*/
public function appendCampaignPrameters($bodyHtml, $utmCampaign) {
$newParams = [
@Abdelhady
Abdelhady / DeviceOrientation
Last active Sep 18, 2020
A utility class to help get current device orientation, you will need it if you decided to fix the activity's orientation in the manifest :)
View DeviceOrientation
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.media.ExifInterface;
/**
* Created by abdelhady on 9/23/14.
*
* to use this class do the following 3 steps in your activity:
You can’t perform that action at this time.