Skip to content

Instantly share code, notes, and snippets.

View githubnando's full-sized avatar
💤
I may be slow to respond.

Ernando José githubnando

💤
I may be slow to respond.
View GitHub Profile
@githubnando
githubnando / mysqldump-ignoring-multiple-tables.sh
Last active July 17, 2017 13:49
mysqldump-ignoring-multiple-tables
#!/bin/bash
DB_HOST=""
DB_DATABASE=""
DB_USERNAME=""
DB_PASSWORD=""
read -r -d '' tableSizesQuery << EOF
SELECT
table_schema as 'Database',
@githubnando
githubnando / two-daterangepicker-dates.md
Last active February 22, 2017 12:53
Two date inputs synchronized

Two date inputs using daterangepicker and jQuery. If the first date gets an update, the second date will also suffer an update if the range of the first date is higher than the second one.

example

// this.dateRangePicker('#start_at_datepicker', '#start_at_form');
// this.dateRangePicker('#end_at_datepicker', '#end_at_form', true);

dateRangePicker(datepickerInputId, dateInputId, minDate = false) {
    let input = document.querySelector(dateInputId);
@githubnando
githubnando / file-ajax-download.md
Last active June 20, 2017 13:40
Downlaod a file without opening a new window/popup

HTML

<iframe name="downloadIframe" id="downloadIframe" style="display: none"></iframe>

JAVASCRIPT

downloadTriggered() {
          uri = '/api/v1/users?id=1',
 downloadLink = document.createElement('a');
@githubnando
githubnando / .gitignore
Last active April 5, 2017 14:52
Useful policies of .gitignore
# Just add any subfolder in uploads path with a .gitkeep file in it to
# ignore all the files except the directory
# this doesnt work
public_html/uploads/**/*
!/**/.gitkeep
# instead, name it every directory that needs to ignore files
public_html/uploads/moduleSuperCool/*
@githubnando
githubnando / gtrack.md
Last active August 18, 2017 20:48
Alias for automatically setup tracking for origin in new branches and other useful git commands
# Automatically setup remote tracking for new branches

$ git config --global push.default current



# Make local repository current branch exactly like remote

$ currentBranch=git rev-parse --abbrev-ref HEAD
@githubnando
githubnando / fedora25-afterinstall.sh
Last active October 4, 2017 18:25
Fedora 25|26 Afterinstall - Things TODO
#!/bin/bash
NC='\033[0m'
CO='\033[0;31m'
function display {
echo -e "$CO $1 $NC"
}
display "RPM FUSION FREE AND NONFREE"
@githubnando
githubnando / utf8.php
Last active June 23, 2017 13:38
Recursively encode to UTF-8 a given array
<?php
# Recursively encode to UTF-8 a given array
public function utf8(array $array)
{
array_walk_recursive($array, function(&$item, $key) {
if(is_string($item) && ! mb_detect_encoding($item, 'utf-8', true)) {
$item = utf8_encode($item);
}
@githubnando
githubnando / php-function-singleton.php
Last active July 20, 2017 13:56
Returns each time called the same instance using functions, not methods in OOP
<?php
# Returns each time called the same instance using functions, not methods in OOP
if ( ! function_exists('logger')) {
function logger() {
static $logger;
if ( ! $logger) {
$logger = new Logger('starlight');
@githubnando
githubnando / strpad-left.js
Created June 28, 2017 19:10
Pad left a string with a given number of characters
strPadLeft(string, length, char) {
const str = '' + string;
let pad = '';
for (let i = 0; i < length; i++) {
pad += char;
}
return pad.substring(0, pad.length - str.length) + str;
@githubnando
githubnando / windows10-uefi-stick.sh
Last active July 20, 2017 13:55
Make a bootable Windows 10 UEFI USB Stick
# Let the device unmounted
sudo umount /dev/sdb
# Optional: change the content to zeros
sudo dd if=/dev/zero of=THE_DEVICE bs=512 count=1
# Normally this is not nessecary. Then to create a new layout on the drive:
sudo fdisk /dev/THE_DEVICE
# Then: