Skip to content

Instantly share code, notes, and snippets.

View dmurawsky's full-sized avatar

Daniel Murawsky dmurawsky

View GitHub Profile
@dmurawsky
dmurawsky / printful.js
Created July 2, 2020 16:14
Place an order for a printful item
const Axios = require('axios')
Axios({
method: 'POST',
headers: {
Authorization: 'Basic thisisyourbase64authtoken',
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
},
data: JSON.stringify({
recipient: {
@dmurawsky
dmurawsky / firebaseTwilioLambda.js
Last active June 13, 2020 20:42
Helper functions for Firebase and Twilio on Lambda
const axios = require("axios");
const client = require("twilio")(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN);
const getDateObj = () => {
const date = new Date();
const hour = date.getHours();
const d = date.getDate();
const m = date.getMonth() + 1;
const y = date.getFullYear();
return { hour, date: `${y}-${m < 10 ? "0" + m : m}-${d < 10 ? "0" + d : d}` };
@dmurawsky
dmurawsky / delete_tags_in_bucket.sh
Created May 22, 2020 17:41
AWS CLI delete all tags in a bucket
# Make sure you have aws installed: https://docs.aws.amazon.com/cli/latest/userguide/install-macos.html
# Make sure you have jq installed: https://github.com/stedolan/jq/wiki/Installation
BUCKET=my-s3-bucket
PREFIX=path/to/objects
PROFILE=default
aws s3api list-objects --bucket $BUCKET --prefix $PREFIX --profile $PROFILE \ # List objects in bucket and prefix
| jq ".Contents" \ # Get the array of ojbects
| jq "map(\"aws s3api delete-object-tagging --profile ${PROFILE} --bucket ${BUCKET} --key \" + .Key)" \ # Create a delete-object-tagging command for each object
@dmurawsky
dmurawsky / bulkImageDownload.js
Created February 3, 2020 17:56
Deno bulk image downloader
// To Run:
// deno run --allow-read --allow-net --allow-write ./bulkImageDownload.ts
const ROOT_URL = 'https://www.example.com/images/';
const imgs = [ 'image1.jpg', 'image2.jpg', 'image3.jpg', 'image4.jpg' ];
const init = () =>
Promise.all(
imgs.map((fileName) =>
fetch(ROOT_URL + fileName).then((resp) => resp.arrayBuffer()).then((buffer) => {
import firebase from "firebase/app";
import "firebase/database";
export const withFirebase = comp => {
comp.componentDidMount = () => {
if (!firebase.apps.length) {
firebase.initializeApp({
apiKey: "",
authDomain: "",
databaseURL: "",
@dmurawsky
dmurawsky / example.md
Last active August 22, 2019 18:57 — forked from gabeklein/example.md
class ActionSequence extends React.Component {
  state={
    remaining = 60,
    surname = "bond"
  }

  componentDidMount(){
    this.timer = 
      setInterval(() => {
@dmurawsky
dmurawsky / now.json
Last active May 16, 2019 16:05
basic next.js server with stripe
{
"version": 2,
"builds": [
{ "src": "api/*.js", "use": "@now/node" },
{ "src": "package.json", "use": "@now/next" }
],
"env": {
"STRIPE_SECRET_KEY": "@acj_stripe_secret_key"
},
"routes": [{ "src": "/blog/(?<name>[^/]+)$", "dest": "/blog?id=$name" }]
@dmurawsky
dmurawsky / next_example.js
Created May 6, 2019 17:56
next.js page example
export default () => (
<div id="wrapper">
<div className="post">
<h1>The Beginning</h1>
<h3>January 1998</h3>
<p>
I was trapped in hell . . . . . a hell of my own making. Two and a half
years prior to this date, I married a man I had no business marrying.
Our relationship should have never evolved past a first date, let alone
progress to marriage. I ignored all of the glaring, neon-flashing red
function isValidDomain(v, opts) {
if (typeof v !== 'string') return false
if (!(opts instanceof Object)) opts = {}
var parts = v.split('.')
if (parts.length <= 1) return false
var tld = parts.pop()
var tldRegex = /^(?:xn--)?[a-zA-Z0-9]+$/gi
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
<link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>materialize</title>
</head>