Skip to content

Instantly share code, notes, and snippets.

@shawwn
shawwn / foo
Created November 29, 2018 07:38
foo
#!/usr/bin/env node
// Replace YOUR_API_KEY at the bottom of this file with the key diffbot sends you during signup.
// usage: diffbot-summary <URL>
//
//
// $ diffbot-summary 'https://news.ycombinator.com/item?id=4399108'
// {
// "date": "Fri, 17 Aug 2012 00:00:00 GMT",
//
arc> (prn "" (str (load-table "../laarc/arc/news/story/1")))
{ip: "173.9.192.58" by: "shawn" kids: (339 337 2) time: 1544549800 score: 2 title: "Test post please ignore" type: story keys: (nokill /l/pics) url: "" votes: ((1545796488 "2a02:8109:b6c0:abe8:c047:9fc6:98a5:98ff" "JungleCat" up 1) (1544549800 "173.9.192.58" "shawn" up 0)) text: "" id: 1 sockvotes: 0}
$ python -c 'import feedparser; import sys; import json; args = sys.argv[1:]; d = feedparser.parse(args[0]); print([k for k in d["entries"][0]]); print(json.dumps({"entries": [[[k, x[k]] for k in x if k in ["summary_detail", "links", " published_parsed", "title", "comments", "summary", "title_detail", "link", " published"]] for x in d["entries"]], "feed": [[k, d["feed"][k]] for k in d["feed"] if k in ["title", "subtitle", "links", "image", "subtitle_detail", "language", "title_detail", "link", "ttl"]]}));' "https://news.ycombinator.com/rss" | js-beautify -
['summary_detail', 'links', 'published_parsed', 'title', 'comments', 'summary', 'title_detail', 'link', 'published'] {
"feed": [
["subtitle", "Links for the intellectually curious, ranked by readers."],
["links", [{
"href": "https://news.ycombinator.com/",
"type": "text/html",
"rel": "alternate"
}]],
["title", "Hacker News"],
<Data>
<!--
id: tileset-id
path: path to texture
copy: uses data of the given tileset-id but with the new texture
ignores: list of tiles this tileset doesn't consider solid when doing checks (* for all)
mask:
0: empty
@shawwn
shawwn / configure-ios.sh
Created March 27, 2019 05:40
The configuration script I used to build Node for iOS. Discussion: https://lobste.rs/s/8mimhh/i_got_node_working_on_iphone_thanks_new
#!/bin/bash
# This is the configure-ios script I used to build node for iOS.
# I decided to release this file without cleaning it up in case
# someone was curious what it looks like going from "I've cloned the
# node repository, now what?" to "Wow, apparently node runs on iOS".
# Then I felt bad about releasing it without explaining anything,
# so... it pivoted into an interactive walkthrough from hell. Buckle
V8_WARN_UNUSED_RESULT MaybeHandle<Object> Invoke(Isolate* isolate,
const InvokeParams& params) {
RuntimeCallTimerScope timer(isolate, RuntimeCallCounterId::kInvoke);
DCHECK(!params.receiver->IsJSGlobalObject());
DCHECK_LE(params.argc, FixedArray::kMaxLength);
#ifdef USE_SIMULATOR
// Simulators use separate stacks for C++ and JS. JS stack overflow checks
// are performed whenever a JS function is called. However, it can be the case
// that the C++ stack grows faster than the JS stack, resulting in an overflow
V8_WARN_UNUSED_RESULT MaybeHandle<Object> Invoke(Isolate* isolate,
const InvokeParams& params) {
RuntimeCallTimerScope timer(isolate, RuntimeCallCounterId::kInvoke);
DCHECK(!params.receiver->IsJSGlobalObject());
DCHECK_LE(params.argc, FixedArray::kMaxLength);
#ifdef USE_SIMULATOR
// Simulators use separate stacks for C++ and JS. JS stack overflow checks
// are performed whenever a JS function is called. However, it can be the case
// that the C++ stack grows faster than the JS stack, resulting in an overflow
#include <v8.h>
#include <node.h>
#include <unistd.h>
extern "C" void hello_node(const char* args)
{
char* args1 = (char*)args;
std::vector<char*> arg;
while (*args1 != '\0') {
const SweetieKit = require('sweetiekit');
const {
CGRect,
UIButton,
} = SweetieKit;
async function make(demoVC) {
const w = demoVC.view.frame.width;
const button = new UIButton('👋 Hello Button', {x: 12, y: 80, width: w - 24, height: 50}, () => {