Skip to content

Instantly share code, notes, and snippets.

@poszlo
poszlo / handle_file_upload.php
Created April 20, 2016 13:02 — forked from ebidel/handle_file_upload.php
Uploading files using xhr.send(FormData) to PHP server
<?php
$fileName = $_FILES['afile']['name'];
$fileType = $_FILES['afile']['type'];
$fileContent = file_get_contents($_FILES['afile']['tmp_name']);
$dataUrl = 'data:' . $fileType . ';base64,' . base64_encode($fileContent);
$json = json_encode(array(
'name' => $fileName,
'type' => $fileType,
'dataUrl' => $dataUrl,
@poszlo
poszlo / EncryptAESWithPHP
Created April 20, 2016 12:38 — forked from krzyzanowskim/EncryptAESWithPHP
How to encrypt data with padding usign AES cipher, complatible with CryptoSwift defaults.
// Marcin Krzyżanwski
// Code for https://github.com/krzyzanowskim/CryptoSwift/issues/20
// PHP
function encrypt($plaintext, $key, $iv) {
$ciphertext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $plaintext, MCRYPT_MODE_CBC, $iv);
return base64_encode($ciphertext);
}
function decrypt($ciphertext_base64, $key, $iv) {
@poszlo
poszlo / tmux.md
Created April 20, 2016 12:08 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@poszlo
poszlo / Send Form (HTML+PHP+Sweet Alert).md
Created October 27, 2015 08:56
Send Form (HTML+PHP+Sweet Alert)