This file contains 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
[user] | |
name = Clark | |
email = clark@abc.com | |
[alias] | |
gl = config --list | |
gg = config --global | |
l = log --pretty=format:\"%C(yellow)%h %C(cyan)%ad %Cblue%aN %Creset%s\" --date=short --graph | |
ld = log --pretty=format:\"%h %ad %aN %s\" --date=iso --graph | |
lh = show --pretty='format:%ce (%cr): %s' --name-only # list HEAD(last commit) files | |
ll = ls-tree -r master --name-only # list tracked files |
This file contains 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
function chunkLeft (str, size = 3) { | |
if (typeof str === 'string') { | |
const chunks = Array(Math.ceil(str.length / size)) | |
const length = str.length | |
for (let i = 0, index = 0; index < length; i++) { | |
chunks[i] = str.slice(index, index += size) | |
} | |
return chunks | |
} | |
} |
This file contains 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 ipNum = /(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)/.source | |
const ipv4 = new RegExp(`^${ipNum}(?:\\.${ipNum}){3}$`) | |
const arpanetHost = /^[a-z]+(?:[a-z0-9-]*?[a-z0-9]+)?$/i | |
const subdomain = /^[a-z0-9]+([a-z0-9-]*[a-z0-9]+)?$/i | |
// https://tools.ietf.org/html/rfc1035#section-2.3.1 | |
// http://data.iana.org/TLD/tlds-alpha-by-domain.txt | |
const TLDs = [ |
This file contains 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 link = function (...iterables) { | |
const its = iterables.map(i => i[Symbol.iterator]()) | |
return { | |
[Symbol.iterator] () { | |
return this | |
}, | |
next () { | |
let n = { done: true } | |
if (its.length > 0) { | |
n = its[0].next() |
This file contains 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 | |
# https://help.ubuntu.com/community/RemoveOldKernels | |
echo Remove old temp kernel files: | |
sudo rm -rv ${TMPDIR:-/var/tmp}/mkinitramfs-* | |
echo Current kernel: | |
uname -a |
This file contains 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
function generate_bakname() { | |
ORG_NAME=$1 | |
NUM=1 | |
TIME_NAME=${ORG_NAME}_$(date +%Y%M%d_%H%M) | |
NEW_NAME=${TIME_NAME} | |
while [[ -d $NEW_NAME || -f $NEW_NAME ]]; do | |
NEW_NAME=${TIME_NAME}.${NUM} | |
let NUM=NUM+1 | |
done | |
echo $NEW_NAME |
This file contains 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 prototypes; | |
import java.awt.Dimension; | |
import java.awt.GridBagConstraints; | |
import java.awt.GridBagLayout; | |
import java.util.Random; | |
import javax.swing.JFrame; | |
import javax.swing.JScrollPane; | |
import javax.swing.JTextArea; | |
import javax.swing.JTextField; |
This file contains 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
public static String convert(String expression) { | |
String regex = "[^\\?\\*]+"; | |
StringBuffer buffer = new StringBuffer(); | |
Matcher m = Pattern.compile(regex).matcher(expression); | |
while (m.find()) { | |
m.appendReplacement(buffer, Matcher.quoteReplacement(Pattern.quote(m.group()))); | |
} | |
m.appendTail(buffer); | |
return buffer.toString().replaceAll(Pattern.quote("?"), Matcher.quoteReplacement(".")) | |
.replaceAll(Pattern.quote("*"), Matcher.quoteReplacement(".+")); |
This file contains 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
function tax(taxable, bottomline, partitions) { | |
var tax = 0; | |
partitions.reduceRight(function(pre, cur) { | |
var baseline = parseInt(Object.keys(cur)[0]); | |
if (pre > baseline) { | |
tax += (pre - baseline) * cur[baseline.toString()]; | |
return baseline; | |
} else { | |
return pre; | |
} |