Skip to content

Instantly share code, notes, and snippets.

View kurtschlatzer's full-sized avatar

Kurt Schlatzer kurtschlatzer

View GitHub Profile
@nepsilon
nepsilon / comm-cli-tip.md
Last active February 19, 2017 13:31
CLI: Output the difference between 2 files — First published on fullweb.io issue #43

CLI: Output the difference between 2 files

Thinking of using diff? Try comm, its sole purpose is to compare 2 sorted files line by line.

Show lines in A.txt but NOT in B.txt:

comm -2 -3 A.txt B.txt

If the files aren’t sorted, use:

@nepsilon
nepsilon / bash-remove-spaces-in-filename.md
Last active March 9, 2023 12:30
How to remove spaces in filenames and lowercasing — First published in fullweb.io issue #20

How to remove spaces in filename and lowercasing

A short script this week to replace spaces in filenames in a given folder:

# Looping over files, forging new filename, and then renaming it.
# Spaces will be replaced by underscores (_).
for oldname in * 
do 
 newname=`echo $oldname | sed -e 's/ /_/g'` 
@imjasonh
imjasonh / markdown.css
Last active May 24, 2024 22:56
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;
}
@lukehedger
lukehedger / ffmpeg-compress-mp4
Last active May 28, 2024 16:48
Compress mp4 using FFMPEG
$ ffmpeg -i input.mp4 -vcodec h264 -acodec mp2 output.mp4
@DevinWalker
DevinWalker / woocommerce-optimize-scripts.php
Last active January 8, 2024 13:24
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
@WillsonSmith
WillsonSmith / Swipe.js
Created July 3, 2012 17:19
Swipe Events (on end touch)
(function(){ //Self executing, anonymous function
//Leave out above if including in already existing script
function Swipe(){
var firstX, lastX;
function swipeRight(){
@andrerom
andrerom / responsive_images.htm
Created May 15, 2012 23:22
Responsive image html support proposal
<p>The proposed (but human unreadable) WHATWG syntax:<p>
<pre>
<img src="face-600-200@1.jpg" alt=""
set="face-600-200@1.jpg 600w 200h 1x,
face-600-200@2.jpg 600w 200h 2x,
face-icon.png 200w 200h">
</pre>
<p>The propposed RICG syntax (that WHATWG rejects):</p>
@speier
speier / cssincimages
Created May 4, 2012 14:04
Replace CSS images with inline base64 data
var fs = require('fs');
var path = require('path');
function cssIncImages(cssFile) {
var imgRegex = /url\s?\(['"]?(.*?)(?=['"]?\))/gi;
var css = fs.readFileSync(cssFile, 'utf-8');
while (match = imgRegex.exec(css)) {
var imgPath = path.join(path.dirname(cssFile), match[1]);
try {
var img = fs.readFileSync(imgPath, 'base64');
@cuppster
cuppster / node-express-cors-middleware.js
Created April 9, 2012 16:02
express.js middleware to support CORS pre-flight requests
app.use(express.methodOverride());
// ## CORS middleware
//
// see: http://stackoverflow.com/questions/7067966/how-to-allow-cors-in-express-nodejs
var allowCrossDomain = function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');