Skip to content

Instantly share code, notes, and snippets.

View jpedrosa's full-sized avatar

Joao Pedrosa jpedrosa

  • Belem, PA, Brazil
View GitHub Profile
@jpedrosa
jpedrosa / gist:48e4fcdb4fdb66744a4f
Created June 16, 2015 21:37
Fun with game script. :-)
<!DOCTYPE html>
<!-- saved from url=(0037)http://zdmilot.com/gamegen/index.html -->
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<title>GameGen</title>
<link rel="shortcut icon" href="http://zdmilot.com/gamegen/images/sixsided.ico" type="image/icon">
<script async="" src="./GameGen_files/analytics.js"></script><script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
@jpedrosa
jpedrosa / gist:078be0e327b07790c85e
Created March 2, 2015 02:21
JavaScript image switching animation.
<!DOCTYPE html>
<html>
<head>
<title>Switching image sample.</title>
</head>
<body>
<div style="border: solid 1px black; background-color: silver">
<img id="faceAImage" alt="Face A" width="638" height="374"
border="0"
$ frogsh append.dart
Elapsed time: 0.04
1500237.4288328215
$ cat append.dart
main() {
var nn = [];
for (var i = 0; i < 3000000; i++) {
nn.add(Math.random());
}
var sum = 0;
$ 8g append.go && 8l -o goappend append.8 && time ./goappend
Elapsed time: 0.18
1.5000704643886663e+07
real 0m4.944s
user 0m4.664s
sys 0m0.236s
$ cat append.go
package main
$ cat big_what.dart
main() {
print(0xABADC0DA * 0xABADC0DA);
//= 8296076440540789000 (doubles, javascript)
//#= 8296076440540789156 (bigints)
}
$ dart_release big_what.dart
8296076440540789156
$ frogsh big_what.dart
2001308926266292700
$ cat plus.dart
main() {
var count = 0;
for (var i = 0; i < 100000; i++) {
count += i;
}
print(count);
}
$ time dart_release plus.dart
4999950000
@jpedrosa
jpedrosa / gist:1290293
Created October 15, 2011 23:10
Fasta Benchmark for Dart
// The Great Computer Language Shootout
// http://shootout.alioth.debian.org
//
// Contributed by Ian Osgood
// Adapted by Joao Pedrosa for Dart
var last = 42, A = 3877, C = 29573, M = 139968;
rand(max) {
last = (last * A + C) % M;
function Node(children){
Node.counter += 1
this._children = children
}
Node.counter = 0
function make_tree(depth){
if (depth > 1){
return new Node ([make_tree(depth - 1), make_tree(depth - 1)])
function readLines(file_path,fn){
var px=system.posix,
fd, s, i, len,
NL='\n',
ES="",
BS=8096,
unused=[],
trail_nl,
lines,
last_i;
from bzrlib import workingtree
from bzrlib import branch
from bzrlib import delta
import os, fnmatch
import inspect
import re
def branch_status(d):