if [ -d "$DIRECTORY" ]; then
# Control will enter here if $DIRECTORY exists.
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
// Returns the camera matrix given the focal and the image itself | |
// img The reference to the image | |
// f The focal length in pixels of the camera | |
cv::Mat getCameraMatrix(const cv::Mat& img, const float f) { | |
const int cx = img.cols / 2; | |
const int cy = img.rows / 2; | |
return (cv::Mat_<float>(3, 3) << f, 0, cx, 0, f, cy, 0, 0, 1); | |
} | |
// Convert a set of points to bearing |
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 info.kghost.test | |
import java.net.InetSocketAddress | |
import java.nio.channels.SelectionKey | |
import java.nio.channels.Selector | |
import java.nio.channels.ServerSocketChannel | |
import java.nio.channels.SocketChannel | |
import java.nio.ByteBuffer | |
import scala.collection.JavaConversions.collectionAsScalaIterable |
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
// scala -P:continuations:enable | |
//Continuation对于诸如异步I/O,UI事件处理以及数据流并发之类的高级控制建造十分有帮助 | |
import util.continuations._ | |
object Continue{ | |
def say = | |
reset { | |
shift { | |
cf:(Int=>Int) => | |
val even = cf(10) |
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 | |
################################################################################### | |
# Requirements: python3, pip3 and curl | |
# | |
# You may be probably interested on creating an isolated Python3 environment. | |
# A quick recipe would be: | |
# $ sudo apt-get install python3-minimal curl virtualenv virtualenvwrapper | |
# $ mkvirtualenv -p /usr/bin/python3 myenv | |
# $ workon myenv |
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 | |
################################################################################### | |
# Requirements: python3, pip3 and curl | |
# | |
# You may be probably interested on creating an isolated Python3 environment. | |
# A quick recipe would be: | |
# $ sudo apt-get install python3-minimal curl virtualenv virtualenvwrapper | |
# $ mkvirtualenv -p /usr/bin/python3 myenv | |
# $ workon myenv |
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
# Identifying character names in The Adventures of David Simple | |
# source: http://www.munseys.com/diskone/davidsimp.htm | |
# | |
# commands: | |
# ./ner.sh david_simple.txt > david_simple.ner.txt | |
# sed -e 's/\S\+\/[^P]\w*//g' -e 's/\s\{2,\}/\n/g' -e 's/\/PERSON//g' david_simple.ner.txt | sort | uniq -c | sort -nr | sed 's/^\s\+//' | awk '{if ($1 > 1) print $1,"\t",substr($0, length($1)+2) }' | |
# note: ner.sh is Stanford NER http://nlp.stanford.edu/software/CRF-NER.html | |
238 David | |
131 Cynthia |
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
port=$1 | |
pid=`netstat -nlp 2>/dev/null|grep ${port}|grep LISTEN|awk '{print \$NF}'|awk -F"/" '{print \$1}'` | |
echo $pid |
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
sort corpus_locations.csv | uniq -c | sort -nr > corpus_locations_count.tsv |
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
#Requires GNU awk 4+, but eliminates the need for a specialized CSV library to handle quoted fields that contain delimiters. | |
#http://www.gnu.org/software/gawk/manual/html_node/Splitting-By-Content.html | |
#http://stackoverflow.com/a/17287068/75386 | |
gawk -vFPAT='[^,]*|"[^"]*"' '{print $1,$2,$3}' |
OlderNewer