Skip to content

Instantly share code, notes, and snippets.

View eaton's full-sized avatar

Eaton eaton

View GitHub Profile
<?php
$ceiling = 600851475143;
$factor = -1;
for ($i = 1; $i < sqrt($ceiling); $i += 2) {
$factor = getLargestFactor($i);
if ($factor == 1) {
primeList($i);
}
}
@eaton
eaton / gist:3768758
Created September 23, 2012 03:40 — forked from saetia/gist:1623487
Clean Install – Mountain Lion OS X 10.8
#!upstart
description "appname"
author "authorname"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
respawn # restart when job dies
respawn limit 5 60 # give up after 5 respawns in 60 seconds
@eaton
eaton / gist:6976743
Created October 14, 2013 14:40
A brainstorming list of the various ways digital devices can vary in capabilities, interface, etc. Responsive design (today) is primarily concerned with the physical size of the screen, and tentatively exploring the resolution of the screen.
New generations of computing devices are changing the way we interact with digital content. These shifts are usually lumped under the "mobile" banner, but that's just one facet of the new world. Forward-thinking designers, developers, and strategists need to consider all of the following (and more!) when they plan for their users.
Screen (This depends on the physical device, or how it's being used)
- Physical size
- Perceived size
- Resolution
- Responsiveness
- Fidelity
Alternative outputs
@eaton
eaton / gist:7255146
Created October 31, 2013 19:12
dnsmasq setup for local craziness
brew install dnsmasq
mkdir /usr/local/etc
touch /usr/local/etc/dnsmasq.conf
echo "address=/dev/127.0.0.1\n" >> /usr/local/etc/dnsmasq.conf
echo "address=/vm/10.0.0.10\n" >> /usr/local/etc/dnsmasq.conf
sudo cp -fv /usr/local/opt/dnsmasq/*.plist /Library/LaunchDaemons
mkdir /etc/resolver
#!/bin/bash
# Assignment
text=$@
letters=("a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z")
blackletters=("𝔞" "𝔟" "𝔠" "𝔡" "𝔢" "𝔣" "𝔤" "𝔥" "𝔦" "𝔧" "𝔨" "𝔩" "𝔪" "𝔫" "𝔬" "𝔭" "𝔮" "𝔯" "𝔰" "𝔱" "𝔲" "𝔳" "𝔴" "𝔵" "𝔶" "𝔷" "𝔄" "𝔅" "ℭ" "𝔇" "𝔈" "𝔉" "𝔊" "ℌ" "ℑ" "𝔍" "𝔎" "𝔏" "𝔐" "𝔑" "𝔒" "𝔓" "𝔔" "ℜ" "𝔖" "𝔗" "𝔘" "𝔙" "𝔚" "𝔛" "𝔜" "ℨ")
for i in {1..52}; do
text=${text//${letters[$i]}/${blackletters[$i]}}
@eaton
eaton / Craft CMS
Created July 16, 2014 20:19
CMS test run vagrantfiles
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Setting up Craft CMS:
# 0. vagrant-up
# 1. Download the latest from http://buildwithcraft.com
# 2. Uncompress the Craft zip.
# 3. Copy its 'public' and 'craft' directories into the 'www' folder.
# 4. Rename www/public/htaccess to www/public/.htaccess
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Component\Utility\Html;
use \Drupal\node\Entity\Node;
function relater_node_presave(EntityInterface $node) {
if ($node->bundle() == 'my_custom_node') {
$embeds = _relater_get_embeds($node);
$node->field_my_entityref->setValue($embeds);
@eaton
eaton / d8-fieldapi-tricks.txt
Last active September 3, 2019 09:43
Drupal 8 field wrangling
// Check whether a node's bundle has a particular field
if ($node->hasField('field_might_be_missing')) { ... }
// Check field-type-specific empty/not empty logic
if ($node->field_name->isEmpty()) { ... }
// Iterate over individual instances in a field. field_name isn't an actual
// array, but a special iteratable class, so it won't die if the field is empty.
foreach ($node->field_name as $delta => $field_instance) { ... }
@eaton
eaton / reading-list.md
Created July 29, 2020 03:03
In progress collection of reading list about the current bullshit.