Skip to content

Instantly share code, notes, and snippets.

@dabit3
dabit3 / App.js
Created March 20, 2020 19:47
Expo + Amplify DataStore App
import Amplify from '@aws-amplify/core'
import config from './aws-exports'
Amplify.configure(config)
import React, { useState, useEffect } from 'react'
import { Text, View, TextInput, Button } from 'react-native'
import { DataStore } from '@aws-amplify/datastore'
import { Message} from './src/models'
const initialState = { color: 'black', title: '' }
@pseudosavant
pseudosavant / canvasToObjectUrl.js
Last active November 19, 2023 17:14
async method for creating an object URL from a canvas
const canvasToBlobUrl = (() => {
const canvasToBlobURL = (canvas, type='image/webp', option=0.1) => {
const promise = new Promise(async (resolve) => {
await rAF();
const blob = await canvasToBlob(canvas);
resolve(URL.createObjectURL(blob, type, option));
});
return promise;
}
@EricTendian
EricTendian / email-over-curl.sh
Created February 17, 2020 22:11
Sending an HTML email with curl over SMTP
#!/bin/bash
cat << EOF > email.eml
From: "${MAIL_FROM_NAME}" <${MAIL_FROM_ADDRESS}>
To: "${MAIL_TO_NAME}" <${MAIL_TO_ADDRESS}>
Reply-To: "${MAIL_TO_NAME}" <${MAIL_TO_ADDRESS}>
Subject: ${MAIL_SUBJECT}
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
@alexellis
alexellis / FAASD_MULTIPASS.md
Last active July 31, 2021 01:50
FAASD_MULTIPASS.md
@tmarshall
tmarshall / lazy-template-literals.js
Last active October 29, 2023 11:21
Lazy javascript template literals
const templatized = (template, vars = {}) => {
const handler = new Function('vars', [
'const tagged = ( ' + Object.keys(vars).join(', ') + ' ) =>',
'`' + template + '`',
'return tagged(...Object.values(vars))'
].join('\n'))
return handler(vars)
}
var kb = require("ble_hid_keyboard");
var services = {
0x180a: {
0x2a50: {
value: [
0x01, /* Use USB Vendor IDs */
0xac, 0x05, /* Apple */
0x5a, 0x02, /* Internal Keyboard */
0x00, 0x00
@rodneyshupe
rodneyshupe / create-sshkey.sh
Created November 3, 2019 21:11
Bash function to create a SSH key and upload to Lastpass using the Lastpass CLI.
# Usage: create-sshkey KEYNAME PASSPHRASE [COMMENT]
# KEYNAME = The file name used for the key.
# PASSPHRASE = The pass phrase to be used. If you wish to not use a passphrase just use a blank string (i.e. "")
# COMMENT = Optional Comment. If skipped the KEYNAME will be used.
#
# Example: create-sshkey my_secret.key "This is my secret passphrase" "An example key."
function create-sshkey() {
KEYNAME=$1
PASSPHRASE=$2
COMMENT=${3:-$KEYNAME}
@jhays
jhays / characteristic.js
Created October 17, 2019 19:05
A sample BLE peripheral service and characteristic for use with Node.js and bleno.
/* characteristic.js
* A simple custom BLE peripheral characteristic for use with Node.js and bleno.
* This characteristic supports read, write, and notify properties.
* Julian Hays - 10/14/19
*/
var util = require('util');
var bleno = require('bleno-mac'); //or 'bleno-mac' if you are using that
var BlenoCharacteristic = bleno.Characteristic;
@oskar456
oskar456 / wgcf.py
Last active September 27, 2025 02:47
Cloudflare WARP linux client (using wg-quick for actual tunnel setup)
#!/usr/bin/env python3
import subprocess
import json
import os
from pathlib import Path
import requests
from requests.compat import urljoin
const bleno = require("@abandonware/bleno");
const CALCULATOR_SERVICE_UUID = "00010000-89BD-43C8-9231-40F6E305F96D";
const ARGUMENT_1_UUID = "00010001-89BD-43C8-9231-40F6E305F96D";
const ARGUMENT_2_UUID = "00010002-89BD-43C8-9231-40F6E305F96D";
const RESULT_UUID = "00010010-89BD-43C8-9231-40F6E305F96D";
class ArgumentCharacteristic extends bleno.Characteristic {
constructor(uuid, name) {
super({