Skip to content

Instantly share code, notes, and snippets.

@simonw
simonw / datasette-polar-bears.md
Last active January 17, 2022 21:16
Datasette for Polar Bears
anonymous
anonymous / local.conf
Created October 27, 2017 17:03
Nginx configuration for withKnown on top of mailinabox
# ...
upstream php-fpm {
server unix:/var/run/php5-fpm.sock;
}
#
server {
listen 443 ssl;
listen [::]:443 ssl;
@halberom
halberom / efs_targets.j2
Last active May 18, 2023 10:22
ansible - example of using lookup and a template to generate dynamic list entries for modules
#jinja2:trim_blocks: True, lstrip_blocks: True
targets:
{% for privnet in all_private_subnets %}
- subnet_id: "{{ privnet }}"
security_groups: [ "{{ sg.group_id }}" ]
{% endfor %}
{% for pubnet in all_public_subnets %}
- subnet_id: "{{ pubnet }}"
security_groups: [ "{{ sg.group_id }}" ]
{% endfor %}
@veltman
veltman / README.md
Created September 2, 2017 12:31
SVG animation to video

Converting an SVG animation to a video with the MediaRecorder API and a hidden canvas.

Drawing frames from img elements can introduce an extra delay, so this version generates all the frames upfront and then renders them in a loop with requestAnimationFrame().

See also: Canvas animation to video

@revotu
revotu / remove_attrs.py
Last active January 27, 2024 06:48
remove all HTML attributes with BeautifulSoup except some tags(<a> <img>...)
from bs4 import BeautifulSoup
# remove all attributes
def _remove_all_attrs(soup):
for tag in soup.find_all(True):
tag.attrs = {}
return soup
# remove all attributes except some tags
def _remove_all_attrs_except(soup):
@aurelijusb
aurelijusb / Dockerfile
Last active January 23, 2020 18:20
Code snippets for Minsk PHP Night presentation: Headless browsers and friends
FROM ubuntu:latest
RUN apt-get update && \
apt-get install -y xvfb firefox python-pip xdotool x11vnc
RUN apt-get install -y wget
RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.16.1/geckodriver-v0.16.1-linux64.tar.gz
RUN tar zxvf geckodriver-v0.16.1-linux64.tar.gz && mv geckodriver /usr/bin/geckodriver
ENV DISPLAY=:1.0
@troutcolor
troutcolor / postto-micro.blog.scpt
Last active April 12, 2019 02:10
This is a script for alfred to post to a WordPress, adding the category micro, post format status and as a note. There is no title. I use a hotkey cmd-alt-cnrl-m alfred passes the selected text in the topmost app to the script as q. I don't deal with special chars. Password hard coded is probably not a good idea. Obviously you could edit categor…
on alfred_script(q)
set myBlogUsername to "USERNAME"
set myBlogPass to "PASSWORD"
set cat to {category:{"Micro"}, kind:{"note"}}
set poststrut to {post_type:"post", post_status:"publish", post_format:"status", post_title:"", post_content:q, terms_names:cat, comment_status:"open"}
tell application "http://example.com/xmlrpc.php"
set myPosts to call xmlrpc {method name:"wp.newPost", parameters:{"1", myBlogUsername, myBlogPass, poststrut}}
return myPosts
end tell
end alfred_script
@krisselden
krisselden / trace-to-mp4.js
Last active July 4, 2022 23:26
Make an mp4 out of a Chrome DevTools trace with screenshots.
const fs = require('fs');
const path = require('path');
const spawn = require('child_process').spawn;
const FPS = 60;
const MICROSEC_PER_FRAME = Math.round(1000000 / FPS);
if (process.argv.length < 3) {
console.log(`node ${path.relative('.', process.argv[1])} [DevToolsProfile]`);
process.exit(1);
}
let traceFile = path.resolve(process.argv[2]);
digraph architecture {
rankdir=LR;
// Storage - #303F9F (dark blue)
node[fillcolor="#303F9F" style="filled" fontcolor="white"];
database[label="DB"]; cache[label="Redis"];
// Client-side Apps - #FFEB3B (yellow)
node[fillcolor="#FFEB3B" style="filled" fontcolor="black"];
front_end[label="Front-end App"]; extension[label="Browser Extension"];
@davidrleonard
davidrleonard / execAsync.js
Last active November 29, 2022 03:42
Node exec async (with shell.js and bluebird)
const Promise = require('bluebird');
const sh = require('shelljs');
/**
* Asynchronously executes a shell command and returns a promise that resolves
* with the result.
*
* The `opts` object will be passed to shelljs's `exec()` and then to Node's native
* `child_process.exec()`. The most commonly used opts properties are:
*