Skip to content

Instantly share code, notes, and snippets.

Avatar

Tom Saleeba tomsaleeba

View GitHub Profile
@cmlenz
cmlenz / babel.config.js
Created Apr 2, 2022
Add babel-plugin-transform-import-meta plugin in test environment only
View babel.config.js
const test = process.env.NODE_ENV === 'test';
module.exports = {
plugins: [
...(test ? ['babel-plugin-transform-import-meta'] : [])
]
};
@hanayashiki
hanayashiki / patch-arrayBuffer.js
Created Dec 16, 2019
Safari 13.0.4: Blob.arrayBuffer is not a function
View patch-arrayBuffer.js
(function () {
File.prototype.arrayBuffer = File.prototype.arrayBuffer || myArrayBuffer;
Blob.prototype.arrayBuffer = Blob.prototype.arrayBuffer || myArrayBuffer;
function myArrayBuffer() {
// this: File or Blob
return new Promise((resolve) => {
let fr = new FileReader();
fr.onload = () => {
resolve(fr.result);
@bittner
bittner / keyboard-keys.md
Created Feb 28, 2019
Keyboard keys markup in MarkDown
View keyboard-keys.md

Ctrl + Alt + Space

@andyrbell
andyrbell / scanner.sh
Last active Sep 23, 2022
Make a pdf look scanned using ImageMagick
View scanner.sh
# use ImageMagick convert
# the order is important. the density argument applies to input.pdf and resize and rotate to output.pdf
convert -density 90 input.pdf -rotate 0.5 -attenuate 0.2 +noise Multiplicative -colorspace Gray output.pdf
@Gomah
Gomah / Dockerfile
Last active Mar 23, 2021
Nuxt.js Dockerfile :: Now.sh
View Dockerfile
FROM node:10-alpine
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json /usr/src/app/
COPY yarn.lock /usr/src/app/
RUN yarn install
View python-argparse-template.py
#!/usr/bin/env python3
"""
The idea here is to have one demo of each common argparse format
type. This is useful for me to be able to copy/paste into a new
script and have something to quickly edit and trim down to get
the functionality I need.
Expect this file to grow/change as I need new options.
This is, however, a working example. I hate examples that don't
@javilobo8
javilobo8 / download-file.js
Last active Sep 23, 2022
Download files with AJAX (axios)
View download-file.js
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
View map-reduce-example.groovy
// Groovy map-reduce example
// declare a closure
def half = { it ->
it / 2
}
// declare another closure
def sum = { result, i ->
result + i
@itod
itod / split_keyboards.md
Last active Sep 27, 2022
Every "split" mechanical keyboard currently being sold that I know of
View split_keyboards.md
@rgl
rgl / wait_for_http_200.sh
Last active Sep 15, 2022
Wait for an HTTP endpoint to return 200 OK with Bash and curl
View wait_for_http_200.sh
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9000)" != "200" ]]; do sleep 5; done'
# also check https://gist.github.com/rgl/c2ba64b7e2a5a04d1eb65983995dce76