This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"github.com/siddontang/go-mysql/client" | |
"github.com/siddontang/go-mysql/mysql" | |
"github.com/siddontang/go-mysql/replication" | |
"os" | |
) |
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"log" | |
"net" | |
"os" | |
"strconv" | |
"time" | |
) |
This file contains hidden or 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
# Delete remote branches already merged with development | |
git branch -a --merged | grep -v "\*" | grep -v master | grep -v main | grep -v develop | cut -d'/' -f 3-4 | xargs -n 1 -I {} git push origin :{} | |
# Delete local merged branches | |
git branch --merged | grep -v "\*" | grep -v master | grep -v main | grep -v dev | xargs -n 1 -I {} git branch -d {} | |
# Delete local squashed branches DANGEROUS https://github.com/not-an-aardvark/git-delete-squashed | |
git for-each-ref refs/heads/ "--format=%(refname:short)" | while read branch; do mergeBase=$(git merge-base master $branch) && [[ $(git cherry master $(git commit-tree $(git rev-parse $branch\^{tree}) -p $mergeBase -m _)) == "-"* ]] && git branch -D $branch; done | |
# Delete all local branches except main |
This file contains hidden or 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
# Remove all untagged images | |
docker rmi $(docker images | grep "^<none>" | awk '{print $3}') | |
# Remove all unused images | |
docker images -q |xargs docker rmi |
This file contains hidden or 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
%% @doc Optimized HEX encoder. | |
%% Source http://stackoverflow.com/questions/3768197/erlang-ioformatting-a-binary-to-hex | |
-module(bin_to_hex). | |
-compile([native, {hipe, [o3]}]). | |
-export([bin_to_hex/1]). | |
bin_to_hex(B) when is_binary(B) -> | |
bin_to_hex(B, <<>>). |
This file contains hidden or 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 escript | |
-record(ecsv,{ | |
state = field_start, %%field_start|normal|quoted|post_quoted | |
cols = undefined, %%how many fields per record | |
current_field = [], | |
current_record = [], | |
fold_state, | |
fold_fun %%user supplied fold function | |
}). |
This file contains hidden or 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
package main | |
import ( | |
"errors" | |
"fmt" | |
"github.com/dgrijalva/jwt-go" | |
"time" | |
) | |
type User struct { |
This file contains hidden or 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 escript | |
main([NS, SL]) -> | |
try | |
N = list_to_integer(NS), | |
List = eval(SL), | |
io:format("Result: ~p~n", [random(List,N)]) | |
catch | |
_:_ -> | |
usage() |
This file contains hidden or 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
date_to_integer_iso8601({date,{Y,M,D}}) -> | |
datetime_to_integer_iso8601({datetime,{{Y,M,D},{0,0,0}}}). | |
datetime_to_integer_iso8601({datetime,{{Y,M,D},{H,Min,S}}}) -> | |
Y * 10000000000 + M * 100000000 + D * 1000000 + H * 10000 + Min * 100 + S. |