Skip to content

Instantly share code, notes, and snippets.

@jameshfisher
jameshfisher / halting_problem_javascript.md
Last active September 7, 2017 01:04
A proof that the Halting problem is undecidable, using JavaScript and examples

Having read a few proofs that the halting problem is undecidable, I found that they were quite inaccessible, or that they glossed over important details. To counter this, I've attempted to re-hash the proof using a familiar language, JavaScript, with numerous examples along the way.

This famous proof tells us that there is no general method to determine whether a program will finish running. To illustrate this, we can consider programs as JavaScript function calls, and ask whether it is possible to write a JavaScript function which will tell us

package com.typesafe.jse
import akka.actor._
import scala.collection.mutable.ListBuffer
import scala.concurrent.blocking
import java.io._
import akka.contrib.process.StreamEvents.Ack
import akka.contrib.process.{Sink, Source}
import scala.collection.immutable
import com.typesafe.jse.Engine.ExecuteJs
Tom Moertel <[email protected]>
2013-12-16
We are given the following problem:
Given a text file with 999,999 lines, one number per line,
numbers in random order from 1 to 1,000,000 but a single number is
missing, figure out what number is missing.
Source: http://blog.moertel.com/posts/2013-12-14-great-old-timey-game-programming-hack.html#comment-1165807320
// Some bug in the code causes it to crash sometimes.
// Gee, that sure is annoying! Server restarts in a
// clean state, and spams the error log until we go
// in and fix it.
function doSomeShiz(n) {
shiz.expect(n);
for (var i = 0; i < n; i++) {
shiz();
}
@dagon666
dagon666 / Makefile
Created September 21, 2013 21:09
Pure C Arduino generic Makefile
TARGET=blink
SOURCES=blink.c
DEPS=
COBJ=$(SOURCES:.c=.o)
CC=avr-gcc
OBJC=avr-objcopy
MCU=atmega328p
CFLAGS=-I. -Wall -Os -DF_CPU=16000000UL
LDFLAGS=

Oberhamsi's RingoJs benchmark

RingoJs comes with a HTTP Server and basic utilities to deal with JSGI. Unless you are building something very specific, you will want to use packages to ease web development. With this benchmark I try to shed some light on how much those (beta quality) packages for web development degrade RingoJs' performance. The benchmark tasks defined by this benchmark are simple but can give us an upper limit for the performance achievable in real world projects.

I am using the TechEmpower FrameworkBenchmarks. This benchmark tests web development frameworks by running multiple, standardized tasks at varying concurrency levels. The four tasks are outlined in more detail in the results section.

Ringo and friends

I benchmarked Ringo twice to see how a pure JSGI application, written just with the Ringo standard library, performs compared to an application utilizing all the libraries we recommend for convenient web development. Those

@mrdoob
mrdoob / gist:5245098
Created March 26, 2013 12:45
Avoiding huge delta times when switching tabs.
// firefox
document.addEventListener( 'visibilitychange', function ( event ) {
if ( document.hidden === false ) {
lastTime = performance.now();
}
@stephen-james
stephen-james / rasterizeElement.js
Last active December 11, 2015 03:48
A helper script for use with phantomJS (http://phantomjs.org/) similar to rasterize.js allowing you to rasterize elements of a web page by specifying a selector.
/*
rasterizeElement.js
This file is a helper script for use with phantomJS (http://phantomjs.org/) similar to rasterize.js
allowing you to rasterize elements of a web page by specifying a selector.
Author - Stephen James
Twitter - @stephenhjames
GitHub - https://github.com/stephen-james
anonymous
anonymous / ringostar-crash
Created December 22, 2012 18:28
318994962 [class org.jibble.pircbot.InputThread-Thread] INFO ringobot.bot - Disconnected
318994962 [class org.jibble.pircbot.InputThread-Thread] INFO ringobot.bot - Scheduling reconnect
Exception in thread "class org.jibble.pircbot.InputThread-Thread" org.mozilla.javascript.EcmaError: TypeError: Cannot call method "schedule" of null (globals.js#89)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3691)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3669)
at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3697)
at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3716)
at org.mozilla.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:3735)
at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2258)
at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2251)
@isochronous
isochronous / Application.root.js
Last active November 17, 2018 10:13
Root app for drop-in multi-app Marionette framework using requireJS and the subapprouter it works with
define([
"underscore",
"backbone",
"marionette",
"vent"
],
/**
* Creates the primary `Marionette.Application` object that runs the admin framework. Provides a central point
* from which all other sub-applications are started, shown, hidden, and stopped.