Skip to content

Instantly share code, notes, and snippets.

View dphiffer's full-sized avatar

Dan Phiffer dphiffer

View GitHub Profile
@sts10
sts10 / css-bases.markdown
Last active April 21, 2024 11:42
Simple CSS base files
@tmcw
tmcw / optimization.md
Last active February 14, 2021 14:38
Optimization

Optimization

Correctly prioritizing and targeting performance problems and optimization opportunities is one of the hardest things to master in programming. There are a lot of ways to do it wrong: by prematurely optimizing non-bottlenecks, or preferring fast solutions to clear solutions, or measuring problems incorrectly.

I'll try to summarize what I've learned about doing this right.

First, don't optimize until there's an issue. And issues should be defined as application issues: performance problems that are either detectable by the users (lag) or endanger the platform – i.e. problems that cause downtime, like out-of-memory issues. Until there's an issue, don't think about peformance at all: just solve the problem at hand, which is "creating value for the end-user," or some less-corporate translation of the same.

Second, only optimize with instruments. By instruments, I mean technology that lets you decipher which sub-part of the stack is the bottleneck. Let's say you see slowness around fet

[
{
"begin": "00:00:07",
"end": "00:00:09",
"text": "[metallic clang]"
},
{
"begin": "00:02:30",
"end": "00:02:32",
"text": "[metallic clang]"
@mouse-reeve
mouse-reeve / witches_pi.py
Last active February 28, 2018 20:04
Once Upon a Pi
#!/usr/bin/env python
''' via https://github.com/whoshuu/Projects/blob/master/Numbers/pi.py '''
import math
def once_upon_a_time(and_, in_a_village):
there_was_a_witch = 10 ** 16
who_hid_her_true_nature = float((and_ * there_was_a_witch) // in_a_village) / \
there_was_a_witch
and_the_birds = (int(there_was_a_witch * math.sqrt(who_hid_her_true_nature)) * in_a_village) // \
there_was_a_witch
@nasser
nasser / b64.sh
Created June 4, 2015 19:44
Data-URI dump file
#!/bin/sh
echo "data:"`file --mime-type -b $1`";base64,"
cat $1 | openssl base64
@imjasonh
imjasonh / markdown.css
Last active February 12, 2024 17:18
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@willrstern
willrstern / node-ubuntu-upstart-service.md
Last active August 17, 2023 10:15
Run Node.js App as Ubuntu Upstart Service

###The Issue With Forever Forever is great for running node services, with a minor setback: the word "forever" doesn't apply to system reboots.

###The solution, run node apps as a system service logged in as root

vim /etc/init/node-app.conf

Contents for node-app.conf

@maxfenton
maxfenton / a-new-mac-setup.md
Last active April 17, 2024 10:55
System setup stuff for a new OLD mac (a/o 2020)

New computer setup

a/o 2020-05-29

--

Format the drive

  1. Restart with Cmd-R or Cmd-D
  2. Erase drive / 3x if second-hand
  3. Reinstall MacOS