Skip to content

Instantly share code, notes, and snippets.

View joyoyoyoyoyo's full-sized avatar
🏴
living it up and busy supporting my community.

Angel Ortega (he/they) joyoyoyoyoyo

🏴
living it up and busy supporting my community.
View GitHub Profile
@joyoyoyoyoyo
joyoyoyoyoyo / relative_pose.cpp
Created March 1, 2017 07:57 — forked from edgarriba/relative_pose.cpp
relative pose with opengv
// 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
@joyoyoyoyoyo
joyoyoyoyoyo / echo server
Created June 9, 2017 16:46 — forked from kghost/echo server
echo server using scala continuation
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
// scala -P:continuations:enable
//Continuation对于诸如异步I/O,UI事件处理以及数据流并发之类的高级控制建造十分有帮助
import util.continuations._
object Continue{
def say =
reset {
shift {
cf:(Int=>Int) =>
val even = cf(10)
@joyoyoyoyoyo
joyoyoyoyoyo / install-jupyter.sh
Created October 8, 2017 20:41 — forked from frgomes/install-jupyter.sh
Debian - Install Jupyter and Scala kernel on Debian Stretch
#!/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
@joyoyoyoyoyo
joyoyoyoyoyo / install-jupyter.sh
Created October 8, 2017 20:41 — forked from frgomes/install-jupyter.sh
Debian - Install Jupyter and Scala kernel on Debian Stretch
#!/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
# 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
@joyoyoyoyoyo
joyoyoyoyoyo / BashCheatSheet.md
Created November 29, 2017 14:13 — forked from damc-dev/BashCheatSheet.md
Linux/Unix Cheat Sheet

Bash Cheat Sheet

If

If Directory Exists

Stack Overflow

if [ -d "$DIRECTORY" ]; then
  # Control will enter here if $DIRECTORY exists.
fi
port=$1
pid=`netstat -nlp 2>/dev/null|grep ${port}|grep LISTEN|awk '{print \$NF}'|awk -F"/" '{print \$1}'`
echo $pid
sort corpus_locations.csv | uniq -c | sort -nr > corpus_locations_count.tsv
@joyoyoyoyoyo
joyoyoyoyoyo / csv.awk
Created November 29, 2017 14:16 — forked from kmatt/csv.awk
CSV parsing in Awk
#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}'