This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "rmagick" | |
# Define class UniformImage | |
class UniformImage | |
def initialize(image, suffix="_uniform", extension="jpg") | |
# Instance variables | |
@image = image | |
if self.exists? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Usage: getNestedValue(<object>, <array>) | |
const object = { | |
key1: { | |
key11: 'nested-value' | |
} | |
} | |
const nestedValue = getNestedValue(object, ['key1', 'key11']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
##this script will check mongodb and apache | |
##if that service is not running | |
##it will start the service and send an email to you | |
##if the restart does not work, it sends an email and then exits | |
##set the path ##this works for Ubuntu 14.04 and 16.04 | |
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "net/http" | |
require "json" | |
# Execute HTTP requests | |
# How to use | |
# http_request({ | |
# "uri" => "...", # Use URI::Parser | |
# "method" => "...", | |
# "payload" => "...", | |
# "headers" => "...", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
try: | |
from functools import reduce | |
except ImportError: | |
pass | |
# How to use | |
# foo = { "a": "a1", "b": "a2", "c": { "d": "a3" } } | |
# bar = ["c", "d"] | |
# nested_value = get_nested_value(foo, bar) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Just include this function in the .bash_profile (or equivalent) file | |
math() { | |
# Use python to perform mathematics | |
if [ -z $1 ]; then | |
echo "Usage: math [expression]" | |
return 1 | |
fi | |
python -c "print $1" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Usage: setNestedValue(<object>, <array>, <value>) | |
const object = { | |
key1: { | |
key11: 'nested-value' | |
} | |
} | |
const newObject = setNestedValue(object, ['key1', 'key12'], 'another-nested-value') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
################################################################################ | |
# Python Wrapper | |
# ------------------------------------------------------------------------------ | |
# Author: Joao Carmo | |
# License: MIT | |
# ------------------------------------------------------------------------------ | |
# This wrapper script will test each available Python interpreter in the system | |
# to find the one which has the most critical modules installed and then execute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "2.0.0", | |
"tasks": [ | |
{ | |
"label": "Preview as HTML in Chrome", | |
"type": "shell", | |
"osx": { | |
"command": "cp ${file} /tmp/${fileBasename}_preview.html && /Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome /tmp/${fileBasename}_preview.html && sleep 5 && rm -f /tmp/${fileBasename}_preview.html", | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
################################################################################ | |
# Interactive Git Delete | |
# ------------------------------------------------------------------------------ | |
# Author: Joao Carmo | |
# License: MIT | |
# ------------------------------------------------------------------------------ | |
# This script will list all available local branches and you can select one or | |
# more to delete using numbers (from the list). |
OlderNewer