Skip to content

Instantly share code, notes, and snippets.

View armand1m's full-sized avatar

Armando Magalhães armand1m

View GitHub Profile
@armand1m
armand1m / hosts
Created August 13, 2016 20:53
Ansible default hosts file
localhost ansible_connection=local
@armand1m
armand1m / worktime-counter.js
Created August 9, 2016 20:19
Count a deadline date using a moment date as start point and a moment duration as the duration of hours, considering your work schedule and that you don't work at weekends, holidays
const moment = require('moment')
const HOURS = {
WORK_START: 8,
LUNCH_START: 12,
LUNCH_END: 13,
WORK_END: 17
}
const INT_LUNCH_DURATION = (HOURS.LUNCH_END - HOURS.LUNCH_START)
@armand1m
armand1m / prepare-commit-msg
Created July 22, 2016 16:19 — forked from aemonge/prepare-commit-msg
Angular Commit Message Conventions git hook, so you got your commit prepared to with the messages they expect ;)
firstLine=`head -2 $1 | tail -1`
if [[ $firstLine == \#* ]]; then # Testing that the file starts with a comment, not yet a real commit ;)
echo '<type>(<component>): <subject>' > .prepare-commit-msg-temp
echo '' >> .prepare-commit-msg-temp
echo '<body>' >> .prepare-commit-msg-temp
echo '' >> .prepare-commit-msg-temp
echo '# types: feat, fix, docs, style, refactor, test, chore(mantean)' >> .prepare-commit-msg-temp
{ cat .prepare-commit-msg-temp; cat $1; } > .prepare-commit-msg-temp2
cat .prepare-commit-msg-temp2 > $1
@armand1m
armand1m / jsf-viewstate-fixer.js
Created July 20, 2016 13:16
Fixer for updating and setting view state hidden field for multiple forms ajax requests in JSF 2.0/2.1/2.2
(function() {
jsf.ajax.addOnEvent(function(data) {
if (data.status == "success") {
var viewState = getViewState(data.responseXML);
for (var i = 0; i < document.forms.length; i++) {
var form = document.forms[i];
if (form.method == "post" && !hasViewState(form)) {
createViewState(form, viewState);
@armand1m
armand1m / query_by_date.sql
Last active October 15, 2016 14:35
how to query a mssql server table by date
SELECT *
FROM TABLENAME
WHERE DateTime BETWEEN '04/12/2011 12:00:00 AM' AND '05/25/2011 3:53:04 AM'
@armand1m
armand1m / docker-machine-no-tls.sh
Last active December 2, 2018 01:31
Create docker-machine without TLS verification
docker-machine create -d virtualbox --engine-opt tlsverify=false node1
eval $(docker-machine env node1)
unset DOCKER_TLS_VERIFY
@armand1m
armand1m / .bash_profile
Created April 20, 2016 03:22
.bash_profile with functions for connecting to vpn using AppleScript
function vpn-connect {
/usr/bin/env osascript <<-EOF
tell application "System Events"
tell current location of network preferences
set VPN to service "your-vpn-name"
if exists VPN then connect VPN
repeat while (current configuration of VPN is not connected)
delay 1
@armand1m
armand1m / sdck.sh
Created March 24, 2016 14:03
automating docker-machine environment
# put it on your .bash_profile or .zshrc
dck_status=$(docker-machine status)
if [ $dck_status == "Stopped" ]; then
echo "sdck ~ starting docker-machine..."
docker-machine start
echo "sdck ~ setting environment.."
eval $(docker-machine env)
else
@armand1m
armand1m / serial_validator.c
Created November 12, 2015 00:21
bagui em c
#import <stdbool.h>
#import <string.h>
#import <stdlib.h>
#import <stdio.h>
bool is_valid(char serial[]);
void print(char serial[]);
int digit_to_int(char digit);
bool is_int_value(char digit);
int valid_serial();
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#