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 | |
errno_headers="/usr/include/asm-generic/errno-base.h /usr/include/asm-generic/errno.h" | |
print_usage () { | |
echo "Usage: ${0##*/} ERRNO" | |
} | |
case $1 in |
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
{ | |
"keymaps": [ | |
[ | |
{"code": 20, "label": {"base": "q", "shifted": "Q"}}, | |
{"code": 26, "label": {"base": "w", "shifted": "W"}}, | |
{"code": 8, "label": {"base": "e", "shifted": "E"}}, | |
{"code": 21, "label": {"base": "r", "shifted": "R"}}, | |
{"code": 23, "label": {"base": "t", "shifted": "T"}}, | |
{ | |
"code": 0, |
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
mkcdir(){ | |
mkdir "$@" | |
if [ "$1" = "-p" ]; then | |
cd "$2" | |
else | |
cd "$1" | |
fi | |
} |
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
import collections | |
class Multiset(collections.Counter): | |
def add(self, elem): | |
self[elem] += 1 | |
def remove(self, elem): | |
self[elem] -= 1 | |
if self[elem] == 0: | |
del self[elem] | |
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 | |
# color pager | |
# run command with appropriate color option (like --color-output for 'jq') and pipe to a pager | |
if which lv >/dev/null 2>&1 | |
then | |
pager=(lv -c) | |
else | |
pager=(less -R) | |
fi |
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/sh | |
# | |
# Linux/MacOSX Version of "Easy rooting toolkit (v2.0)" script. | |
# http://forum.xda-developers.com/showthread.php?t=1320350 | |
# You need Linux/MacOSX version of 'adb' binary copied into 'files' | |
# directory | |
# | |
alias adb='./files/adb' | |
cat<<EOF | |
--------------------------------------------------------------- |
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
// https://leetcode.com/problems/median-of-two-sorted-arrays/description/ | |
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"runtime" | |
"sort" | |
"time" | |
) |
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 | |
set -ue | |
voices=($(say -v '?' | egrep 'en_US|en_UK' | egrep -v 'Pipe Organ|Bubbles|Bells|Bahh|Hysterical|Boing|Bad|Albert'| awk '{print $1}')) | |
nr_voices=${#voices[@]} | |
correct=0 | |
wrong=0 | |
RANDMAX=32767 |
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
with open("filename.txt") as f: | |
lineIdx = 0 | |
for line in f: | |
if lineNo %2 == 1: | |
print(lastline + "の" + line) | |
else: | |
lastline = line | |
lineIdx += 1 |
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
// https://leetcode.com/problems/n-queens-ii | |
func totalNQueens(n int) int { | |
ans := []int{0,1,0,0,2,10,4,40,92,352,724,2680,14200,73712,365596,2279184,14772512,95815104,666090624,4968057848,39029188884,314666222712,2691008701644,24233937684440,227514171973736,2207893435808352,22317699616364044,234907967154122528} | |
return ans[n] | |
} |
NewerOlder