Skip to content

Instantly share code, notes, and snippets.

@Emp3r
Emp3r / load.js
Created June 4, 2018 13:41
How to dynamically load external javascript code or css styles with JS functions
function loadScript(src) {
return new Promise((resolve, reject) => {
const script = document.createElement("script");
script.type = "text/javascript";
script.onload = resolve;
script.onerror = reject;
script.src = src;
document.getElementsByTagName("head")[0].appendChild(script);
});
}
@Emp3r
Emp3r / compare.js
Created October 18, 2017 08:31
Compare the speed of two functions
var iterations = 1000000;
console.time('Function 1');
for (let i = 0; i < iterations; i++ ){
functionOne();
};
console.timeEnd('Function 1')
console.time('Function 2');
for (let i = 0; i < iterations; i++ ){
@Emp3r
Emp3r / .gitignore
Last active June 14, 2017 08:00
Epic .gitignore, starts with classic Laravel 5 ignores and then adds much more.
/node_modules
/public/storage
/public/hot
/storage/*.key
/vendor
npm-debug.log
Homestead.json
Homestead.yaml
.idea
.env
@Emp3r
Emp3r / Preferences.sublime-settings
Last active June 14, 2017 08:01
My Sublime Text 3 user settings.
{
"default_line_ending": "system",
// "draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"font_size": 13,
"highlight_line": false,
"line_numbers": true,
"line_padding_bottom": 1,
"line_padding_top": 1,
"show_definitions": false,
@Emp3r
Emp3r / bootstrap-basic-form.sublime-snippet
Created March 7, 2017 17:04
Bootstrap form snippets for Sublime Text, prepared for Laravel with "old()" function set in values.
<snippet>
<content><![CDATA[
<form method="${1:POST}" action="${2:/}">
${3:{{ csrf_field() \}\}}
<div class="form-group">
<label for="${4:name}">${5:Name}:</label>
<input type="text" class="form-control" name="${4:name}" id="${4:name}" ${6:required }value="${7:{{ old('${4:name}') \}\}}">
</div>
@Emp3r
Emp3r / laravel-helpers.sublime-completions
Last active March 6, 2017 15:15
Various little Laravel snippets for Sublime Text. I like these unnecessary time savers.
{
"scope": "source.php",
"completions":
[
{ "trigger": "rg", "contents": "Route::get('/$1', '$2Controller@$3');" },
{ "trigger": "rp", "contents": "Route::post('/$1', '$2Controller@$3');" },
{ "trigger": "rd", "contents": "redirect($1)$2" },
{ "trigger": "rq", "contents": "request($1)$2" },
@Emp3r
Emp3r / php-helpers.sublime-completions
Last active March 7, 2017 17:02
Short PHP snippets for Sublime Text. Maybe unnecessary, but they actually save a lot of time.
{
"scope": "source.php",
"completions":
[
{ "trigger": "pu", "contents": "public $1" },
{ "trigger": "pri", "contents": "private $1" },
{ "trigger": "pro", "contents": "protected $1" },
{ "trigger": "rt", "contents": "return $1;" },