Skip to content

Instantly share code, notes, and snippets.

@mfelsche
mfelsche / gist:ef4dd9e104a8127e820b6e4e20c88b2c
Created January 25, 2019 05:04
Setup pony debugging with vscode
The basic steps are here
```
install https://marketplace.visualstudio.com/items?itemName=npruehs.pony <- for syntax colors
install https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb <- for debugging
#vscode settings should have :
"debug.allowBreakpointsEverywhere": true
#(for example ) create an ./examples/.vscode/launch.json file under the pony examples directory with:
{
@mfelsche
mfelsche / known_folders.pony
Created December 28, 2018 21:48
Getting some known folders on windows with Pony
use "debug"
use "lib:shell32" if windows
use "lib:ole32" if windows
primitive KnownFolderIds
"""
Known folder ids as described in:
https://docs.microsoft.com/en-ca/windows/desktop/shell/knownfolderid
functions return the little endian byte values of the folderid GUIDs
@mfelsche
mfelsche / promises_ext.pony
Created December 11, 2018 19:53
first function for promises - returning the first fulfilled value
use "promises"
use "collections"
actor _Selector[A: Any #share]
var _completed: Bool = false
var _outstanding: USize
let _promise: Promise[A]
new create(promise: Promise[A], expected: USize) =>
_promise = promise
@mfelsche
mfelsche / scratch.pony
Created March 26, 2018 07:37
Code to reproduce weird `String.cstring()` behaviour in ponyc
use "net"
use "cli"
use "debug"
actor Main
new create(env: Env) =>
try
let spec = CommandSpec.leaf("damn", "", [
OptionSpec.string("addr",
"The host:port:name to be advertised to other clustering nodes."
@mfelsche
mfelsche / object_ast
Last active December 19, 2017 21:24
pony AST error message for syntax pass on object literal
(class:scope
(id $1$0)
x
ref
(provides (nominal x (id Getter) x x x))
(members
(fvar (id d) (nominal (id $0) (id Bool) x val x x) x)
(fvar (id c) (nominal (id $0) (id Bool) x val x x) x)
(fvar (id b) (nominal (id $0) (id Bool) x val x x) x)
(fvar (id a) (nominal (id $0) (id Bool) x val x x) x)
@mfelsche
mfelsche / buffered-ast.txt
Created July 29, 2017 23:17
incomplete actor ast print
(program:scope
(package:scope
(module:scope
(use x "builtin" x)
(use x "ponytest" x)
(actor:scope
(id Main)
x
tag
(provides (nominal (id $2) (id TestList) x ref x x))
@mfelsche
mfelsche / Dockerfile
Last active June 1, 2017 20:06
Dockerfile installing ponyc deb from bintray repo and llvm-3.9 from http://apt.llvm.org
FROM ubuntu:xenial¬
¬
ENV LLVM_VERSION 3.9.1¬
¬
RUN apt-get update \¬
&& apt-get install -y \¬
apt-transport-https \¬
g++ \¬
@mfelsche
mfelsche / arrays.pony
Last active April 10, 2017 07:11
Array Literal Types in Pony
type MyUnionType is (U32|I32|U8)
actor Main
new create(env: Env) =>
let union_array: Array[MyUnionType] = [
as MyUnionType: U32(1)
I32(-1)
]
actor Main
new create(env: Env) =>
let yep: Array[U32] = [1]
let nope: Array[U32] = [1, 2]
@mfelsche
mfelsche / proxy.pac
Last active August 26, 2016 08:02 — forked from amiorin/proxy.pac
function regExpMatch(url, pattern) {
try { return new RegExp(pattern).test(url); } catch(ex) { return false; }
}
function FindProxyForURL(url, host) {
// Important: replace 172.31 below with the proper prefix for your VPC subnet
if (shExpMatch(url, "*172.31.*")) return "SOCKS5 localhost:8157";
if (shExpMatch(url, "*internal-jenkins-nuggad-*.eu-central-1.elb.amazonaws.com*")) return "SOCKS5 localhost:8157";
if (shExpMatch(url, "*ec2*.amazonaws.com*")) return 'SOCKS5 localhost:8157';
if (shExpMatch(url, "*.compute.internal*") || shExpMatch(url, "*://compute.internal*")) return 'SOCKS5 localhost:8157';