Skip to content

Instantly share code, notes, and snippets.

View jegtnes's full-sized avatar
🤔
thinkin' about them websites

Alex Jegtnes jegtnes

🤔
thinkin' about them websites
View GitHub Profile

Keybase proof

I hereby claim:

  • I am jegtnes on github.
  • I am jegtnes (https://keybase.io/jegtnes) on keybase.
  • I have a public key ASCKHOB0n6Q26jdAWmdre4m72ud1r0B4JEQ_FBMyRETwowo

To claim this, I am signing this object:

#!/bin/bash
mocha_skip_found=`git grep -e ".only" --or -e ".skip" HEAD`
if [ "$mocha_skip_found" ]
then
commit=`git log --pretty=format:'%Cred%h%Creset %s' -G "(.only|.skip)" | head -n1`
echo "Found Mocha test suite skip. This change was last introduced in:"
echo $commit
echo "Not pushing. (override with the --no-verify flag)"
@jegtnes
jegtnes / Gulpfile.js
Created June 1, 2014 10:43
The Gulpfile I created for the blogpost http://jegtnes.co.uk/blog/using-gulp-with-uncss-in-ghost-for-tiny-assets/, detailing how to use UnCSS and Gulp for Ghost.
var gulp = require('gulp');
var sass = require('gulp-sass'); // skip this if you're working with vanilla CSS
var rename = require('gulp-rename');
var cmq = require('gulp-combine-media-queries');
var uncss = require('gulp-uncss');
var download = require('download');
var cssmin = require('gulp-cssmin');
var clean = require('gulp-clean');
var xml2js = require('gulp-xml2js');
@jegtnes
jegtnes / greentored.scss
Last active August 29, 2015 14:01
A SCSS function generating 100 classes from green to red.
$i: 0;
$color: rgb(0, 255, 0);
@while $i < 100 {
$i: $i + 1;
.color-#{$i} {
color: $color;
}
$color: adjust-color($color, $red: 2.55, $green: -2.55);
}
@jegtnes
jegtnes / Antiviral
Last active January 6, 2017 05:33
A list of Tweetbot mute filters for "viral" clickbaity headlines to reduce the amount of pageview-farming crap listicles you get exposed to on the internet these days. Inspired by @snipe's Downworthy: http://downworthy.snipe.net/ — if only Tweetbot supported regex replace…
Listicles:
(?i)(([0-9]{1,3})|three|four|five|six|seven|eight|nine|ten|eleven|twelve|twenty|eigh|thir|four|fif|six|seven|eight|nine)(teen|ty)?( (more|extra))? (reasons?|weird|things?|gifs?|spectacular|fantastic|tips|pieces|confessions|awesome|ludicrous|incredible|stages|movies?|films?|crazy|epic|easy|outrageous(ly)?|hilarous(ly)?|scar(y|iest)|\bof the\b|ways?|signs?|life ?(hacks?)|tweets|impossibl(e|ly)|productiv(e|ivity)|quotes|apps|best|simple)
Hyperbole:
(?i)what happen(s|ed) next
(?i)((won|can)'t|(will|can) ?not) believe
(?i)faith in humanity
(?i)can('|no)?t (even )?handle
(?i)viral
(?i)(life|work(place)?|office) hacks?
@jegtnes
jegtnes / sass_colorfunctions.php
Created June 6, 2013 08:43
A function attempting to rudimentary replicate SASS lighten/darken functions. Adapted from Frxstrem's answer on StackOverflow: http://stackoverflow.com/questions/3512311/how-to-generate-lighter-darker-color-with-php
<?php
function sass_darken($hex, $percent) {
preg_match('/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i', $hex, $primary_colors);
str_replace('%', '', $percent);
$color = "#";
for($i = 1; $i <= 3; $i++) {
$primary_colors[$i] = hexdec($primary_colors[$i]);
$primary_colors[$i] = round($primary_colors[$i] * (100-($percent*2))/100);
$color .= str_pad(dechex($primary_colors[$i]), 2, '0', STR_PAD_LEFT);
}
@jegtnes
jegtnes / wp_deploy.sql
Last active December 15, 2015 02:29
A short database query to run after transferring a WordPress database to a different environment. From local to stage, stage to production, etc. Remember to change the name of the table if you've set a custom prefix.
UPDATE wp_options SET option_value = replace(option_value, 'http://local.dev', 'http://stage.project.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://local.dev', 'http://stage.project.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://local.dev', 'http://stage.project.com');
@jegtnes
jegtnes / gist:5123868
Created March 9, 2013 11:11
Example of filtering by multiple categories and tags with a custom WP Query
<?php
$categories = $_GET( 'categories' );
$tags = $_GET( 'tags' );
$query = new WP_Query(
array( 'cat' => $categories ),
array( 'tags' => $tags )
);
while ( $query->have_posts() ) :
@jegtnes
jegtnes / bg-color>bg-image.css
Created June 15, 2012 16:27
:after hack to apply background-color above background-image without extra markup
header:after {
background-color: rgba(0, 0, 0, 0.3);
content: "";
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
z-index: -1;
}