Skip to content

Instantly share code, notes, and snippets.

View pkrumins's full-sized avatar

Peter Krumins pkrumins

View GitHub Profile
module.exports = Prompt;
function Prompt(question, cb) {
if (!(this instanceof Prompt)) return new Prompt(question, cb);
if ((question && cb) !== undefined) prompt(question, cb);
var self = this;
var vars = {};
var queue = [];
self.ask = function (question, into) {
pkrumins@stackvm:~/projects/stackvm$ rm data/*db
pkrumins@stackvm:~/projects/stackvm$ node server.js
9 Oct 00:59:37 - socket.io ready - accepting connections
StackVM running at http://localhost:9000
^C
pkrumins@stackvm:~/projects/stackvm$ node server.js
9 Oct 01:00:11 - socket.io ready - accepting connections
StackVM running at http://localhost:9000
^C
pkrumins@stackvm:~/projects/stackvm$ node server.js
pkrumins@stackvm:~/projects/node-lazy$ cat tests/filter.js
var Lazy = require('lazy');
var EventEmitter = require('events').EventEmitter;
function range(i, j) {
var r = [];
for (;i<j;i++) r.push(i);
return r;
}
import Prelude hiding (catch)
import System (getArgs)
import System.IO (hPutStrLn, hSetBuffering, BufferMode(NoBuffering), hClose, Handle)
import System.IO.Error (isEOFError, IOError(..))
import Network (connectTo, PortID(..), withSocketsDo)
import Control.Concurrent (forkIO, threadDelay)
import Control.Exception
delay :: Int
delay = 60
// server.js
var dnode = require('dnode');
function Manager () {
var desktops = {};
var self = this;
this.spawn = function (name) {
var $ = require('jquery-browserify');
$(window).ready(function () {
if (!window.navigator.userAgent.match(/chrome|chromium/i)) {
$('<div>')
.addClass('alert')
.append(
$('<img>').attr('src', '/img/chrome.png'),
$('<div>').text(
"You don't appear to be using chrome, "
#include <windows.h>
#include <cstdio>
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow) {
while (1) {
HWND dialog = FindWindow("MozillaDialogClass", "FireFox Update");
if (dialog) {
printf("Found dialog: %x\n", dialog);
HWND dialogItem = NULL;
SendMessage(dialog, WM_CLOSE, 0, 0);
@pkrumins
pkrumins / getusername
Created November 16, 2010 00:06
GetUserName windows api call via haskell's FFI!
{-# LANGUAGE ForeignFunctionInterface #-}
import System.Win32.Types
import Foreign
import Foreign.C
foreign import stdcall unsafe "windows.h GetUserNameW"
c_GetUserName :: LPTSTR -> LPDWORD -> IO Bool
getUserName :: IO String
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pkrumins
pkrumins / nylki-lindenmayer-browser.js
Created June 20, 2019 20:28
nylki/lindenmayer library that works in IE
/* This is a modified version of https://github.com/nylki/lindenmayer.
** The modifications make it work in Internet Explorer again.
** The modifications include:
** * Replacing `let` with `var`.
** * Replacing `{ x }` with `{ x : x }` in object context.
** * Replacing `class` with `function.
** * Replacing `{ arg1, arg2, }` with `opts` in function definition context.
** * Replacing `x of obj` with a `for (var i = 0; i < obj.length; i++)`
** * Replacing default arguments with `if (arg === undefined) { arg = defaultVal; }`
** * Replacing `array.push(...obj)` with `array.extend(obj)`.