Skip to content

Instantly share code, notes, and snippets.

View YavorK's full-sized avatar
🥥

Yavor Kirov YavorK

🥥
View GitHub Profile
@YavorK
YavorK / service-workers.md
Created October 3, 2018 14:52 — forked from Rich-Harris/service-workers.md
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@YavorK
YavorK / fun math.js
Last active June 1, 2023 17:27
how to get chained methods (builder pattern :3 ) in ES6
class math {
constructor() {
this.current = 0;
}
add(number) {
this.current += number;
return this;
}
@YavorK
YavorK / helpers.php
Created December 9, 2016 16:38
Helpers file from a "random" Laravel project
<?php
use Illuminate\Support\Facades\Route;
function path_to_user_profile_image($filename)
{
if ($filename != '') {
return url('img/children/' . $filename);
}
return url('img/default_child.png');
@YavorK
YavorK / lf_settings.php
Created December 6, 2016 14:22
Example module for prestashop 1.6 with config page
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
class Lf_settings extends Module
{
private $settings = [
'lf_settings_support_email' => 'support@email.com',
'lf_settings_support_phone_1' => '+33 333 33333333',
@YavorK
YavorK / DateService.php
Last active November 30, 2016 14:45
DateService.php
<?php
class DateService
{
/**
* Return number of day in the week in an European manner,
* 0 is Monday, 6 is Sunday
* @param $unixTimestamp integer
* @return integer
@YavorK
YavorK / generateNames.php
Last active October 19, 2016 04:46
Generate names with faker (fzaninotto/faker)
<?php
// this script uses https://github.com/fzaninotto/Faker
// to generate male/female names:
require 'vendor/autoload.php';
// use the factory to create a Faker\Generator instance
$faker = Faker\Factory::create();
// generate data by accessing properties
$maleNames = [];
@YavorK
YavorK / names.php
Last active October 19, 2016 04:43
A list of female names and a list of male names as a php array
<?php
//to generate: https://gist.github.com/YavorK/f91780cd29a290fd7b9846f97ab8cf17
$maleNames = array (
0 => 'Jamey Bogan',
1 => 'Dr. Afton Crona V',
2 => 'Ronaldo Bahringer PhD',
3 => 'Dr. Korbin Feeney I',
4 => 'Jamil Beer',
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Remote Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify the default connection that will be used for SSH
@YavorK
YavorK / import-remote-db-with-laravel.php
Last active September 16, 2021 23:21
Import Remote DB with Laravel.
<?php
//import db from original server to local one...
/**
* Instructions:
* 1. Install this package: https://laravelcollective.com/docs/5.3/ssh
* 2. Add those to your .env file and fill up the values:
ORIGINAL_SERVER_SSH_ADDRESS=
ORIGINAL_SERVER_SSH_USERNAME=
<?php
Artisan::command('db:port-original', function () {
//Laravel Remote is AWESOEM // https://laravelcollective.com/docs/5.3/ssh#sftp-downloads ...
//make sure process does not get killed
set_time_limit(0);
//define some values
$archiveName = env('ORIGINAL_SERVER_DB_DUMP_ARCHIVE_NAME');