Skip to content

Instantly share code, notes, and snippets.

@agzam
agzam / zathura-client.org
Last active May 20, 2022
Open pdf files with Zathura on Mac
View zathura-client.org

Zathura on Mac

I want to open PDF files with Zathura on Mac. Problem is - Zathura does not have a proper App Bundle. So you cannot go in Finder to a pdf file, navigate to ‘Get Info’ and set pdf files to be opened with Zathura.

Luckily, you can create a custom App Bundle that wraps up a script that does that

But that is not as straightforward as you think it is, you can’t just execute a shell script. What if the file already opened with one of the instances of zathura process? Since Zathura is not a native OSX app, it will create a new process instance every time you open it.

The following script opens a file in Zathura, and if it was already opened, it would only activate the right window.

How to use it

View scanned_pdf.sh
#!/bin/bash
# Make a PDF look scanned.
# Extracted from https://github.com/baicunko/scanyourpdf and modified for smaller output files (compression lower density).
INPUT_FILE=$1
/usr/local/bin/convert -density '80' ${INPUT_FILE} -colorspace 'gray' -linear-stretch '3.5%x10%' \
-blur '0x0.5' -attenuate '0.25' +noise Gaussian -rotate 0.5 \
-compress lzw -quality 50 scanned_${INPUT_FILE}
View AppleScript – How can I _get_ UI elements' names, attributes, properties, classes programmatically without “guessing” via AccessibilityInspector?
URL: https://apple.stackexchange.com/questions/340942/applescript-how-can-i-get-ui-elements-names-attributes-properties-classe/
When I started to search for an AppleScript's generic way to "click onto Safari's context menu" of a selected item, there were a lot of questions on "how-to" on several levels of nomenclature.
How can I, without having to use Accessibility Inspector, investigate what "categories" of AppleScript UI elements an application is offering and what additional details AppleScript knows about them?
ANSWER 1:
This is a "study" –an *attempt*– to find pragmatic ways to identify and "use" AS's UI elements:
------------------------------------------------------------------------
@johnhw
johnhw / umap_sparse.py
Last active Dec 1, 2021
1 million prime UMAP layout
View umap_sparse.py
### JHW 2018
import numpy as np
import umap
# This code from the excellent module at:
# https://stackoverflow.com/questions/4643647/fast-prime-factorization-module
import random
@antimatter15
antimatter15 / faketalk.js
Last active Dec 2, 2018
A toy system inspired by realtalk
View faketalk.js
function mouse(_, me, when, claim){
when('fox is out', () => {
claim(me, 'wish', 'labelled', 'squeak')
claim(me, 'wish', 'outlined', 'red')
})
}
function fox(_, me, when, claim){
claim('fox is out')
}
@mfikes
mfikes / README.md
Last active May 17, 2020
Seeing the inferred type of a ClojureScript expression
View README.md

If you are curious about the types inferred by ClojureScript, it is easy to get some insight using a macro:

(defmacro inferred-type [form]
  `'~(cljs.analyzer/infer-tag &env
       (cljs.analyzer/no-warn (cljs.analyzer/analyze &env form))))

This is the kind of dev-time macro you could refer using the new user.cljs feature.

@forresto
forresto / dynamicland-vneck-tshirt.lua
Last active Aug 30, 2018
first shot at dynamicland #softfab
View dynamicland-vneck-tshirt.lua
-- Shirt (#softfab)
Claim (you) has state "waist" with initial value (30).
Claim (you) has state "arm" with initial value (5).
Claim (you) has state "armaround" with initial value (10).
Claim (you) has state "side" with initial value (20).
Claim (you) has state "neck" with initial value (15).
When (you) contains dots /dots/,
(you) has width /width/:
View webrtc.md

WebRTC

WebRTC is a free, open project that provides browsers and mobile applications with Real-Time Communications (RTC) capabilities via simple APIs. It's supported by most major browsers (except Safari).

WebRTC APIs

To acquire and communicate streaming data, WebRTC implements the following APIs:

  • MediaStream: get access to data streams, such as from the user's camera and microphone.
@beesandbombs
beesandbombs / cylWedges.pde
Created Sep 25, 2017
spinning cylinder wedges
View cylWedges.pde
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
if (p < 0.5)
return 0.5 * pow(2*p, g);
View wavingCubes.pde
// gif by dave @beesandbombs :)
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {