Skip to content

Instantly share code, notes, and snippets.

@airportyh
airportyh / diff.patch
Created Dec 15, 2020
I modified the Python interpreter (ceval.c) to look the state of the stack before each bytecode instruction.
View diff.patch
diff --git a/Python/ceval.c b/Python/ceval.c
index 9de925780e..99ca5d6265 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -144,6 +144,50 @@ is_tstate_valid(PyThreadState *tstate)
}
#endif
+void printObject(PyObject *obj) {
+ PyObject *type = PyObject_Type(obj);
View code.py
def f():
n = 0
while n < 10:
n = n + 1
print("Hello")
@airportyh
airportyh / example.ts
Last active Jun 4, 2020
TypeScript-based store implementation with type inference that works with StrictNullChecks turned on.
View example.ts
import { Store } from "./store";
interface IUser {
username: string;
}
interface IProduct {
name: string;
description?: string;
price: number;
@airportyh
airportyh / test-bug.js
Last active Feb 17, 2020
Test case for suspected reduce bug.
View test-bug.js
// Runtime functions
const $history = [];
let $historyCursor = -1;
let $stack = [];
let $nextHeapId = 1;
let $heap = {};
let $body = $nativeDomToVDom(document.body);
let $heapOfLastDomSync = $heap;
function $pushFrame(funName, variables) {
View year-born.asm
; This program asks the user for their age, and then
; calculates the year that they were born in and prints it out to the user.
SECTION .data
; these are string constants
ask_number db 'How old are you? '
answer db 'So you were born in '
SECTION .bss
; this buffer is used to store the user's input, which are expected to be all digits
View yes_no.asm
section .data
question: db "Are you sure? (y/n)", 10
affirmative: db "Okay, fine.", 10
negative: db "Nevermind, then.", 10
section .bss
input: resb 255
section .text
global _start
View behavior-subject.ts
import { Subject, BehaviorSubject, Observable } from "rxjs";
const subject: Observable<string> = new BehaviorSubject("Hello");
subject.subscribe((value) => {
console.log("1st sub: received value", value);
});
subject.next("How are you doing?");
subject.next("Goodbye");
View .jshintrc
{
"curly": true,
"eqeqeq": true,
"latedef": true,
"unused": true,
"undef": true,
"proto": true,
"debug": true,
"esversion": 6,
View exercises.md

Firebase 1 Exercises

Correction: during our lesson, we saw that the UPDATE verb did not work. This is because UPDATE is not a valid verb in the HTTP protocol: it should have been PUT. Replacing UPDATE with PUT fixed the problem. Which also means my slide was wrong.

You will create a user interface for someone to create and manage a number of Doctor Who TV episodes. The information will be persisted in a Firebase database.

View bower_components.js
This file has been truncated, but you can view the full file.
/*!
* jQuery JavaScript Library v3.1.1
* https://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license