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
on run {input, parameters} | |
do shell script "hidutil property --set '{\"UserKeyMapping\":[{\"HIDKeyboardModifierMappingSrc\":0x700000064,\"HIDKeyboardModifierMappingDst\":0x700000035}]}'" with administrator privileges | |
return input | |
end run |
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
#include <cstdio> | |
#include <iostream> | |
#include <memory> | |
#include <stdexcept> | |
#include <string> | |
#include <array> | |
std::string exec(const char* cmd) { | |
std::array<char, 128> buffer; | |
std::string result; |
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
for i in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30; do find . -type f -name "${i}*" -print ; done > /tmp/files | |
cat /tmp/files | while read line || [[ -n $line ]]; do d=`dirname "${line}"`; b1=`basename "${line}"`; b2=`basename "${line}" | cut -c4-`; mv "${d}/${b1}" "${d}/${b2}"; done | |
find . -type f -name "*.m4a" -exec ffmpeg -v 5 -y -i '{}' -acodec libmp3lame -ac 2 -ab 192k '{}'.mp3 \; -print |
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 sets | |
import ( | |
"fmt" | |
"strings" | |
) | |
// DisjointSet tracks a set of elements partitioned | |
// into a number of disjoint (non-overlapping) subsets. | |
type DisjointSet 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
package heaps | |
// Elem is a comparable element of the heap | |
type Elem interface { | |
Compare(elem Elem) int | |
} | |
// PairingHeap is a type of heap data structure | |
type PairingHeap struct { | |
elem Elem |
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
get_latest_release() { | |
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api | |
grep '"tag_name":' | # Get tag line | |
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value | |
} | |
# Usage | |
# $ get_latest_release "creationix/nvm" | |
# v0.31.4 |
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
execute pathogen#infect() | |
let g:go_fmt_command = "goimports" | |
let g:clang_format#detect_style_file=1 | |
let g:clang_format#auto_format=1 | |
let NERDTreeShowHidden=1 | |
set autoindent | |
set tabstop=4 " Show existing tab with 4 spaces width | |
set shiftwidth=4 " When indenting with '>', use 4 spaces width |
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
func dist(lat1, lon1, lat2, lon2 float64) float64 { | |
const R = 1000.0 * 6378.132 // Radius of earth in m. | |
lat := lat2*math.Pi/180.0 - lat1*math.Pi/180.0 | |
lon := lon2*math.Pi/180.0 - lon1*math.Pi/180.0 | |
a := math.Sin(lat/2.0)*math.Sin(lat/2.0) + math.Cos(lat1*math.Pi/180.0)*math.Cos(lat2*math.Pi/180.0)*math.Sin(lon/2.0)*math.Sin(lon/2.0) | |
c := 2.0 * math.Atan2(math.Sqrt(a), math.Sqrt(1.0-a)) | |
d := R * c | |
return d |
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
import java.security.SecureRandom; | |
import java.math.BigInteger; | |
final class StringGenerator { | |
private SecureRandom random = new SecureRandom(); | |
public String next() { | |
return new BigInteger(128, random).toString(32); | |
} |
NewerOlder