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
# create empty file | |
ni hello.txt | |
# remove directory recursively | |
rmdir | |
# list files | |
ls |
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
git config --global alias.co 'checkout' | |
git config --global alias.br 'branch' | |
git config --global alias.st 'status' | |
git config --global alias.alias 'config --get-regexp ^alias' | |
git config --global alias.squash '!git reset $(git merge-base master $(git branch --show-current))' | |
git config --global alias.squash-undo 'reset HEAD@{1}' |
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
class BitSet: | |
""" | |
bit-array implementation | |
""" | |
def __init__(self, size): | |
# same as size / 32 (2^5) | |
self.arr = [0] * ((size >> 5) + 1) |
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
// AND logic | |
// @see https://medium.com/@stanleydukor/neural-representation-of-and-or-not-xor-and-xnor-logic-gates-perceptron-algorithm-b0275375fea1 | |
// The perceptron model is x1+x2–1 where weights is 1 | |
// Classify into 1 or -1 where | |
// 1 = true | |
// -1 = false | |
const trainingData = [ | |
[1, 1, 1], | |
[1, 0, -1], | |
[0, 1, -1], |
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
/** | |
* Generated from Wikipedia. | |
* Link: https://pt.wikipedia.org/wiki/Lista_de_munic%C3%ADpios_do_Brasil | |
*/ | |
var xs = []; | |
$('.mw-parser-output li').each(function() { | |
xs.push($(this).text()); | |
}); |
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
param ( | |
[switch]$Decrypt = $false, | |
[switch]$Encrypt = $false, | |
[string]$Path | |
) | |
$Dir = $(pwd) | |
$Target = "/tmp" | |
$Image = "<my-image-with-ansible>" | |
$C = "view" |
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
// Reverse inplace the two char arrays splitten by space. Examples: | |
// perfect makes practice -> practice makes perfect | |
// a b c -> c b a | |
function reverse(arr) { | |
reverseArray(arr, 0, arr.length-1); | |
} | |
// reverse array inplace | |
function reverseArray(arr, start, end) { |
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
// dijkstra algorithm | |
// Dijkstra’s algorithm works when all the weights are positive | |
// If you have negative weights, use the Bellman-Ford algorithm. | |
// START -> A | |
// START -> B | |
// B -> A | |
// A -> FIN | |
// B -> FIN |
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
const convert = require('buffer-to-stream'); | |
const request = require('request'); | |
/** | |
* Post binary data in base64. | |
* @param opt The request options | |
* @param data The binary data in base64 string | |
* @param cb The request callback | |
*/ | |
function _postBinaryData(opt, data, cb) { |
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
#!/bin/bash | |
awk -F'|' '(!a[$1]++){print $0"|"FILENAME;}' *.csv |
NewerOlder