Skip to content

Instantly share code, notes, and snippets.

View bnetter's full-sized avatar

Benjamin Netter bnetter

View GitHub Profile
@bendc
bendc / simulate-typing.js
Created September 1, 2017 08:57
Fake typing animation
const trackTime = timing => {
const now = performance.now();
if (!timing.startTime) timing.startTime = now;
const elapsed = now - timing.startTime;
const {duration} = timing;
if (duration != null && duration <= elapsed) timing.startTime = null;
return elapsed;
};
const delay = (callback, duration) => {
@wojteklu
wojteklu / clean_code.md
Last active September 21, 2024 05:38
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@runion
runion / getExpiringDomains.php
Created October 18, 2012 20:14
A CRON job that emails me a list of domains set to expire the next day
<?php
$tomorrow = mktime(0, 0, 0, date("m"), date("d")+1, date("Y"));
$tomorrow_egrep = date('n/j/Y', $tomorrow); # like "10/19/2012" without quotes
$shellCommands= <<<END
rm ~/temp/PoolDeletingDomainsList.zip ~/temp/PoolDeletingDomainsList.txt ~/temp/email_tmp.txt ~/temp/tomorrow.txt;
wget http://www.pool.com/Downloads/PoolDeletingDomainsList.zip -O ~/temp/PoolDeletingDomainsList.zip -q;
unzip -o ~/temp/PoolDeletingDomainsList.zip -d ~/temp/;
egrep -e "{$tomorrow_egrep}" ~/temp/PoolDeletingDomainsList.txt > ~/temp/tomorrow.txt;