Skip to content

Instantly share code, notes, and snippets.

@prantlf
prantlf / jquery.ajaxIntercept.js
Last active July 17, 2020 22:13
Intercepts AJAX calls issued against a base URL and redirect them to other service
// jQuery.ajaxIntercept 0.2.0
// https://gist.github.com/prantlf/316c8dc3b80c3b2a0aad3be2d0d01a86
//
// Copyright (c) 2017 Ferdinand Prantl
// Licensed under the MIT license.
//
// Allows intercepting AJAX calls issued against a base URL
// and either redirect them to some other service, or compose
// the response by a custom asynchronous callback
@prantlf
prantlf / jquery.parseParams.js
Last active September 2, 2018 00:12
Reverses the $.param effect - parses the URL query part into an object
// jQuery.parseParams 0.1.0
// https://gist.github.com/prantlf/061e3911cd450491f84aac40292b7e7c
//
// Copyright (c) 2015-2017 Ferdinand Prantl
// Licensed under the MIT license.
//
// Reverses the $.param effect - parses the URL query part into an object
// with parameter names as keys pointing to parameter values; normalizes
// all parameter names to lower-case and saves multiple parameters with
// the same name to arrays
#!/usr/bin/python
# Credit to frogor for the objc
from Foundation import NSBundle
import json
import objc
import os
import plistlib
import subprocess
@jbelke
jbelke / Mac OSX Setup - Brew
Last active May 2, 2024 05:45
Mac OSX Setup - Brew and Cask
# Get Sudo.
if [ $EUID != 0 ]; then
sudo "$0" "$@"
exit $?
fi
# Install Xcode first - https://itunes.apple.com/us/app/xcode/id497799835?ls=1&mt=12
# Install Xcode command line tools.
xcode-select --install
@DesignByOnyx
DesignByOnyx / JS Comments REGEX - Failing Cases.md
Last active September 21, 2022 03:31
JS Comments REGEX - Failing Cases

This shows use cases where a simple regex like the one on StackOverflow cannot be relied upon for 100% accuracy in detecting comments in code.

Case 1 - comment-like characters within a string:

var foo = "There's no way to tell that this /* is not the beginning of a comment";
var bar = "There's no way to tell that this */ is not the end of a comment";
var baz = "There's no way to tell that this // is not a single line comment";
var buz = "Matters get much worse when there are escaped \" quotes /* inside the string. Definitely need a parser.";
var fiz = `And there is
@nikoskip
nikoskip / gfonts.php
Last active September 20, 2022 21:34
Demo: http://nikoskip.me/gfonts.php | You only have to use the CSS import URL that Google gives you, for instance: http://fonts.googleapis.com/css?family=Cabin:500,700,500italic,700italic
<?php
$fontTypes = array('woff2', 'woff', 'ttf', 'svg', 'eot');
$gFontURL = 'http://fonts.googleapis.com/css?family=';
$uaFonts = array(
'woff2' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36',
'woff' => 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/4.0; GTB7.4; InfoPath.3; SV1; .NET CLR 3.1.76908; WOW64; en-US)',
'ttf' => 'Mozilla/5.0 (Linux; U; Android 2.2.1; en-ca; LG-P505R Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
'svg' => 'Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10',
@prantlf
prantlf / require.config.js
Last active September 2, 2018 00:12
Loads JSON file, parses it to an object and passes it to require.config
// Loads JSON file, parses it to an object and passes it to require.config
//
// https://gist.github.com/prantlf/a7972320307580573eb715ed65e85a2b
// Copyright (c) 2016 Ferdinand Prantl
// Licensed under the MIT license.
//
// If you have a couple of pages and apply the same RequireJS configuration
// on them, you would like to maintain the configuration content at a single
// place. You could put the require.config statement to a script file and
// load it on the page by the script element before your main application
@olih
olih / jq-cheetsheet.md
Last active June 8, 2024 19:39
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@baumandm
baumandm / GIF-Screencast-OSX.md
Last active November 3, 2023 07:18 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to Animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime and ffmpeg.

Forked from https://gist.github.com/dergachev/4627207. Updated to use a palette to improve quality and skip gifsicle.

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@foxxyz
foxxyz / nginx.conf
Last active March 3, 2024 10:42
Serve current directory via nginx
# Extremely basic development setup to serve the current directory at http://localhost:9001
# Start nginx in this directory with `nginx -p . -c nginx.conf`
# Stop nginx with `nginx -p . -s stop`
events {}
http {
# Serve files with correct mimetypes on OSX
# location may have to be adjusted depending on your OS and nginx install
include /usr/local/etc/nginx/mime.types;