Skip to content

Instantly share code, notes, and snippets.

@JohnArcher
JohnArcher / handle_file_upload.php
Created September 16, 2019 12:56 — 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,
@JohnArcher
JohnArcher / country-list-german.html
Created October 30, 2015 08:54 — forked from mrcgrtz/country-list-german.html
German country SELECT element in HTML
<select name="country">
<option value="DE" selected>Deutschland</option>
<option value="AT">Österreich</option>
<option value="CH">Schweiz</option>
<optgroup label="A">
<option value="AF">Afghanistan</option>
<option value="EG">Ägypten</option>
<option value="AX">Åland</option>
<option value="AL">Albanien</option>
<option value="DZ">Algerien</option>
@JohnArcher
JohnArcher / funnycaptions.txt
Last active September 17, 2015 10:54
Funny captions of CodeProject's Daily Newsletter
24.03.2015
----------
Stealing data from computers using heat (http://www.codeproject.com/News.aspx?ntag=19837497518395608&_z=8113364)
Eight bits an hour! Game over, man.
13.04.2015
----------
Mysterious radio signals came from microwave oven, not outer space (http://www.codeproject.com/News.aspx?ntag=19837497534085628&_z=8113364)
But what if it's aliens IN the microwave oven?
@JohnArcher
JohnArcher / js-class-template.js
Last active August 29, 2015 14:02
JavaScript-Class-Template with public and private members and functions
function MyClass() {
// private member
var that = this;
// public members
this.publicMember = 'Bazinga';
// private functions
var privateFunction = function() {
};
@JohnArcher
JohnArcher / JS-bit-operations.js
Created April 15, 2014 10:03
How do you set, clear and toggle a single bit in JavaScript?
To get a bit mask:
var mask = 1 << 5; // gets the 6th bit
To test if a bit is set:
if ((n & mask) != 0) {
// bit is set
} else {
// bit is not set
{
"word_separators": "./\\()\"'-:,.;<>~!@#%^&*|+=[]{}`~?"
}
@JohnArcher
JohnArcher / programming_quotes.txt
Created June 12, 2013 08:48
Programming quotes
"One of my most productive days was throwing away 1000 lines of code."
- Ken Thompson
"Measuring programming progress by lines of code is like measuring aircraft building progress by weight."
- Bill Gates
"When debugging, novices insert corrective code; experts remove defective code."
- Richard Pattis
"Good code is its own best documentation. As you’re about to add a comment, ask yourself, ‘How can I improve the code so that this comment isn’t needed?’"
@JohnArcher
JohnArcher / checkElementExistance.js
Created May 22, 2013 08:41
Checks existance of DOM element. - Alternativly you can use http://evilwebdesign.bplaced.net/doesExist/
if ($('#entitytable').length === 0) {
alert("not there");
} else {
alert("there");
}
h1. Sublime Text 2 - Useful Shortcuts (PC)
Loosely ordered with the commands I use most towards the top. Sublime also offer "full documentation":http://www.sublimetext.com/docs/2/.
h2. Editing
| *Ctrl+C* | copy current line (if no selection) |
| *Ctrl+X* | cut current line (if no selection) |
| *Ctrl+⇧+K*| delete line |
| *Ctrl+↩* | insert line after |