Skip to content

Instantly share code, notes, and snippets.

View iRynoh's full-sized avatar
🎉
Grooving!

Percy Astocaza iRynoh

🎉
Grooving!
View GitHub Profile
@iRynoh
iRynoh / script.php
Created January 3, 2022 13:17
Pandoc .docx to .mdx
<?php
$files = glob("*.docx");
foreach ($files as $file) {
shell_exec('pandoc "'.$file.'" --wrap=none -t gfm-smart -o "'.str_replace('.docx','.md',$file).'"');
}
@iRynoh
iRynoh / LaravelBulkUpdate.php
Created November 26, 2020 16:58 — forked from sentiasa/LaravelBulkUpdate.php
Laravel Bulk/Mass Update
<?php
$vat = 0.20;
$transactions = Transaction::get();
foreach ($transactions->chunk(5000) as $chunk) {
$cases = [];
$ids = [];
$params = [];
<?php
FormAccount::whereIdSource(2)
->whereIdAccount(215)
->addSelect([
'emails_sent_today' => function ($query) {
$query
->select(DB::raw('COUNT(*)'))
->from('emails as outbound')
->where('outbound.id_form_account', DB::raw('form_accounts.id'))
@iRynoh
iRynoh / model.php
Created February 4, 2020 17:02
Trying to get dynamic relationship in Laravel 6
<?php
// InventoryEmail Model
public function firstReply()
{
return $this->belongsTo(InventoryEmail::class, 'first_reply_id', 'id');
}
public function scopeWithFirstReply(EloquentBuilder $query)
@iRynoh
iRynoh / docker.md
Last active September 22, 2019 20:51
Laravel Docker Ubuntu 18.04 File permission - Cannot open log

When working with docker and laravel with linux distros sometimes the web server container cannot write to log files.

To workaround this you will have to do the following:

Inside the container

Find the www-data UID from the container

$ id -u www-data
@iRynoh
iRynoh / npm.md
Last active July 11, 2019 19:03
NPM Global

When npm tries to install to globally, it tries to install it's packages to the sensible location of /usr/local/. When you aren't a super user, this gives the warning checkPermissions Missing write access to /usr/local/lib and error Error: EACCES: permission denied, access '/usr/local/lib' and fails. Other package installers (such as Python's pip) already ship, at least on Ubuntu, with a concept of a user-specific local directory of ~/.local/ to replace the global /usr/local/ to avoid such warnings.

Thus, let's just reuse this existing convention.

Step 1: Configure NPM

npm config set prefix ~/.local
@iRynoh
iRynoh / error.txt
Created May 8, 2019 14:17
Puppeteer errors
Raw puppeteer response : {"error":"net::ERR_TUNNEL_CONNECTION_FAILED at https://www.kijiji.ca/t-login.html"}
Error in puppeteer script : net::ERR_TUNNEL_CONNECTION_FAILED at https://www.kijiji.ca/t-login.html
Header retry #1
Raw puppeteer response : {"error":"net::ERR_TUNNEL_CONNECTION_FAILED at https://www.kijiji.ca/t-login.html"}
Error in puppeteer script : net::ERR_TUNNEL_CONNECTION_FAILED at https://www.kijiji.ca/t-login.html
Header retry #2
Raw puppeteer response : {"error":"net::ERR_TUNNEL_CONNECTION_FAILED at https://www.kijiji.ca/t-login.html"}
Error in puppeteer script : net::ERR_TUNNEL_CONNECTION_FAILED at https://www.kijiji.ca/t-login.html
Header retry #3
Raw puppeteer response : {"error":"net::ERR_TUNNEL_CONNECTION_FAILED at https://www.kijiji.ca/t-login.html"}
@iRynoh
iRynoh / .php_cs
Created May 2, 2019 16:00 — forked from isuzuki/.php_cs
Config for PHP-CS-Fixer ver 2 (based on laravel .php_cs https://github.com/laravel/framework/blob/5.4/.php_cs)
<?php
/**
* Config for PHP-CS-Fixer ver2
*/
$rules = [
'@PSR2' => true,
// addtional rules
@iRynoh
iRynoh / webstorm64.vmoptions
Created April 17, 2019 18:49 — forked from macd2/webstorm64.vmoptions
Jetbrains Custom VM Options Optimized Configuration: Performance tuning parameters for IntelliJ IDEA. Add these params in idea64.exe.vmoptions or idea.exe.vmoptions file in IntelliJ IDEA. If you are using JDK 8.x, please knock off PermSize and MaxPermSize parameters from the tuning configuration.
# custom WebStorm VM options, this configuration also works well for other IDEs like phpstorm, pycharm..etc.
-Xms1024m
-Xmx2048m
-XX:ReservedCodeCacheSize=240m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
@iRynoh
iRynoh / gist:b54ceede254cb2bc9bdfc8570f362f04
Last active April 17, 2019 17:01
GET parameters php command script

Workaround in case of missing php-cgi binary

alias php-cgi="php -r '"'parse_str(implode("&", array_slice($argv, 2)), $_GET); include($argv[1]);'"' --"
php-cgi test1.php foo=123