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
/** | |
* @name Prefer Generator to List Comprehension | |
* @description List comprehensions can be avoided in favor of | |
* @kind problem | |
* @tags reliability | |
* maintainability | |
* @problem.severity recommendation | |
* @sub-severity low | |
* @precision medium | |
* @id py/no-list-comprh |
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
function zjson { | |
zcat $1 | python3 -m json.tool | less | |
} | |
function zjsonl { | |
zcat $1 | while read -r l; do | |
echo $l | python3 -m json.tool | |
echo '--------------------------------------------------' | |
done | less | |
} |
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
in_seq = T.matrix(name='input') | |
initial_state = theano.shared(np.array([0., 0.]), name='initial') | |
initial_scan_state = T.zeros((in_seq.shape[0], initial_state.shape[0])) | |
initial_scan_state = T.set_subtensor(initial_scan_state[0], initial_state) | |
def fun(i, current_element, state): | |
res = T.sum(state[:i], axis=0)+current_element | |
return T.set_subtensor(state[i], res) |
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
#!/bin/bash | |
# | |
# From https://yoursunny.com/t/2016/parallelize/ | |
# | |
# Run commands in parallel. | |
# Usage: JOBS=8 ./parallelize.sh < commands.lst | |
# JOBS: number of subprocesses | |
# If omitted, use number of CPUs. | |
# If specified as AxB, A subprocesses are running in parallel, | |
# and JOBS environ passed to subprocesses is B. |
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
#!/usr/bin/python | |
import csv, sys, os | |
import numpy as np | |
# Get the top X non-fork projects for the GHTorrent dump (without using SQL) | |
# The dumps should be available at http://ghtorrent.org/downloads.html | |
if len(sys.argv) < 5: | |
print "Usage <dir> <language> <topX> <outcsv>" | |
sys.exit(-1) |
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
#put the code below into your .htaccess file to force https | |
Options +SymLinksIfOwnerMatch | |
RewriteEngine On | |
RewriteCond %{SERVER_PORT} !=443 | |
RewriteRule ^ https://lowesthost.com%{REQUEST_URI} [R,L] |
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
find ./java_projects -iname '*.java' -print | tar -zcvf java_projects.tar.gz --files-from - |
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 uk.ac.ed.inf.astretriever; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.util.Hashtable; | |
import java.util.Map; |
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 urllib2 | |
prefix = "url-pref" | |
for i in xrange(1,7882): | |
filename = '%0*d' % (5,i)+'.jpg' | |
url = prefix + filename | |
print url | |
u = urllib2.urlopen(url); | |
localfile = open(filename , 'w') |
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
function convertToGSM($t){ | |
$t = strtr($t, array( | |
"@" => "%00", | |
"£" => "%01", | |
"$" => "%02", | |
"¥" => "%03", | |
"è" => "%04", | |
"é" => "%05", | |
"ù" => "%06", | |
"ì" => "%07", |