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
val key: PGPPublicKey = ... | |
def encrypt(plaintext: String): String = { | |
val baos = new ByteArrayOutputStream() | |
val literalDataGenerator = new PGPLiteralDataGenerator() | |
val comData = new PGPCompressedDataGenerator(CompressionAlgorithmTags.ZLIB) // I've also tried other compression algorithms | |
val bytes = plaintext.getBytes("utf-8") | |
val BufferSize = 1 << 16 | |
import resource.managed // The "managed" method with for is just a nice replacement of try/catch/finally{x.close()} | |
for{ |
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
// An ugly hack for Bittorrent sync; hope to write more later | |
// separate function for easier debugging | |
show = function(x){console.log(["X:"+x.folders.map(function(x){return {folder: x, active_peers: x.peers.filter(function(peer){return peer.down_diff || peer.up_diff;})};}).filter(function(x){return x.active_peers.length > 0;}).map(function(x){return x.folder.name;})])} | |
var origRequest = utWebUI.request; utWebUI.request= function(a, e, d, b){return origRequest.call(this, a, function(f){e && e(f); console.log(f.folders);}, d, b); }; |
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
#include <iostream> | |
#include "json.h" | |
using namespace std; | |
int main() { | |
Json::Number num(3.14159265358972); | |
Json::String s("5.\" ' \1 0"); | |
Json::Boolean t(true); | |
Json::Boolean f(false); |
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 | |
# This script does a configurable intelligent exponential backoff with maximum. If the app runs for some time without any problem, the interval is resetted. | |
# Requires: bash, genius | |
# Security considerations: Like in almost any other shell scripts, some info may leak via /proc/. This should be rather negligible in this case. A local adversary may read sleep values, application run time, wait time and some WAIT_TIME_* variables. | |
# | |
# 1. Replace {{run-the-app}}. | |
# 2. Replace {{clean}} by some clean procedure, e.g. rm -f "$BASE_DIR/play.pid". It might be a good idea to add some notification or logging there. | |
# 3. Configure WAIT_TIME_* variables. | |
# 4. Adjust if needed. |
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/sh | |
IDEA_VERSION=14 | |
# Note that thread dump will not work well when you have launched other IDEA-like IDE (e.g. CLion, PhpStorm, PyCharm, RubyMine), since it has the same main class. | |
time=$(date +%Y-%m-%d--%H:%M:%S) | |
jps -l | grep ' com.intellij.idea.Main$' | sed 's/ .*$//' | xargs jstack > "/tmp/idea-$time.threads" | |
cp ~/.IntelliJIdea$IDEA_VERSION/system/log/idea.log "/tmp/idea-$time.log" | |
notify-send "Saved as /tmp/idea-$time.{log,threads}." |
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 | |
# No warranty is provided! | |
# | |
# Rather hacky script for streaming downloaded files through pipe. | |
# Requires inotify-tools package installed. | |
# It does not handle some failures properly! | |
# | |
# Assumes that a browser saves the temporary result into the .part file and the browser is the only process that opens the file for writing. | |
# | |
# How it works: The script streams the content of the .part file to stdout. When the .part file is closed, it stops streaming. |
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
% scalac weird.scala && javap X | |
Compiled from "weird.scala" | |
public class X implements scala.ScalaObject { | |
public int 1(); | |
public java.lang.String package(); | |
public java.lang.String class(); | |
public java.lang.String def(); | |
public java.lang.String for(); | |
public java.lang.String while(); | |
public X(); |
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
% ant test-opt -v | |
… | |
test.osgi: | |
[echo] Running OSGi JUnit tests. Output in …/scala/build/osgi | |
[mkdir] Skipping …/scala/build/osgi/classes because it already exists. | |
[junit] Implicitly adding /usr/share/ant/lib/junit.jar:/usr/share/java/ant-launcher-1.8.2.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-junit.jar:/usr/share/ant/lib/ant-junit4.jar to CLASSPATH | |
[junit] Executing '/usr/lib/jvm/java-8-oracle/jre/bin/java' with arguments: | |
[junit] '-classpath' | |
[junit] '…/scala/build/osgi/classes:…/scala/build/osgi/org.scala-lang.scala-library.jar:…/scala/build/osgi/org.scala-lang.scala-reflect.jar:…/scala/build/osgi/org.scala-lang.scala-compiler.jar:…/scala/build/osgi/org.scala-lang.scala-actors.jar:…/.m2/repository/org/ops4j/pax/exam/pax-exam-container-native/2.6.0/pax-exam-container-native-2.6.0.jar:…/.m2/repository/org/ops4j/pax/exam/pax-exam/2.6.0/pax-exam-2.6.0.jar:…/.m2/repository/org/ops4j/base/ops4j-base-lang/1.4.0/ops4j-base-lang-1.4.0.jar:…/.m2/repository/org/ops4j/base/ops4j-b |
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
<testcase classname="tools.test.osgi.BasicTest" name="everythingLoads:tools.test.osgi.BasicTest.everythingLoads:NativeContainer:org.apache.felix.framework.FrameworkFactory@5606c0b" time="10.442"> | |
<error message="gave up waiting for service org.ops4j.pax.exam.ProbeInvoker" type="org.ops4j.pax.swissbox.framework.ServiceLookupException">org.ops4j.pax.swissbox.framework.ServiceLookupException: gave up waiting for service org.ops4j.pax.exam.ProbeInvoker | |
at org.ops4j.pax.swissbox.framework.ServiceLookup.getService(ServiceLookup.java:161) | |
at org.ops4j.pax.swissbox.framework.ServiceLookup.getService(ServiceLookup.java:104) | |
at org.ops4j.pax.swissbox.framework.ServiceLookup.getService(ServiceLookup.java:87) | |
at org.ops4j.pax.exam.nat.internal.NativeTestContainer.call(NativeTestContainer.java:94) | |
at org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactor.invoke(AllConfinedStagedReactor.java:74) | |
at org.ops4j.pax.exam.junit.JUnit4TestRunner$2.evaluate(JUnit4TestRunner.java:285) | |
at org.ops4j.pax.exam.junit.JUn |
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: 0, 100, 200 | |
1: 1, 101, 201 | |
2: 2, 102, 202 | |
3: 3, 103, 203 | |
4: 4, 104, 204 | |
5: 5, 105, 205 | |
6: 6, 106, 206 | |
7: 7, 107, 207 | |
8: 8, 108, 208 | |
9: 9, 109, 209 |
OlderNewer