Algorithm | Card set | Times | Elapsed | Note |
---|---|---|---|---|
A-Res | FG only | 100k | 18,741ms | Acceptable speed for small card set |
A-Chao | FG only | 100k | 8,561ms | Broken probability |
Uniform | FG only | 100k | 8,145ms | Current implementation |
A-Chao | All | 100k | 11,215ms | Broken probability |
Uniform | All | 100k | 11,774ms | Current implementation |
A-Res / sort | All | 100k | 163,021ms | Simple implementation but heavy |
A-Res / heap(A) | All | 100k | 31,068ms | Push all cards then pop N cards |
A-Res / heap(W) | All | 100k | 23,028ms | The same as described in Wikipedia |
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 | |
if ! [ "$#" = 1 ] | |
then | |
echo "Usage: $0 FILE" | |
exit 1 | |
fi | |
d="$(identify "$1" | cut -d' ' -f3)" | |
width="${d/x*/}" |
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
# Original PDF: | |
# 1. Front cover | |
# 2. content 1 | |
# 3. content 2 | |
# 4. ... | |
# 5. content -2 | |
# 6. content -1 | |
# 7. Back cover | |
# | |
# Resulting PDF: |
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
aaa |
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 bodyParser = require('body-parser') | |
const express = require('express') | |
const moment = require('moment-timezone') | |
const slack = require('slack') | |
const VERIFICATION_TOKEN = process.env.VERIFICATION_TOKEN | |
const OAUTH_ACCESS_TOKEN = process.env.OAUTH_ACCESS_TOKEN | |
const app = express() |
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 | |
colors=256 | |
fps=30 | |
half= | |
while true | |
do | |
case "$1" in | |
'-c') |
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
<?php | |
$a = 1; | |
debug_zval_dump($a); | |
//==> long(1) refcount(2) | |
// Novice: Huh? Why is refcount 2? The value is only pointed by $a, so refcount must be 1! | |
// Tatsujin: PHP uses copy-on-write. The value is passed by value to debug_zval_dump. | |
// It doesn't modify the passed value. The value is shared by $a and debug_zval_dump. | |
// Therefore refcount is 2. |
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
<?php | |
function test_copy_on_write() | |
{ | |
print "test_copy_on_write\n"; | |
$a = 100; | |
xdebug_debug_zval('a'); | |
//==> a: (refcount=1, is_ref=0)=100 |
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! s:_GetCwordStartPos() | |
let cword = expand('<cword>') | |
let cword_pattern = '\V' . escape(cword, '\') | |
let cword_end_pos = searchpos(cword_pattern, 'ceW', line('.')) | |
let cword_start_pos = searchpos(cword_pattern, 'bcW', line('.')) | |
return cword_start_pos | |
endfunction | |
function! s:GuessClassName() | |
let cursor_pos = getpos('.') |
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
var mapped = gearSets.map(function (gearSet, i) { | |
var countMap = JSON.parse(JSON.stringify(required.countMap)); | |
return { | |
index: i, | |
value: [ | |
gearSet.shoes === anyGear ? 1 : 2, | |
gearSet.clothing === anyGear ? 1 : 2, | |
gearSet.headgear === anyGear ? 1 : 2, | |
countMap[gearSet.headgear.main]-- > 0 ? 1 : 2, |