Skip to content

Instantly share code, notes, and snippets.

View andreshg112's full-sized avatar
💻
Make it simpler, make it better!

Andrés Herrera García andreshg112

💻
Make it simpler, make it better!
View GitHub Profile
/* global module, exports, require, process, console */
'use strict'
const Airtable = require('airtable')
// Configure Airtable database
const base = new Airtable({
apiKey: process.env.AIRTABLE_API_KEY}
).base(process.env.AIRTABLE_DATABASE)
@jeffochoa
jeffochoa / ProgressBarCallback.php
Last active May 28, 2019 16:10
ProgressBar callback trait for Laravel commands
<?php
namespace App\commands;
trait ProgressionBarOutput
{
public function runProcess(\Countable $countable, callable $callback)
{
$bar = $this->output->createProgressBar(count($countable));
$bar->start();
@evanwill
evanwill / dualpythonnotebook.md
Created June 3, 2016 19:16
add more kernels to python 3 jupyter notebooks with anaconda

this assumes you have installed Python 3 via Anaconda distribution.

Make Python 2 kernel available to Jupyter Notebook

  1. open a terminal and create a new python 2 environment: conda create -n py27 python=2.7
  2. activate the environment: linux source activate py27 or windows activate py27
  3. install the kernel in the env: conda install notebook ipykernel
  4. install the kernel for outside the env: ipython kernel install --user
  5. close the env: source deactivate
@pyjavo
pyjavo / zen_python.md
Last active February 3, 2021 07:28
El zen de Python: Explicado y con ejemplos

El Zen de Python

============ Este post se encuentra publicado en https://pybaq.co/blog/el-zen-de-python-explicado/ ===========

Si alguna vez abren la consola de python y escriben import this verán que les aparecerán las líneas con el famoso Zen de Python:

  1. Beautiful is better than ugly.
  2. Explicit is better than implicit.
@gunnarlium
gunnarlium / guzzle-retry.php
Created December 17, 2015 16:23
Example of how to create a retry subscriber for Guzzle 6
<?php
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Handler\CurlHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Request as Psr7Request;
use GuzzleHttp\Psr7\Response as Psr7Response;
use Psr\Log\LoggerInterface;
const MAX_RETRIES = 2;
@frankdejonge
frankdejonge / Envoy.blade.php
Created August 23, 2014 15:59
Envoy server at a non-standard port
@servers(['web' => 'user@example.com -p 1234'])
@task('deploy', ['on' => 'web'])
ls -la
@endtask
@OlesenkoViktor
OlesenkoViktor / PS3Dualshock_10_15.plist
Last active June 27, 2022 07:48
DualShock 3 + Mac OS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CGPDeviceCategory</key>
<string>GamePad</string>
<key>CGPDeviceType</key>
<string>PS3</string>
<key>CGPDisplayNameOvr</key>
<string>DualShock3 Analogue Triggers</string>
@meSingh
meSingh / JsonMiddleware.php
Last active July 11, 2022 09:19
If you are using laravel as api only, you might want to return JSON on every request, even on errors/exceptions. The easiest way to do so is using this middleware globally.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class JsonMiddleware
{
public function handle(Request $request, Closure $next)
@nicolasembleton
nicolasembleton / restart_bluetooth.sh
Last active October 21, 2022 20:10
Restart Bluetooth Daemon on Mac OS X without restarting
#!/bin/bash
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
@andreshg112
andreshg112 / OrderByField.php
Last active April 6, 2023 09:25
It can be used for queries like this in MySQL: `SELECT * FROM `plans` ORDER BY FIELD(`interval`, 'day', 'week', 'month', 'year');`
<?php
namespace App\Traits;
/**
* Traits that eases the use of ORDER BY FIELD with an eloquent model.
* https://github.com/laravel/ideas/issues/1066
*/
trait OrderByField
{