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
T=$(grep -i "Message received:" $F | wc -l) | |
typeset -F2 MP=$M.00/$T.00 #float number calculation | |
printf "Total[%8s] [%8.2f]" | |
#meaning escalate all warnings like 0 rows | |
set -e | |
tr '\n' ' ' | sed s/.$//' ' | |
grep -i "message" `find 2014* -type f -name *.log` | wc -l |
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
def foo(): | |
pass; | |
if __name__ == '__main__': | |
import timeit | |
print(timeit.timeit("test()", setup="from __main__ import test", number=10)) | |
if __name__=='__main__': | |
from timeit import Timer | |
t = Timer(lambda: foo(bar) ) |
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
(defun db-compile() | |
"run a command on the current file and revert the buffer" | |
(interactive) | |
(shell-command | |
(format "RTZ.py %s" | |
(shell-quote-argument (buffer-file-name)))) | |
(revert-buffer t t t)) | |
(global-set-key (kbd "M-o M-c") 'db-compile) |
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
ps = d.disqus.posts.list(forum='campusnews') | |
#likes / dislikes | |
rs = d.disqus.posts.details( post='1310432214') |
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
apt-cache search virtualbox | |
sudo aptitude install virtualbox-ose-dkms | |
wget https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.2_x86_64.deb (#https://www.vagrantup.com/download-archive/v1.7.2.html) | |
dpkg -i vagrant_1.7.2_x86_64.deb | |
sudo dpkg -i vagrant_1.7.2_x86_64.deb | |
sudo apt-get install linux-headers-$(uname -r) | |
sudo dpkg-reconfigure virtualbox-ose-dkms |
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
public static String getAccessTokenOfAccount() throws IOException { | |
String url = "SOMEURL"; | |
DefaultHttpClient client = new DefaultHttpClient(); | |
HttpGet request = new HttpGet(url); | |
HttpResponse response = client.execute(request); | |
BufferedReader rd = new BufferedReader( | |
new InputStreamReader(response.getEntity().getContent())); | |
StringBuilder result = new StringBuilder(); |
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
#!/usr/bin/python | |
import pycosat | |
class Var(object): | |
_num_vars = 0 | |
idx_to_var = {} | |
@staticmethod | |
def _add_var(var): | |
Var._num_vars += 1 | |
idx = Var._num_vars |
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
//In discussion of http://stackoverflow.com/questions/39118224/would-java-jit-compiler-optimise-useless-throw-statement | |
//awang:/tmp/ $ cat GarbageTest.java [20:57:30] | |
import java.io.IOException; | |
public class GarbageTest { | |
private void f() throws IOException { | |
throw new IOException(); | |
} |
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 dispatchMouseEvent = function(target, var_args) { | |
var e = document.createEvent("MouseEvents"); | |
// If you need clientX, clientY, etc., you can call | |
// initMouseEvent instead of initEvent | |
e.initEvent.apply(e, Array.prototype.slice.call(arguments, 1)); | |
target.dispatchEvent(e); | |
}; | |
function clickContinue() { | |
dispatchMouseEvent(element, 'mouseover', true, true); |
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
import scala.reflect.runtime.universe._; | |
import org.apache.spark.sql.SparkSession; | |
val field = spark.getClass.getDeclaredField("extensions"); | |
field.setAccessible(true); | |
val extensions = field.get(spark).asInstanceOf[org.apache.spark.sql.SparkSessionExtensions]; | |
val tpe = typeOf[org.apache.spark.sql.SparkSession]; | |
val m = scala.reflect.runtime.currentMirror; | |
val im = m.reflect(m.reflectModule(tpe.typeSymbol.asClass.companion.asModule).instance); | |
val method = tpe.companion.decl(TermName("applyExtensions")).asMethod;\n | |
im.reflectMethod(method)("io.delta.sql.DeltaSparkSessionExtension" :: Nil, extensions); |
OlderNewer