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/env python3 | |
## usage: ./sparql_query.py 'select ?x where {[] a ?x} limit 100' | |
import json | |
import sys | |
from SPARQLWrapper import SPARQLWrapper, JSON | |
if __name__ == '__main__': | |
query = sys.argv[1] | |
sparql = SPARQLWrapper('http://dbpedia.org/sparql') | |
sparql.setQuery(query) |
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
cat wiki_* | awk '!/<doc id/ || !/<\/doc/{print x, "\n";};{x=$0}' > wiki_text_extracted |
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/env python | |
import sys | |
import random | |
if __name__ == '__main__': | |
old_indices = [] | |
new_indices = [] | |
with open(sys.argv[1]) as f: | |
pl = f.read().split("\n") | |
desired = [] | |
for i in range(1, len(pl[1:]), 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
[archlinuxfr] | |
SigLevel = Never | |
Server = http://repo.archlinux.fr/$arch |
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
{ | |
"0": [ | |
"aardvark", | |
"adroitness" | |
], | |
"1": [ | |
"absurd", | |
"adviser" | |
], | |
"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
$ for file in *.csv; do echo "${file%.csv},$(head -n 1 $file)" >> headers; done |
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 abstractreflection | |
import "reflect" | |
// Sum adds all the fields of `struct1` to `struct2` | |
// This will only work if the two structs are of the same | |
// type, and have flat properties | |
// that are all float64. If not, the result will be `nil` | |
func Sum(struct1 interface{}, struct2 interface{}) interface{} { | |
t := reflect.TypeOf(struct1) | |
if t != reflect.TypeOf(struct2) { |
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
# Shutdown local node | |
$ curl -XPOST 'http://localhost:9200/_cluster/nodes/_local/_shutdown' | |
# Shutdown all nodes in the cluster | |
$ curl -XPOST 'http://localhost:9200/_shutdown' |
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
# SCP Protip: Ever needed to copy something between two remote | |
# servers with a proxy (like orbital) in between them? In one step (kinda?)? | |
# Try using this insane `scp` invocation to copy a file from remote host 1 to remote host 2 | |
# which is behind a proxy gateway! | |
scp -v -3 -o "ProxyCommand ssh -A -o StrictHostKeyChecking=no | |
-o UserKnownHostsFile=/dev/null proxy_user@proxyhost nc remotehost2 port_for_remotehost_2" | |
-o "ForwardAgent=yes" -o "StrictHostKeyChecking=no" | |
-o "UserKnownHostsFile=/dev/null" | |
user1@remotehost1:/file/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
# First, get the last line of each file (each log file) | |
# Then, pull the floating point number at the end of the line | |
# Then, collect the sum of `1/floating_point_number`. At the end, print | |
# s | |
tail -n 1 *.log | grep -e "[0-9]\.[0-9]*$" -o | awk '{s+=1/$1} END {print s}' |