Skip to content

Instantly share code, notes, and snippets.

View gavi's full-sized avatar
🎯
Focusing

Gavi Narra gavi

🎯
Focusing
View GitHub Profile
@kiichi
kiichi / SpeechRecognizerExample.java
Created April 12, 2016 03:44
Speech Recognizer Android Example. I removed unrelated part of codes so it would not run if you just copy and paste it.
// Ommitted ...
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
SpeechRecognizer mSpeech = null;
Intent mIntent;
@Override
protected void onCreate(Bundle savedInstanceState) {
@andymatuschak
andymatuschak / States-v3.md
Last active June 12, 2024 04:17
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

@nenodias
nenodias / report_header_example.py
Last active December 20, 2023 13:38
Reportlab example with header
import pdb
from io import BytesIO
from reportlab.lib.pagesizes import letter, A4
from reportlab.platypus import SimpleDocTemplate, Paragraph
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER
from reportlab.lib.units import inch
from reportlab.pdfgen import canvas
from reportlab.lib.units import mm
from reportlab.pdfbase.pdfmetrics import registerFont
@andy-thomason
andy-thomason / Genomics_A_Programmers_Guide.md
Created May 14, 2019 13:32
Genomics a programmers introduction

Genomics - A programmer's guide.

Andy Thomason is a Senior Programmer at Genomics PLC. He has been witing graphics systems, games and compilers since the '70s and specialises in code performance.

https://www.genomicsplc.com

@insidegui
insidegui / PlatformViewRepresentable.swift
Created August 10, 2022 18:13
Protocol that automatically adds UIViewRepresentable or NSViewRepresentable conformance to implementers according to the current platform
import SwiftUI
#if os(iOS) || os(tvOS)
public typealias PlatformView = UIView
public typealias PlatformViewRepresentable = UIViewRepresentable
#elseif os(macOS)
public typealias PlatformView = NSView
public typealias PlatformViewRepresentable = NSViewRepresentable
#endif
@rain-1
rain-1 / LLM.md
Last active July 27, 2024 04:02
LLM Introduction: Learn Language Models

Purpose

Bootstrap knowledge of LLMs ASAP. With a bias/focus to GPT.

Avoid being a link dump. Try to provide only valuable well tuned information.

Prelude

Neural network links before starting with transformers.

@OrionReed
OrionReed / dom3d.js
Last active July 28, 2024 16:59
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯