Skip to content

Instantly share code, notes, and snippets.

@tmslnz
tmslnz / gulpfile.js
Last active October 26, 2021 02:30
Complete example gulpfile.js for https://github.com/tmslnz/gulp-shopify-theme
/*
Streamlined Shopify theme development.
NOTE: depends on module gulp-shopify-theme
npm install --save-dev yargs gulp gulp-sass gulp-changed gulp-sourcemaps gulp-autoprefixer gulp-uglify gulp-concat gulp-replace gulp-plumber gulp-babel browser-sync gulp-if del gulp-add-src gulp-rename gulp-yaml gulp-shopify-theme
Highlights:
- https proxying via BrowserSync
@tmslnz
tmslnz / dnsmasq.md
Last active March 20, 2023 07:07
Setting up dnsmasq on OS X

Install dnsmasq

Via brew or other method

Set up DNS resolver order

In order to work on every connection and on any TLD, dnsmasq needs to be the first DNS resolver receving the query.

And since dnsmasq is a local process, all DNS queries need to go to 127.0.0.1

On macOS, /etc/resolv.conf is automaticaly created, depending on a variety of things (network settings, etc), so it cannot be edited.

.*\b((invoice|recei(pts?|ved)|failed|payment|order|sale|authori[zs]ed|sent|statement|confirm(ation|ed)|booking|deliver(y|ed)|complete|transaction|bill|purchased?|account|ready|available|funded|trip)(\b.*?|$)){2}.*
.*\s(order|invoice|receipt|payment|renewal).*((\[|-|number|no|#|id).*[A-Z0-9]+).*
.*\b(amazon|invoice from).*\b(order|apple).*
(*
Speed up Mail.app by vacuuming the Envelope Index
Code from: http://www.hawkwings.net/2007/03/03/scripts-to-automate-the-mailapp-envelope-speed-trick/
Originally by "pmbuko" with modifications by Romulo
Updated by Brett Terpstra 2012
Updated by Mathias Törnblom 2015 to support V3 in El Capitan and still keep backwards compability
*)
tell application "Mail" to quit
set os_version to do shell script "sw_vers -productVersion"
ul li:before {
content: "\2022";
margin-left: -1.2em;
padding-right: 0.6em;
opacity: 0.4;
}
@tmslnz
tmslnz / get-paragraph-from-selection.js
Created August 16, 2015 21:47
Get whole paragraph from text selection
// Discussion here: http://stackoverflow.com/questions/845390/javascript-to-get-paragraph-of-selected-text-in-web-page
var selection = window.getSelection();
var textNode = selection.anchorNode.parentNode;
var text = textNode.innerHTML;
@tmslnz
tmslnz / fancy-underline.less
Last active August 29, 2015 14:27
LESS mixin for nicer, more controllable text underlines
// Fancy Underline
// Creates a nice underline for links using CSS linear gradient
// with control on width, color and distance from baseline
// Inspired by Medium's technique ca. 2015
.fancy-underline ( @color: rgba(0, 0, 0, 0.5), @start: 0.05em, @end: 0.15em ) {
text-decoration: underline;
// Use Modernizr
// http://modernizr.com/download/#-cssgradients-printshiv-cssclasses-prefixes-cssclassprefix:has!
.has-cssgradients & {
text-decoration: none;
@tmslnz
tmslnz / apple-system-font.css
Created July 12, 2015 18:01
Specify Apple System Font in CSS
/* From http://furbo.org/2015/07/09/i-left-my-system-fonts-in-san-francisco/ */
* { font-family: -apple-system-font, HelveticaNeue, LucidaGrande; }
/* Dynamic Type feature */
* { font-family: -apple-system-headline1, HelveticaNeue, LucidaGrande; }
* { font-family: -apple-system-headline2, HelveticaNeue, LucidaGrande; }
* { font-family: -apple-system-body, HelveticaNeue, LucidaGrande; }
* { font-family: -apple-system-subheadline1, HelveticaNeue, LucidaGrande; }
* { font-family: -apple-system-subheadline2, HelveticaNeue, LucidaGrande; }
@tmslnz
tmslnz / ios-refresh.md
Last active August 29, 2015 14:24
How to free space and fully back up iOS
  1. Connect to computer via USB
  2. Backup via iTunes (make sure you choose encrypted backup)
  3. Transfer purchases via iTunes
  4. Ensure iCloud backup for Docs and Data is on for the apps that need their data restored
  5. Force-trigger an iCloud backup (fromthe Settings, on Wi-Fi and connected to power)
  6. Erase all content and Settings on iOS
  7. Connect to iTunes and use Restore from Backup
@tmslnz
tmslnz / node-compile-rpi.sh
Created July 12, 2015 10:49
Compile Node.js on Raspberry Pi
export CC='gcc -O3 -march=armv7-a -mtune=cortex-a8 -mfpu=neon'
export CXX='g++ -O3 -march=armv7-a -mtune=cortex-a8 -mfpu=neon'
./configure --without-snapshot
make -j4
sudo make install