Skip to content

Instantly share code, notes, and snippets.

View dgoguerra's full-sized avatar

Diego Guerra dgoguerra

View GitHub Profile
@dgoguerra
dgoguerra / create-db-credentials.sh
Last active December 19, 2016 12:12
Create database and setup credentials
#!/usr/bin/env bash
bin="mysql"
#bin="/Applications/MySQLWorkbench.app/Contents/MacOS/mysql"
database=$1
username=$2
password=$3
if [ ! "$password" ]; then
@dgoguerra
dgoguerra / disown-process.md
Created October 20, 2016 11:18
disown running process
# ctrl + z to pause command
$ bg
$ disown -h
# now you can exit the shell
@dgoguerra
dgoguerra / taiga-collapse-all-readme.md
Last active October 10, 2016 10:14
Collapse / expand all user stories at once in Taiga's sprint view

To use, go to Taiga's sprint view and paste this code into it. The "User Story" header will be clickable, and will expand or collapse all user stories.

@dgoguerra
dgoguerra / memusg
Created September 30, 2016 10:36 — forked from netj/memusg
memusg -- Measure memory usage of processes
#!/usr/bin/env bash
# memusg -- Measure memory usage of processes
# Usage: memusg COMMAND [ARGS]...
#
# Author: Jaeho Shin <[email protected]>
# Created: 2010-08-16
############################################################################
# Copyright 2010 Jaeho Shin. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
@dgoguerra
dgoguerra / dns-lookup.md
Last active September 19, 2016 08:38
DNS lookup

Start of Authority record and authoritative servers of a given domain (see stackoverflow answer):

nslookup -type=soa example.com

Lookup a domain from a particular server. If the DNS server is authoritative for that domain, the response will not be cached (see serverfault answer):

dig @ns1.example.com example.com
@dgoguerra
dgoguerra / git-prune.md
Created September 8, 2016 13:59
Prune branches and tags deleted in the remote
# prune branches deleted in origin
git remote prune origin

# prune tags
# http://stackoverflow.com/questions/1841341/remove-local-tags-that-are-no-longer-on-the-remote-repository
git fetch --prune <remote> '+refs/tags/*:refs/tags/*'
@dgoguerra
dgoguerra / attempt.js
Last active September 5, 2016 12:10
retry an async action until it doesn't fail
// attempt to do an async action in a loop, until it doesn't
// return an error or a max number of retries is reached.
function attempt(opts, fun, next) {
var lastError = null, retry = 0,
increment = opts.increment || 500,
nextTimeout = typeof opts.initial !== 'undefined' ? opts.initial : 500,
maxRetries = typeof opts.retries !== 'undefined' ? opts.retries : 0;
function nextRetry() {
if (maxRetries && retry >= maxRetries) {
@dgoguerra
dgoguerra / browserify_for_webpack_users.markdown
Created August 17, 2016 09:55
browserify for webpack users

browserify for webpack users

There's been a strange explosion in misinformation about browserify recently, particularly in comparisons to webpack.

Generally speaking, most of this confusion stems from how webpack is more willing to pull features into its core to ease discoverability while browserify is more likely to push features out to userland instead.

I think that longer-term, separability has more benefits from a maintenance and

@dgoguerra
dgoguerra / pokemon-slack-bot.js
Last active August 31, 2016 10:18
Pokemon GO slack bot notifications
var async = require('async'),
request = require('request'),
sprintf = require('sprintf-js').sprintf,
pokegoScan = require('pokego-scan');
// coords to check in a loop
var coords = {
latitude: null,
longitude: null
};
@dgoguerra
dgoguerra / laravel-script.php
Created July 15, 2016 10:15
Minimal code to load a Laravel application
<?php
require_once __DIR__.'/vendor/autoload.php';
function bootstrapApplication()
{
$app = require __DIR__.'/vendor/laravel/laravel/bootstrap/app.php';
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();