Skip to content

Instantly share code, notes, and snippets.

const g = n => n + 1;
const f = n => n * 2;
const wait = time => new Promise(
(resolve, reject) => setTimeout(
resolve,
time
)
);
wait(300)
const g = n => n + 1;
const f = n => n * 2;
const trace = label => value => {
console.log(`${ label }: ${ value }`);
return value;
};
const doStuff = x => {
const afterG = g(x);
#!/bin/bash
git reset --hard # removes staged and working directory changes
## !! be very careful with these !!
## you may end up deleting what you don't want to
## read comments and manual.
git clean -f -d # remove untracked
git clean -f -x -d # CAUTION: as above but removes ignored files like config.
git clean -fxd :/ # CAUTION: as above, but cleans untracked and ignored files through the entire repo (without :/, the operation affects only the current directory
#!/bin/sh
git config --global credential.helper cache
# Set git to use the credential memory cache
git config --global credential.helper 'cache --timeout=7200'
# Set the cache to timeout after 1 hour (setting is in seconds)
#!/bin/bash
git config http.postBuffer 524288000
import com.jasongoodwin.monads.Try;
import org.apache.log4j.Logger;
import java.util.function.Function;
public abstract class Retrier<Tin, Tout> {
private static Logger logger = Logger.getLogger(WsExecuter.class);
private int LIMIT_OF_RETRIES;
doAnswer(new Answer() {
public Object answer(InvocationOnMock invocation) {
Object[] args = invocation.getArguments();
((objectToAlter)args[0]).campo1 = 1;
((objectToAlter)args[0]).campo2 = 2;
return null;
}})
.when(xxxx).method(entry());
@pfrozi
pfrozi / extensions.cs
Last active March 12, 2018 21:05
Get attribute information from ENUM type
public enum ServiceErrors
{
[ErrorDescription(10, "A data de emissão é menor que a data de movimento.", ErrorType.DadosInvalidos)]
DataEmissaoMenorQueMovimento,
[ErrorDescription(20, "Data de emissão inválida.", ErrorType.DadosInvalidos)]
DataEmissaoInvalida
}
public static class ServiceErrorsExtension{
public static ErrorDescriptionAttribute GetErrorDescription<T>(this T serviceErrors)
where T : struct, IConvertible, IComparable, IFormattable
@pfrozi
pfrozi / Update remote repo
Created January 4, 2018 12:36 — forked from mandiwise/Update remote repo
Transfer repo from Bitbucket to Github
// Reference: http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/
// See also: http://www.paulund.co.uk/change-url-of-git-repository
$ cd $HOME/Code/repo-directory
$ git remote rename origin bitbucket
$ git remote add origin https://github.com/mandiwise/awesome-new-repo.git
$ git push origin master
$ git remote rm bitbucket
@pfrozi
pfrozi / mocks.cs
Last active March 6, 2018 21:43
Creating mocks for all types of classes
private static object RandomString(int length)
{
var random = new Random((int)DateTime.Now.Ticks);
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return new string(
Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]
).ToArray()
);
}