Skip to content

Instantly share code, notes, and snippets.

View henriquegogo's full-sized avatar

Henrique Gogó henriquegogo

View GitHub Profile
@henriquegogo
henriquegogo / ctags-rails.sh
Created August 14, 2012 01:22
CTags para projetos que utilizam Rails
ctags -f $(git rev-parse --show-toplevel)/tags -R $(bundle show --paths) $(git rev-parse --show-toplevel)
@henriquegogo
henriquegogo / calc-letters-occurence.js
Created August 30, 2012 13:36
Calc of number of occurence of letters in a string
var result = {};
"Your String".toUpperCase().split(" ").join("").split("").forEach(function(element, index, array) {
result[element] = (result[element] + 1 || 1)
});
console.log(result);
// You can remove '.join("").split("")' to calculate words occurence
@henriquegogo
henriquegogo / UITextFieldNumber.m
Created August 30, 2012 14:03
Extending UITextField to reuse some behaviours
#import "UITextFieldNumber.h"
@implementation UITextFieldNumber
- (void)awakeFromNib
{
[self createKeyboardToolbar];
}
- (void)createKeyboardToolbar
@henriquegogo
henriquegogo / getUserGroups.cs
Created October 15, 2012 20:16
Get current ActiveDirectory user groups
using System;
using System.Collections.Generic;
using System.DirectoryServices.AccountManagement;
using System.Linq;
using System.Security.Principal;
namespace console
{
class MainClass
{
@henriquegogo
henriquegogo / GiWThen.js
Created November 23, 2012 13:31
Given, When, Then BDD mini-framework to acceptance tests in Javascript
(function() {
var currentScenario = "";
var executedTests = 0;
var successTests = 0;
var errorTests = 0;
var Scenario = function(text) {
self.Steps.Before();
currentScenario = text;
@henriquegogo
henriquegogo / RunShellCommand.cs
Created December 18, 2012 17:23
A method to run shell command and return the command line return
private static string RunShellCommand(string command)
{
var arguments = "/C " + command;
var proccessSettings = new ProcessStartInfo("cmd.exe", arguments)
{
WindowStyle = ProcessWindowStyle.Hidden,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};
@henriquegogo
henriquegogo / modal-jquery.js
Created December 19, 2012 19:49
Extreme simple modal using jQuery
$(document).on("click", ".modal", function() {
$(".modal-view").remove();
var imageSrc = $(this).attr("href");
var image = $("<img>").attr("src", imageSrc).attr("style", "box-shadow: 0 0 40px #000");
var modal = $("<div class='modal-view'>").attr("style","position: fixed; padding-top: 50px; top: 0; bottom: 0; left: 0; right: 0; z-index: 10; text-align: center; background: rgba(0, 0, 0, 0.5);");
modal.html(image)
.appendTo("body");
@henriquegogo
henriquegogo / cleanduplicates.sh
Created January 19, 2013 04:03
Clean duplicated emails in mbox files
#!/bin/sh
formail -D 1000000 idcache < $1 -s > $1.tmp && mv $1.tmp $1
rm idcache
@henriquegogo
henriquegogo / gist:5877233
Last active December 19, 2015 01:39
Download full website with wget
wget -HELkpr http://website/
@henriquegogo
henriquegogo / gist:8364937
Created January 10, 2014 23:52
Format a pendrive/sdcard with cluster size / allocation unit / sectors per cluster
sudo mkdosfs /dev/mmcblk0 -F32 -s32