Skip to content

Instantly share code, notes, and snippets.

View franzheidl's full-sized avatar

Franz Heidl franzheidl

View GitHub Profile
@LettError
LettError / blinkenDraw.py
Last active March 14, 2018 16:38
Toy script for RF3: draw animated pixels in a tiny window, save to gif.
# coding: utf-8
import os
import vanilla
import mojo.canvas
from mojo.UI import PutFile
from random import random
from mojo.drawingTools import *
import drawBot
from AppKit import NSTimer

An example of a simple form

Consider the following markup:

<form class="root" state:theme=dark state:compact>
  <div class="input-area">
    <label for="username" class="label">Username:</label>
    <input id="username" class="input" type="text">
  </div>
@ljharb
ljharb / array_iteration_thoughts.md
Last active April 22, 2024 10:15
Array iteration methods summarized

Array Iteration

https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu

@bendc
bendc / display-fade.html
Created June 22, 2016 03:01
Transitioning the opacity of a hidden element
<!doctype html>
<meta charset="utf-8">
<title>Example</title>
<style>
div {
width: 100px;
height: 100px;
background: black;
animation-duration: .5s;
@typemytype
typemytype / randomColorAppIcon.py
Created May 10, 2016 13:55
add random color to app icon
from AppKit import *
from lib.tools.misc import randomColor
# get the application icon image
icon = NSApp().applicationIconImage()
# get the size
w, h = icon.size()
# make a rect with the size of the image
imageRect = NSMakeRect(0, 0, w, h)
# create a new image with the same size
@joseluisq
joseluisq / terminal-git-branch-name.md
Last active April 20, 2024 02:26
Add Git Branch Name to Terminal Prompt (Linux/Mac)

Add Git Branch Name to Terminal Prompt (Linux/Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@nolanlawson
nolanlawson / protips.js
Last active February 4, 2024 18:06
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@imjasonh
imjasonh / markdown.css
Last active February 12, 2024 17:18
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@typemytype
typemytype / defaultFontInfoChanger.py
Created February 22, 2015 20:40
Change default font info values
from lib.settings import defaultFontInfoAttributes
defaultFontInfoAttributes["descender"] = -200
defaultFontInfoAttributes["ascender"] = 800
@chriseppstein
chriseppstein / _minified_filenaming.md
Last active November 26, 2019 07:40
compiling a minified version of css. This configures your compass project to emit files in minified form when compiling for production.
$ compass compile --environment production && compass compile

Afterwards you will have both the minified and non-minified versions in your output folder. Note that compass clean will not clean up your minified files.