Skip to content

Instantly share code, notes, and snippets.

View stevenroose's full-sized avatar
👀
looking for a decentralized GitHub alternative

Steven Roose stevenroose

👀
looking for a decentralized GitHub alternative
View GitHub Profile
EncryptedPrivateKey encrypt(Uint8List privKey, KeyParameter aesKey) {
if(privKey == null || aesKey == null) throw new ArgumentError();
Uint8List iv = new Uint8List(BLOCK_LENGTH);
// TODO fill iv with random bytes from securerandom
ParametersWithIV keyWithIv = new ParametersWithIV(aesKey, iv);
PaddedBlockCipher cipher = new PaddedBlockCipherImpl(new PKCS7Padding(), new CBCBlockCipher(new AESFastEngine()));
cipher.init(true, keyWithIv);
Uint8List encryptedKey = cipher.process(privKey);
Process: dota_osx [1774]
Path: /Users/USER/Library/Application Support/Steam/*/dota_osx
Identifier: dota_osx
Version: ???
Code Type: X86 (Native)
Parent Process: bash [1771]
User ID: 501
Date/Time: 2014-05-18 17:19:40.949 +0200
OS Version: Mac OS X 10.8.5 (12F45)
public void execute(Worm worm){
Map<String, Type> context = new HashMap<String, Type>();
context.put("self", new WormEntityType(worm));
programTree.execute(context);
}
public class AssignmentStatement implements Statement {
String name;
Expression rhs;
public AssignmentStatement(String name, Expression rhs) {
this.name = name;
this.rhs = rhs;
}
public void execute(Map<String, Type> context) {
public abstract class Statement {
public void execute(Map<String, Type> context);
/**
* Updates the global context with the changes made in the local scope.
* Variables newly created in the scope are discarded.
*/
protected void updateContext(Map<String, Type> context, Map<String, Type> scopeContext) {
for(String key : context.keySet()) {
Steven-Rooses-MacBook-Pro:capsel4 steven$ python3 ~/Downloads/problog2/src/problog.py /Volumes/Data/Google\ Drive/school/irw/1ma/mettim/capsel4/part1.pl
Calling external process failed:
Command '/Users/steven/Downloads/problog2/assist/darwin/dsharp -Fnnf /var/folders/91/_k0t34l161qf90jgdsd995q40000gn/T/tmpu1jtlxz1/compile_cnf.nnf -Fgraph /var/folders/91/_k0t34l161qf90jgdsd995q40000gn/T/tmpu1jtlxz1/compile_cnf.nnf.graph -smoothNNF -disableAllLits /var/folders/91/_k0t34l161qf90jgdsd995q40000gn/T/tmpu1jtlxz1/compile_cnf' returned -11
Verifying myself: My Bitcoin username is +stevenroose. https://onename.io/stevenroose
@stevenroose
stevenroose / gist:010f3b8671141f31ca79
Last active August 29, 2015 14:10
Performance comparison between two big integer implementations in Dart
/**
* Results for the Dart VM (v1.7.2)
* Duration for bignum's BigInteger: 59s
* Duration for rational's BigInt: 197s
*
* Results for dart2js in Chrome (v39.0.2171.62)
* Duration for bignum's BigInteger: 77s
* Duration for rational's BigInt: 474s
*/
@stevenroose
stevenroose / gist.md
Last active August 29, 2015 14:15
Using deferred loading to create environment-independent libraries in Dart

Using deferred loading to create environment-independent libraries in Dart

The problem

Upon creating my first Dart library, I bumped into the issue of the environment-dependent libraries dart:io and dart:html, and most importantly the fact that some very similar functionality is present in both of them.

It bothered my ever-since that many libraries had to split up into two counterparts and so did some of the classes within. Let's say one of your classes uses WebSockets. The WebSocket is defined differently in dart:io and dart:html. So what you have to do create an abstract class for the general case and then create two subclasses in their own libraries that fill the gap of the WebSocket interface.

It would look like this:

library environment;
import "dart:async";
import "dart:io" deferred as io;
import "dart:html" deferred as html;
Future inEnvironment({Future onIo(), Future onHtml()}) {
Completer c = new Completer();
io.loadLibrary().then((_) {