Skip to content

Instantly share code, notes, and snippets.

View callaginn's full-sized avatar
😎
Coding

Stephen Ginn callaginn

😎
Coding
View GitHub Profile
@rithvikgv
rithvikgv / gist:1916925
Created February 26, 2012 13:53
AppleScript to snap windows to the right à la Windows 7 Aero Snap
-- get Dock height
tell application "System Events" to tell process "Dock"
set dock_dimensions to size in list 1
set dock_height to item 2 of dock_dimensions
end tell
-- get the new width and height for the window
tell application "Finder"
set desktop_dimensions to bounds of window of desktop
set new_width to (item 3 of desktop_dimensions) / 2
set new_height to (item 4 of desktop_dimensions) - dock_height
@ofca
ofca / $.3.js
Last active February 20, 2021 13:30
// based on https://gist.github.com/Potfur/5576225 & https://github.com/james2doyle/saltjs
// more info: https://plus.google.com/109231487156400680487/posts/63eZzzrBSb6
window.$ = function(s) {
var c = {
'#': 'ById',
'.': 'sByClassName',
'@': 'sByName',
'=': 'sByTagName'}[s[0]];
return document[c?'getElement'+c:'querySelectorAll'](s.slice(1))
};
@drmalex07
drmalex07 / getopt-example.sh
Last active May 3, 2024 03:03
A small example on Bash getopts. #bash #getopt #getopts
#!/bin/bash
#
# Example using getopt (vs builtin getopts) that can also handle long options.
# Another clean example can be found at:
# http://www.bahmanm.com/blogs/command-line-options-how-to-parse-in-bash-using-getopt
#
aflag=n
bflag=n
@paulirish
paulirish / bling.js
Last active July 3, 2024 20:45
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@chrisjhoughton
chrisjhoughton / enforce-http.liquid.js
Last active February 14, 2024 07:49
How to build an ajax form on Shopify. See http://inside.sauce.ly/how-to-build-an-ajax-login-form-on-shopify/ for the full blog post.
/*
* Ensure the http protocol is always used on the myshopify.com domains.
* Uses liquid to input the correct URL.
*/
if (window.location.href.match(/https:\/\/.*.myshopify.com/) && top === self) {
window.location.href = window.location.href.replace(/https:\/\/.*.myshopify.com/, 'http://{{ shop.domain }}');
}
@jeremypage
jeremypage / check-tls.js
Last active January 31, 2019 10:40
JavaScript: Check TLS level of browser and remove matching domain links from page if browser does not meet minimum requirement
// domains to check
var checkDomains = ['www.foobar.com', 'www.fubar.com'];
// check all links in DOM for matching domain(s)
var matchingLinks = [];
var documentLinks = document.links;
for (var i = 0; i < documentLinks.length; i++) {
if (checkDomains.indexOf(documentLinks[i].hostname) > -1)
matchingLinks.push(documentLinks[i]);
}
@jakerella
jakerella / jkq.js
Last active May 3, 2024 01:49
An ultra-light, jQuery-like micro-library for selecting DOM elements and manipulating them.
(function() {
'use strict';
/**
* Core method, similar to jQuery (only simpler)
*
* @param {String|HTMLElement} s The CSS selector to search for or HTML element to wrap with functionality
* @param {HTMLElement} root OPTIONAL An HTML element to start the element query from
* @return {Array} The collection of elements, wrapped with functionality (see API methods)
*/
@giovanigenerali
giovanigenerali / postfix-gmail-macos.md
Last active December 20, 2021 20:07
Postfix Gmail relay on macOS Sierra & macOSHigh Sierra

Postfix Gmail relay on macOS Sierra & macOSHigh Sierra

1 - Create a file to store our credentials:

sudo vim /etc/postfix/sasl_passwd

2 - Add something like this:

@karlhillx
karlhillx / macos_high_sierra_apache_php_brew_2018.md
Last active June 10, 2024 14:37
macOS High Sierra Setup: Homebrew + Apache + PHP + MariaDB + SSL

macOS High Sierra Setup: Homebrew + Apache + PHP + MariaDB + SSL

Homebrew Installation

First let's install Homebrew.

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

@bcnzer
bcnzer / postman-pre-request.js
Last active July 17, 2024 15:53
Postman pre-request script to automatically get a bearer token from Auth0 and save it for reuse
const echoPostRequest = {
url: 'https://<my url>.auth0.com/oauth/token',
method: 'POST',
header: 'Content-Type:application/json',
body: {
mode: 'application/json',
raw: JSON.stringify(
{
client_id:'<your client ID>',
client_secret:'<your client secret>',