Skip to content

Instantly share code, notes, and snippets.

View natanfelles's full-sized avatar
๐Ÿ’ฅ
Hunting bugs!

Natan Felles natanfelles

๐Ÿ’ฅ
Hunting bugs!
View GitHub Profile
@natanfelles
natanfelles / vagrant-cheat-sheet.md
Created December 2, 2018 11:36 — forked from wpscholar/vagrant-cheat-sheet.md
Vagrant Cheat Sheet

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Creating a VM

  • vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
  • vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
@natanfelles
natanfelles / tt2srt.php
Created September 19, 2018 11:29
YouTube Subtitles - XML to SRT
<?php
$argv = [
'',
'filename.xml'
];
if(empty($argv[1])) {
exit('Argument one must contain the TimedText file.');
}
@natanfelles
natanfelles / uri.js
Created July 19, 2018 22:44 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@natanfelles
natanfelles / gist:3caa3bb840fad19850091fac58e82aa9
Created July 7, 2018 02:08 — forked from branneman/gist:951847
array_find() - A case insensitive array_search() with partial matches
<?php
/**
* Case in-sensitive array_search() with partial matches
*
* @param string $needle The string to search for.
* @param array $haystack The array to search in.
*
* @author Bran van der Meer <[email protected]>
* @since 29-01-2010
*/
@natanfelles
natanfelles / session-life-cycle.md
Created June 11, 2018 15:29 — forked from mindplay-dk/session-life-cycle.md
Complete overview of the PHP SessionHandler life-cycle

This page provides a full overview of PHP's SessionHandler life-cycle - this was generated by a set of test-scripts, in order to provide an exact overview of when and what you can expect will be called in your custom SessionHandler implementation.

Each example is a separate script being run by a client with cookies enabled.

To the left, you can see the function being called in your script, and to the right, you can see the resulting calls being made to a custom session-handler registed using session_set_save_handler().

@natanfelles
natanfelles / php speed up tips.html
Created May 26, 2018 14:30 — forked from bsalim/php speed up tips.html
63 Tips for speeding up PHP
<html>
<body>
<p>Here are Webberโ€™s points:</p>
<ul>
<li>If a method can be static, declare it static. Speed improvement is by a factor of 4.</li>
<li>echo is faster than print.(<em>* compare with list from phplens by John Lim</em>)</li>
<li>Use echoโ€™s multiple parameters instead of string concatenation.</li>
<li>Set the maxvalue for your for-loops before and not in the loop.</li>
<li>Unset your variables to free memory, especially large arrays.</li>
<li>Avoid magic like __get, __set, __autoload</li>
@natanfelles
natanfelles / csv-to-json.php
Created March 22, 2018 04:54 — forked from robflaherty/csv-to-json.php
Convert CSV to JSON
<?php
/*
* Converts CSV to JSON
* Example uses Google Spreadsheet CSV feed
* csvToArray function I think I found on php.net
*/
header('Content-type: application/json');
// Set your CSV feed
@natanfelles
natanfelles / how-to.md
Created January 11, 2018 22:36
PHP Dev Env
sudo apt-get install apt-transport-https lsb-release ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
sudo sh -c 'echo "deb https://packages.sury.org/php/ stretch main" > /etc/apt/sources.list.d/php.list'
sudo apt update
sudo apt upgrade
sudo apt install php5.6-fpm php7.0-fpm php7.1-fpm php7.2-fpm

git clone https://github.com/xdebug/xdebug.git
@natanfelles
natanfelles / Install-xdebug-php7.1.md
Created January 11, 2018 20:59 — forked from asanikovich/Install-xdebug-php7.1.md
Installing xdebug for php7.1 on Ubuntu 14.04

Install xdebug extension

# Download stable release of xdebug from https://xdebug.org/download.php
wget -c "https://xdebug.org/files/xdebug-2.5.3.tgz"
# Extract archive
tar -xf xdebug-2.5.3.tgz

cd xdebug-2.5.3/
@natanfelles
natanfelles / gist:c5e157672f63f66a13940f1842f9c51c
Created December 14, 2017 05:21 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: ๐Ÿ˜„ :smile: ๐Ÿ˜† :laughing:
๐Ÿ˜Š :blush: ๐Ÿ˜ƒ :smiley: โ˜บ๏ธ :relaxed:
๐Ÿ˜ :smirk: ๐Ÿ˜ :heart_eyes: ๐Ÿ˜˜ :kissing_heart:
๐Ÿ˜š :kissing_closed_eyes: ๐Ÿ˜ณ :flushed: ๐Ÿ˜Œ :relieved:
๐Ÿ˜† :satisfied: ๐Ÿ˜ :grin: ๐Ÿ˜‰ :wink:
๐Ÿ˜œ :stuck_out_tongue_winking_eye: ๐Ÿ˜ :stuck_out_tongue_closed_eyes: ๐Ÿ˜€ :grinning:
๐Ÿ˜— :kissing: ๐Ÿ˜™ :kissing_smiling_eyes: ๐Ÿ˜› :stuck_out_tongue: