Skip to content

Instantly share code, notes, and snippets.

View hugooliveirad's full-sized avatar

Hugo de Oliveira hugooliveirad

View GitHub Profile
@hugooliveirad
hugooliveirad / find-exec-thumbs.sh
Created January 31, 2014 14:28
Find WordPress generated thumbnails and execute a command
# Becareful! This is not tested with every kind of names and isn't ok to use in production.
# So, never execute rm in these files. Please. Or the world will end.
#
# Be sure to run this command in wp-content/uploads.
# Please comment if any strange behavior.
# creates backup folder
mkdir -p ~/bkp
# finds thumbs and move then to ~/bkp. You can run any command after the -exec flag.
@hugooliveirad
hugooliveirad / git-ahead-behind.sh
Last active August 29, 2015 13:55
Git ahead and behind info
# add this function to your .bash_profile to be able to use it everywhere
# usage: git-ahead-behind [local-branch] [remote-branch]
function git-ahead-behind() {
branch="`git symbolic-ref --short -q HEAD`";
loc="${1-$branch}";
remote="${2-origin/$loc}";
git fetch $remote &> /dev/null
wait
@hugooliveirad
hugooliveirad / .yeopress
Last active August 29, 2015 14:03
.yeopress mkt-virtual-theme
{
"dbHost": "localhost",
"dbUser": "root",
"dbPass": "root",
"git": true,
"installTheme": true,
"themeDir": "mkt-virtual-theme",
"themeType": "git",
"themeUser": "mktvirtual",
"themeRepo": "mkt-virtual-theme",
@hugooliveirad
hugooliveirad / wordpress-zip.sh
Last active August 29, 2015 14:04
Generate zip from WordPress project (excluding node_modules and bower_components)
# Run it in the root of your wordpress project
# Create .zip from project, without node_modules and bower_components
projectname=${PWD##*/}; zip -x '*.git*' -x 'wp-content/uploads*' -x '*node_modules*' -x '*bower_components*' -r $projectname.zip .
@hugooliveirad
hugooliveirad / ideia-serviços.md
Last active August 29, 2015 14:08
Ideias para criação de serviços bem simples

Serviços bem simples baseados em API públicas que tenham como objetivo facilitar a vida na cidade.

Algumas ideias do que é possível fazer:

@hugooliveirad
hugooliveirad / prefs.json
Created January 20, 2015 12:33
Sublime Prefs
{
"caret_extra_width": 2,
"caret_style": "phase",
"color_scheme": "Packages/User/base16-ocean.dark (SL).tmTheme",
"dictionary": "Packages/Dictionaries/Portuguese (Brazilian).dic",
"ensure_newline_at_eof_on_save": true,
"folder_exclude_patterns":
[
".svn",
".git",
@hugooliveirad
hugooliveirad / om.cljs
Created May 24, 2015 07:00
My first 100 lines of ClojureScript
(ns ^:figwheel-always om-tut.core
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[cljs.core.async :refer [put! chan <!]]
[clojure.data :as data]
[clojure.string :as string]))
(enable-console-print!)
@hugooliveirad
hugooliveirad / a.sh
Created June 24, 2015 11:30
Run Node REPL with require support
node -e "require('repl').start({ignoreUndefined: true})"
function createReducer(handlers, initialState) {
return function reducer(state = initialState, action) {
return handlers[action.type] ?
handlers[action.type](state, action)
: state
}
}
const math = createReducer({
INCREMENT: (state) => state + 1,
@hugooliveirad
hugooliveirad / angles-fun.js
Created September 16, 2015 16:53
Angles fun
// radians->degrees
function degrees(radians) {
return radians * 180 / Math.PI;
}
// gets two positions { x: Number, y: Number } and return
// angle between them in radians
function getAngle(pos1, pos2 = {x: 0, y: 0}) {
let [dx, dy] = [pos1.x - pos2.x, (pos1.y - pos2.y) * -1]
return Math.atan2(dy, dx);