This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sh.mjs: javascript shorthand | |
// array helpers (apl/j/k) | |
export const id=x=>x | |
export const af=(n,x)=>Array(n).fill(x) // TODO: make this 'afl' or 'fil' (aa?) | |
export const ii=(n,f)=>{for(let i=0;i<n;i++)f(i)} | |
export const im=(n,f)=>af(n,0).map((_,i)=>f(i)) | |
export const ia=(n,f)=>im(n,id) | |
export const at=(a,ixs)=>ixs.map(i=>a[i]) | |
export const io=(xs,ys)=>ys.map([].indexOf.bind(xs)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{deck} | |
version:1 | |
card:0 | |
size:[512,342] | |
name:"itemlist.deck" | |
{card:home} | |
{widgets} | |
itemlist1:{"type":"contraption","size":[400,161],"pos":[13,30],"def":"itemlist","widgets":{"label":{},"item_text":{},"items":{},"bnw":{},"bgo":{},"run_event":{},"slider1":{},"bpr":{},"bnx":{},"brm":{},"bup":{},"dn":{}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NB. Core logic for a tiny editor in J. | |
NB. No select/copy/paste (in this gist), but it does support multiple cursors. | |
NB. This started as the code for editing a single line of text, but I'm now | |
NB. using three copies simultaneously: one for a single token, one for | |
NB. boxed tokens on a line, and one for boxed lines in a buffer. | |
coclass 'ed' | |
init =: {{ | |
B =: '' NB. the buffer to edit. | |
C =: 0 NB. cursor position(s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
customElements.define('ts-list', class extends HTMLElement { | |
static observedAttributes = ['ix'] | |
constructor() { super(); this.ix=0 } | |
connectedCallback() { | |
let sh = this.attachShadow({mode: 'open'}) | |
sh.innerHTML=` | |
<slot></slot> | |
<button id="up">^</button> | |
<button id="add">+</button> | |
<button id="dn">v</button>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let set=(o,k,v)=>{let r={...o}; r[k]=v; return r} | |
let gs=k=>(x,y)=> y===undefined ? x[k] : set(y,k,x) | |
let mb=gs('mb'), // match bit | |
ib=gs('ib'), // input buffer | |
ix=gs('ix'), // index into input buffer | |
ch=gs('ch'), // current character (ib[ix]) | |
mk=gs('mk'); // start index of current token | |
let s0=()=>({mb:0,ib:'',ch:'',ix:-1,mk:-1}) | |
on=s=>ix(0,ch(s[0],ib(s,s0()))) | |
m1=s=>mb(1,s) // match |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class { | |
#name : #GsEllipse, | |
#superclass : #GsObject, | |
#instVars : [ | |
'radius', | |
'position' | |
], | |
#category : #GameSketchLib | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{$mode delphi} | |
program pcapdemo; | |
uses pcap, sysutils, crt; | |
procedure throw(msg:string; detail:pchar); | |
begin raise Exception.Create(msg + ': ' + detail) | |
end; | |
function IPv4ToStr(addr:dword) : string; | |
// this probably exists somewhere but i don't know where. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// An IRC bot for the k5 programming language, | |
// using oK from : https://github.com/JohnEarnest/ok | |
"use strict"; | |
var irc = require('irc'); | |
var ok = require('./ok/ok'); | |
const MAXLINES = 8; | |
var client = new irc.Client('irc.freenode.net', 'oK-bot', { | |
channels: ['#jsoftware', '#learnprogramming'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# i wrote this, and it works, but then i decided to just use Godot's own Expression parser. | |
# https://docs.godotengine.org/en/latest/tutorials/scripting/evaluating_expressions.html | |
func _examples(): | |
test('@title["the deck"]') | |
test('@show["jp-editor"; 0]') | |
test('@ed.xy[ 0 5]') | |
func test(cmd:String): | |
if cmd.begins_with('@'): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NB. Code from the "Basic Animation In J" video | |
NB. https://www.youtube.com/watch?v=uL-70fMTVnw | |
NB. ------------------------------------------------------------------------ | |
NB. animation demo | |
load 'viewmat' | |
coinsert'jgl2' | |
wd 'pc w0 closeok' NB. parent control (window) named 'w0' |
NewerOlder