Skip to content

Instantly share code, notes, and snippets.

View prestonp's full-sized avatar
😍
you had me at hello world

Preston Pham prestonp

😍
you had me at hello world
View GitHub Profile
@tatsuyasusukida
tatsuyasusukida / !README-javascript-svg-png.md
Last active October 4, 2024 19:04
🌅 How to convert SVG to PNG with JavaScript [video version available]

🌅 How to convert SVG to PNG with JavaScript [video version available]

Video thumbnail: How to convert SVG to PNG with JavaScript

About this article

This article describes how to convert SVG to PNG with frontend JavaScript. The related resources are as follows.

@tayvano
tayvano / gist:6e2d456a9897f55025e25035478a3a50
Created February 19, 2017 05:29
complete list of ffmpeg flags / commands
Originall From: Posted 2015-05-29 http://ubwg.net/b/full-list-of-ffmpeg-flags-and-options
This is the complete list that’s outputted by ffmpeg when running ffmpeg -h full.
usage: ffmpeg [options] [[infile options] -i infile]… {[outfile options] outfile}…
Getting help:
-h — print basic options
-h long — print more options
-h full — print all options (including all format and codec specific options, very long)
@wzulfikar
wzulfikar / docker-ps-vertical
Last active March 14, 2024 13:36
vertical format for docker ps
export FORMAT="ID\t{{.ID}}\nNAME\t{{.Names}}\nIMAGE\t{{.Image}}\nPORTS\t{{.Ports}}\nCOMMAND\t{{.Command}}\nCREATED\t{{.CreatedAt}}\nSTATUS\t{{.Status}}\n"
// usage:
docker ps --format="$FORMAT"
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@prestonp
prestonp / .bash_profile
Last active March 29, 2017 22:32
dynamic emoji shell prompt
emoji() {
emojis=("🍕 " "💩 " "🐶 " "🍣 " "🍔 " "🍪 " "🐳 ")
echo ${emojis[$RANDOM % ${#emojis[@]} ]}
}
set_bash_prompt() {
# Define your prompt formatting here
export PS1="\d \t \u:\w\n$(emoji) "
}
@linhmtran168
linhmtran168 / pre-commit-eslint
Last active June 20, 2024 23:01
Pre-commit hook to check for Javascript using ESLint
#!/bin/sh
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$")
if [[ "$STAGED_FILES" = "" ]]; then
exit 0
fi
PASS=true
@sebz
sebz / grunt-hugo-lunrjs.md
Last active June 28, 2024 18:41
hugo + gruntjs + lunrjs = <3 search
@sebmarkbage
sebmarkbage / Enhance.js
Last active November 7, 2024 13:05
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {

What would it look like if orders used strategies?

Right now, we've got a number of different fields to calculate into our total. We've sort of tangled them together in an unscalable way. Here's how we could define the behavior in a separated way.

models/order.js

module.exports = models.define({
  totalStrategies: []
, attributes: {

Screencapture and animated gifs

I say "animated gif" but in reality I think it's irresponsible to be serving "real" GIF files to people now. You should be serving gfy's, gifv's, webm, mp4s, whatever. They're a fraction of the filesize making it easier for you to deliver high fidelity, full color animation very quickly, especially on bad mobile connections. (But I suppose if you're just doing this for small audiences (like bug reporting), then LICEcap is a good solution).

Capturing (Easy)

  1. Launch quicktime player
  2. do Screen recording

screen shot 2014-10-22 at 11 16 23 am