Skip to content

Instantly share code, notes, and snippets.

View jrobinsonc's full-sized avatar
🎯
Focusing

Jose Robinson jrobinsonc

🎯
Focusing
View GitHub Profile
@jrobinsonc
jrobinsonc / README.md
Last active October 22, 2021 21:40
Use React Context effectively
const parseArgs = (slice = 0) => {
return process.argv.slice(slice).reduce((map, item, index) => {
let match = null;
switch (true) {
case (match = item.match(/^(?:\-\-([a-z]+)|\-([a-z]))(?:=(.+))?$/)) !== null:
const [, longName, shortName, value] = match;
const parsedValue = typeof value === 'undefined' ? true : value;
const parsedName = typeof longName === 'undefined' ? shortName : longName;
;
(function ($, undefined) {
$.fn.handleScroll = (upHandler, downHandler, userOptions) => {
const options = $.extend({}, {
debug: false
}, userOptions);
/**
* Window object.
*/
@jrobinsonc
jrobinsonc / auth.js
Created June 24, 2021 02:28
BASIC Authentication - Simple authentication script intended to be run by Amazon Lambda to * provide Basic HTTP Authentication for a static website hosted in an * Amazon S3 bucket through Couldfront.
/**
* BASIC Authentication
*
* Simple authentication script intended to be run by Amazon Lambda to
* provide Basic HTTP Authentication for a static website hosted in an
* Amazon S3 bucket through Couldfront.
*
* https://hackernoon.com/serverless-password-protecting-a-static-website-in-an-aws-s3-bucket-bfaaa01b8666
*/
@jrobinsonc
jrobinsonc / updateEnumField.php
Last active January 5, 2021 15:13
Simplifies the job of changing the values of a ENUM field. #laravel
<?php
/**
* Update enum column
*
* @param string $tableName Table to update.
* @param string $columnName Column to update.
* @param array $values Values for ENUM column.
* @return void
*/
<?php
namespace App\Helpers;
use App\Helpers\StorageHelper;
use RuntimeException;
use InvalidArgumentException;
class FileHelper
{
@jrobinsonc
jrobinsonc / random-password.php
Last active December 12, 2020 17:08
Generate random passwords.
<?php
/**
* Generate random password
*
* @see <https://gist.github.com/jrobinsonc/ef4245a6e915a038f108e12980ac24bc>
* @param int $len Number of characters the password should have.
* @param string $types Types of characters the password should have.
* Options are: l for lowercase, u for uppercase, d for digital, s for special.
* @return string
#!/bin/bash
# Usage
# ./slack <channel> <message>
# ./slack @jrobinson "Test message for a user"
# ./slack #general "Test message for a channel"
CHANNEL=$1
MSG=$2
#!/bin/bash
# Usage
# ./logzio <type> <message>
# ./logzio info "My Message"
LOG=$2
TYPE=$1
ENV=PRO # Useful to identify which env is sending the log
rsync -va --exclude="node_modules/" --exclude=".git/" --exclude=".dev/" --delete /from-dir/ /to-dir