Skip to content

Instantly share code, notes, and snippets.

View alexcarpenter's full-sized avatar
:shipit:

Alex Carpenter alexcarpenter

:shipit:
View GitHub Profile
@mislav
mislav / nginx.conf
Last active December 12, 2024 04:19
SSL nginx configuration for my personal site using Let's Encrypt https://certbot.eff.org/#ubuntutrusty-nginx
# primary HTTPS config
server {
listen 443 ssl;
server_name mislav.net;
ssl_certificate /etc/letsencrypt/live/mislav.net/cert.pem;
ssl_certificate_key /etc/letsencrypt/live/mislav.net/privkey.pem;
root /home/app/blog/_site;
index index.html;
@sjelfull
sjelfull / _lazyFocusImager.twig
Created April 6, 2017 12:51 — forked from hendrikeng/_lazyFocusImager.twig
Twig/Craft macro for lazy responsive images/bgimages with Imager and Focuspoint
{#
// lazyLoaded Image/bgImages, optimized with Imager and Focuspoint
---------------------------------------------------------------------------
https://nystudio107.com/blog/creating-optimized-images-in-craft-cms
https://github.com/aelvan/Imager-Craft
https://github.com/smcyr/Craft-FocusPoint
for the bgImage intrinsic ratio classname creation check:
https://github.com/inuitcss/inuitcss/blob/develop/objects/_objects.ratio.scss
@bendc
bendc / randomInterval.js
Created March 9, 2017 21:55
rAF-based random interval
const randomInterval = (() => {
const random = (min, max) => Math.random() * (max - min) + min;
return (callback, min, max) => {
const time = {
start: performance.now(),
total: random(min, max)
};
const tick = now => {
if (time.total <= now - time.start) {
time.start = now;
@brettburwell
brettburwell / img.html
Last active June 26, 2018 09:05
Craft macro to centralize the markup and config for responsive images
{# ================================================================== #}
{# Responsive Image Macro
{# ================================================================== #}
{#
Macro to centralize the markup and config for responsive images.
Based on an article by Marion Newlevant (@marionnewlevant) and
adapted for the Lazysizes plugin. Read more:
https://straightupcraft.com/articles/responsive-images-with-twig-macros
@srdjan
srdjan / 100+ different counter apps...
Last active May 6, 2024 05:13
100+ different js counter apps...
100+ different js counter apps...
@nfourtythree
nfourtythree / How To Disable Strict SQL Mode in MySQL 5.7.MD
Last active April 29, 2021 09:45
Serverpilot - Disable Strict SQL Mode in MySQL 5.7

How To Disable Strict SQL Mode in MySQL 5.7

I wrote a quick script for those that provision servers often enough.

To get this to work take the following steps

  1. Log into your server as root
  2. Get script wget https://gist.githubusercontent.com/nfourtythree/90fb8ef5eeafdf478f522720314c60bd/raw/disable-strict-mode.sh
  3. Make is executable chmod +x disable-strict-mode.sh
  4. Run the script ./disable-strict-mode.sh
@dgrijuela
dgrijuela / index.html
Created January 12, 2016 15:17
Code for the article How to Make Your Blog Work Offline: https://blog.redradix.com/how-to-make-your-blog-work-offline
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
// Test if service workers are supported
if ('serviceWorker' in navigator) {
@brandondurham
brandondurham / convert_spaces_to_tabs.sublime-macro
Last active March 17, 2020 02:33
Convert indentation from 2 spaces to tabs in Sublime Text
// Convert 2 spaces to tabs in Sublime Text
// To add a key binding, go to "Sublime Text » Preferences » Key Bindings - User" and add the following line:
// { "keys": ["super+;"], "command": "run_macro_file", "args": {"file": "Packages/User/convert_spaces_to_tabs.sublime-macro"} }
// Change the `super+;` shortcut accordingly.
[
{
"args": {
"setting": "tab_size",
"value": 2
@joshuabaker
joshuabaker / general.php
Created July 14, 2015 18:44
CloudFlare compatible config for Craft CMS.
<?php
if (isset($_SERVER['HTTPS']) && (strcasecmp($_SERVER['HTTPS'],'on') === 0 || $_SERVER['HTTPS'] == 1))
{
$protocol = 'https://';
}
else if ( ! empty($_SERVER['HTTP_X_FORWARDED_PROTO']))
{
$protocol = $_SERVER['HTTP_X_FORWARDED_PROTO'] . '://';
}
@wpsmith
wpsmith / get-cookie.js
Created July 5, 2015 21:50
JavaScript: Get Cookie By Name