Skip to content

Instantly share code, notes, and snippets.

View jpcaparas's full-sized avatar
🐔

Jayps jpcaparas

🐔
View GitHub Profile
version: '3.0'
services:
blackfire:
image: blackfire/blackfire
environment:
BLACKFIRE_SERVER_ID: "bbca40d2-459c-4e5e-a87f-42b8eed72417"
BLACKFIRE_SERVER_TOKEN: "cd660acd7a9a2365e5007e1329191032a8c464bbf018697aaca92e33d793a59f"
BLACKFIRE_CLIENT_ID: "9f37bbd8-cff1-41dd-ae03-84dee0bc753d"
BLACKFIRE_CLIENT_TOKEN: "c9e53296c4d78e92ae093f6fc5f8b11ccda375a8ae29d30d82acaa2d0d30c693"
@jpcaparas
jpcaparas / calltrace.php
Created December 19, 2018 09:07
PHP call trace
<?php
function calltrace() {
$backtrace = debug_backtrace();
$filetrace = array_column($backtrace, 'file');
$linetrace = array_column($backtrace, 'line');
dump(array_map(function($index) use ($filetrace, $linetrace) {
return $filetrace[$index] . ':' . $linetrace[$index];
}, array_keys($filetrace)));
@jpcaparas
jpcaparas / composer.bat
Created April 19, 2019 21:39
Composer PHPStorm WSL
REM This assumes that you have the "composer" binary on your global $PATH
@echo off
set params=%*
bash.exe -c "composer %params%"
@jpcaparas
jpcaparas / vuex-component.spec.js
Created April 29, 2019 04:43
Vuex testing with Chai
import chai, { expect } from 'chai';
import spies from 'chai-spies';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex';
import Actions from '@/components/Actions.vue';
const localVue = createLocalVue();
localVue.use(Vuex);
@jpcaparas
jpcaparas / getopts.sh
Created May 6, 2019 05:45
getopts example
#!/bin/bash
while getopts ":f:b:" o; do
case "${o}" in
f)
foo=${OPTARG}
;;
b)
bar=${OPTARG}
;;
@jpcaparas
jpcaparas / getopts.sh
Created May 7, 2019 21:46
getopts long options
#!/bin/bash
optspec=":-:"
while getopts "${optspec}" optchar; do
case "${optchar}" in
-)
case "${OPTARG}" in
*)
value=${OPTARG#*=}
@jpcaparas
jpcaparas / displaylink-restart.service
Created May 9, 2019 08:58
Restart DisplayLink service after waking up from suspend
@jpcaparas
jpcaparas / sanitize.js
Created May 9, 2019 23:46
JS: Sanitize amount
const sanitizeAmount = amount => {
return amount
.replace(/[^\d.]/g, '') // Remove non-numeric symbols
.replace(/\.(?!\d+$)/g, ''); // Remove excess "." symbols, and leave out the last "."
};
@jpcaparas
jpcaparas / 40-libinput.conf
Created May 10, 2019 11:33
T440 touchpad libinput to synaptics driver swap
# Match on all types of devices but joysticks
#
# If you want to configure your devices, do not copy this file.
# Instead, use a config snippet that contains something like this:
#
# Section "InputClass"
# Identifier "something or other"
# MatchDriver "libinput"
#
# MatchIsTouchpad "on"
@jpcaparas
jpcaparas / restart-usb-ports.service
Last active May 11, 2019 03:49
systemd service to restart usb ports after suspend (Manjaro)
[Unit]
Description=Restart USB ports after waking up from suspend/hibernate
After=suspend.target hibernate.target
[Service]
Type=oneshot
ExecStart=/opt/usr/bin/reset-usb-ports.sh
[Install]
WantedBy=suspend.target hibernate.target