Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View tarpdalton's full-sized avatar
🍕

James Dalton tarpdalton

🍕
View GitHub Profile
@Badestrand
Badestrand / react-mini.html
Last active January 28, 2024 12:01
Simple React in browser
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style rel="stylesheet" type="text/less">
* {
margin: 0;
padding: 0;
@marcelmeyer
marcelmeyer / audit.api_request().sql
Last active March 14, 2018 17:07
Allows for some logging and debugging of PostgREST requests. All the x-* headers set by the reverse proxy.
create or replace function audit.api_request() returns void
language plpgsql
as $$
declare
_request_id text := coalesce(current_setting('request.header.x-request-id', true),'');
_role text := coalesce(current_setting('request.jwt.claim.role', true),'');
_user_id text := coalesce(current_setting('request.jwt.claim.id', true),'');
_resource text := coalesce(current_setting('request.header.x-path', true),'');
_verb text := coalesce(current_setting('request.header.x-verb', true),'');
@chrisveness
chrisveness / crypto-aes-gcm.js
Last active March 17, 2024 15:36
Uses the SubtleCrypto interface of the Web Cryptography API to encrypt and decrypt text using AES-GCM (AES Galois counter mode).
/**
* Encrypts plaintext using AES-GCM with supplied password, for decryption with aesGcmDecrypt().
* (c) Chris Veness MIT Licence
*
* @param {String} plaintext - Plaintext to be encrypted.
* @param {String} password - Password to use to encrypt plaintext.
* @returns {String} Encrypted ciphertext.
*
* @example
* const ciphertext = await aesGcmEncrypt('my secret text', 'pw');
@Rich-Harris
Rich-Harris / service-workers.md
Last active April 21, 2024 16:24
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@opragel
opragel / tempfix_managedpref_parentalcontrolsd_cpu.sh
Last active January 27, 2018 16:56
tempfix_managedpref_parentalcontrolsd_cpu.sh
#!/bin/bash
# this is not following best practices
# removing explicit familyControlsEnabled keys to mitigate high parentalcontrolsd cpu usage
rm -rf /Library/Managed\ Preferences/com.apple.applicationaccess.new.plist
rm -rf /Library/Managed\ Preferences/*/com.apple.applicationaccess.new.plist
if pgrep 'parentalcontrolsd'; then
killall -STOP parentalcontrolsd
fi
@fernandoaleman
fernandoaleman / fix-libv8-mac.txt
Created May 5, 2016 15:14
Fixing libv8 and therubyracer on Mac
brew tap homebrew/versions
brew install v8-315
gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315
bundle install
@johnulist
johnulist / SPARQL-tests.md
Created April 27, 2016 15:59 — forked from ktk/SPARQL-tests.md
SPARQL performance tests

SPARQL CONSTRUCT comparison

I had some days left on a physical machine we used for an EU FP7 research project so I took the chance to compare 3 triplestores I or my colleagues worked with in the past months. I do not want to imply anything with this test, it's just me playing around and having fun with RDF. If you have any comments, add it here.

Hardware

The test platform comprises a dedicated server, not a virtual machine, with the following specification:

  • 2 x Intel Xeon E5 2620V2, 2 x (6 x 2.10 GHz) (appears as 24 cores in htop)
  • 128 GB buffered ECC RAM
@tmelz
tmelz / pre-commit.sh
Last active April 12, 2023 15:09
auto format java files with google-java-format
#!/bin/bash
# Auto format changed java files using google-java-format.
# To install, copy this file into $repo/.git/hooks and remove the .sh extension.
# Download the google-java-format JAR from
# https://github.com/google/google-java-format
# A more mature implementation of this would be a plugin for Yelp's pre-commit library:
# http://pre-commit.com/
echo "Running auto-formatter for any changed Java files"
echo "(formatting changes will be automatically added to your commit)"
@DocX
DocX / README.md
Last active September 5, 2023 12:58
Connect to bash inside running ECS container by cluster and service name
@georgiana-gligor
georgiana-gligor / osx-pdf-from-markdown.markdown
Last active March 5, 2024 21:09
Markdown source for the "Create PDF files from Markdown sources in OSX" article

Create PDF files from Markdown sources in OSX

When [Markdown][markdown] appeared more than 10 years ago, it aimed to make it easier to express ideas in an easy-to-write plain text format. It offers a simple syntax that takes the writer focus away from the formatting, thus giving her time to focus on the actual content.

The market abunds of editors to be used for help with markdown. After a few attempts, I settled to Sublime and its browser preview plugin, which work great for me and have a small memory footprint to accomplish that. To pass the results around to other people, less technical, a markdown file and a bunch of images is not the best approach, so converting it to a more robust format like PDF seems like a much better choice.

[Pandoc][pandoc] is the swiss-army knife of converting documents between various formats. While being able to deal with heavy-weight formats like docx and epub, we will need it for the more lightweight markdown. To be able to generate PDF files, we need LaTeX. On OSX, the s