Skip to content

Instantly share code, notes, and snippets.

View arlm's full-sized avatar

Alexandre Rocha Lima e Marcondes arlm

View GitHub Profile
@arlm
arlm / unzip.ps1
Created February 21, 2017 11:14 — forked from nachivpn/unzip.ps1
Unzip a file in powershell by overwriting existing files
function Unzip($zipfile, $outdir)
{
Add-Type -AssemblyName System.IO.Compression.FileSystem
$archive = [System.IO.Compression.ZipFile]::OpenRead($zipfile)
foreach ($entry in $archive.Entries)
{
$entryTargetFilePath = [System.IO.Path]::Combine($outdir, $entry.FullName)
$entryDir = [System.IO.Path]::GetDirectoryName($entryTargetFilePath)
#Ensure the directory of the archive entry exists
@arlm
arlm / BigDecimal.cs
Created February 20, 2017 16:45 — forked from nberardi/BigDecimal.cs
BigDecimal type in .NET
using System;
using System.Linq;
namespace System.Numerics
{
public struct BigDecimal : IConvertible, IFormattable, IComparable, IComparable<BigDecimal>, IEquatable<BigDecimal>
{
public static readonly BigDecimal MinusOne = new BigDecimal(BigInteger.MinusOne, 0);
public static readonly BigDecimal Zero = new BigDecimal(BigInteger.Zero, 0);
public static readonly BigDecimal One = new BigDecimal(BigInteger.One, 0);
@arlm
arlm / BrPhoneNumberFormatter.java
Created December 22, 2016 00:23 — forked from alfredbaudisch/BrPhoneNumberFormatter.java
Android EditText mask for Brazilian telephone numbers. It deals with the default format (xx) xxxx-xxxx as well the newer longer one (xx) xxxxx-xxxx. Máscara de telefones brasileiros para EditText do Android: formata tanto o telefone padrão (xx) xxxx-xxxx, quanto o novo formato (xx) xxxxx-xxxx.
/**
* Adapted to BR phone format from the class
* UsPhoneNumberFormatter by Samik Bandyopadhyay:
* http://stackoverflow.com/a/23659268/332839
*/
public class BrPhoneNumberFormatter implements TextWatcher {
final int MAX_LENGTH = 11;
//This TextWatcher sub-class formats entered numbers as (41) 1234(5)?-6789
@arlm
arlm / encoding-helpers.ps1
Created October 13, 2016 10:14 — forked from jpoehls/encoding-helpers.ps1
Convert-FileEncoding and Get-FileEncoding
<#
.SYNOPSIS
Converts files to the given encoding.
Matches the include pattern recursively under the given path.
.EXAMPLE
Convert-FileEncoding -Include *.js -Path scripts -Encoding UTF8
#>
function Convert-FileEncoding([string]$Include, [string]$Path, [string]$Encoding='UTF8') {
$count = 0
@arlm
arlm / re-encode.sh
Created October 13, 2016 10:13 — forked from sanssucre/re-encode.sh
Bash script to change the encoding of source files.
#!/bin/bash
# I wrote this script to change the encoding of a large
# source code repository with inconsistent file encoding
SOURCE_DIR=$1
FILE_MASK="*.$2"
DESTINATION_ROOT=$3
if [ $# -ne 3 ]; then
@arlm
arlm / git-obliterate
Created October 13, 2016 10:13 — forked from brianloveswords/git-obliterate
git-obliterate: for removing sensitive files you may have committed from the entire history of the project.
#!/bin/bash
file=$1
test -z $file && echo "file required." 1>&2 && exit 1
git filter-branch -f --index-filter "git rm -r --cached $file --ignore-unmatch" --prune-empty --tag-name-filter cat -- --all
git ignore $file
git add .gitignore
git commit -m "Add $file to .gitignore"
@arlm
arlm / git-commit-cleaner.py
Created October 13, 2016 10:12 — forked from kanzure/git-commit-cleaner.py
git-filter-branch examples and notes
"""
Creates pretty-looking commit messages for git. This was created to pretty
print the old-commit-id values for filter-branched-rewritten commits in
pyphantomjs from the phantomjs repository.
"""
import os
import sys
@arlm
arlm / details.md
Created October 12, 2016 14:44 — forked from richfitz/details.md
Unify (and unixify) line endings through a git repository's history

Basic strategy same as here but having some trouble with getting find to behave like the article, and working around files that have spaces or other special character in them (especially apostrophes, as they are in people's names).

The fix-eol.sh file is basically the same as the articles, except that we use a for loop over xargs so that the name escaping can be done.

The fix-eol-1.sh file converts all line endings to Unix for a single file. The issues are mostly Mac, but this does Windows -> Unix first so that the \r in Windows files isn't also changed to a \n (giving \n\n).

Run by doing

git filter-branch --tree-filter '~/Documents/Projects/baad/fix-eol.sh' --prune-empty -- --all
@arlm
arlm / userDefineLang.xml
Created September 28, 2016 12:30 — forked from jeremypage/userDefineLang.xml
Notepad++: userDefineLang.xml for Markdown (from https://github.com/jjchiw/markdown_npp)
<NotepadPlus>
<UserLang name="MarkDown" ext="md markdown" udlVersion="2.1">
<Settings>
<Global caseIgnored="yes" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="yes" Keywords2="yes" Keywords3="yes" Keywords4="yes" Keywords5="yes" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments">00# 01 02 03&lt;!-- 04--&gt;</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>
@arlm
arlm / HOSTS-UDL.xml
Created September 28, 2016 12:30 — forked from CodeAndLoathing/HOSTS-UDL.xml
Notepad++ User defined language to format Windows HOSTS file
<NotepadPlus>
<UserLang name="HOSTS" ext="" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="1" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments">00# 01 02 03 04</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>