Skip to content

Instantly share code, notes, and snippets.

View sjelfull's full-sized avatar

Fred Carlsen sjelfull

View GitHub Profile
@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
@sjelfull
sjelfull / Pushover+UptimeRobot.php
Created November 29, 2016 14:54
Use Pushover and a webhook from Uptime Robot to send notifications to your phone
<?php
require __DIR__ . '/vendor/autoload.php';
use Sly\PushOver\Model\Push;
use Sly\PushOver\PushManager;
if (!isset($_GET['key']) || $_GET['key'] !== 'KEY') {
die('No key');
}
$monitorFriendlyName = $_GET['monitorFriendlyName'];
@sjelfull
sjelfull / create-test-order-in-craft-commerce.php
Created October 24, 2016 09:25
Creating test order in Craft Commerce
<?php
public function actionCreateTestOrder ()
{
// Configuration
$customerId = 1;
$productId = 8;
$productQuantity = 5;
$orderStatusId = 1;
$paymentMethodId = 1;
$shippingMethodHandle = 'bring';

Keybase proof

I hereby claim:

  • I am sjelfull on github.
  • I am fredcarlsen (https://keybase.io/fredcarlsen) on keybase.
  • I have a public key ASCXgDizO7fSlSLYrno4ro3h_lPxQJmDv390-gE6TE7qmwo

To claim this, I am signing this object:

@sjelfull
sjelfull / craft-commerce-create-test-order.php
Last active August 1, 2016 11:00
Create a test order in Craft Commerce
<?php
public function actionCreateTestOrder ()
{
// Configuration
// Id of customer for this order
$customerId = 1;
$productId = 8;
$orderStatusId = 1;
$paymentMethodId = 1;
@sjelfull
sjelfull / sm-annotated.html
Created April 25, 2016 15:07 — forked from hdragomir/sm-annotated.html
The deferred font loading logic for Smashing Magazine. http://www.smashingmagazine.com/
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
@sjelfull
sjelfull / set-project-perms.sh
Created April 20, 2016 20:40 — forked from khalwat/set-project-perms.sh
Properly set permissions for a Craft CMS install, including ensuring that files are all g-x. Set CHOWN_USER, CHOWN_GROUP, and BASE_DIR to whatever is appropriate, add directories that need to be writeable by the web server to DIRS[], then execute: ./set-project-perms.sh PROJECT_NAME
#!/bin/bash
# Execute via: ./set-project-perms.sh PROJECT_NAME
# The paradigm is the entire project dir is owned by $CHOWN_USER with the group set to $CHOWN_GROUP
# $CHOWN_USER is an admin or user account that is used to edit files/templates, etc.
# $CHOWN_GROUP is the group of the webserver (e.g.: 'apache', 'nginx', 'httpd', etc.)
# The project dir permissions are set to 755 (-rwxr-xr-x) for directories and to 644 (-rw-r--r--) for files
# The permissions to $DIRS[] that need to be writeable are set to 775 (-rwxrwxr-x) for directories and
# 664 (-rw-rw-r--) for files. Add any assets directories, etc. as necessary.
# Change $BASE_DIR to the absolute path where your websites are stored (leaving it appended with '/$1')
@sjelfull
sjelfull / latency.markdown
Created February 9, 2016 11:46 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@sjelfull
sjelfull / zip.php
Created January 6, 2016 13:02 — forked from jonmaim/zip.php
PHP script to remotely create zip archives of your FTP
<?php
/*
*
* This script will backup your web site by remotely archiving all files on the root FTP directory.
* It will work even if your web server is memory limited buy splitting zips in several arhive files it they are too many files.
* All zip files will be stored in a directory called temporary which must be writable.
*
* How to use it:
* - Place the script at the root of your FTP.
@sjelfull
sjelfull / pthreads.md
Created November 15, 2015 23:52 — forked from krakjoe/pthreads.md
pthreads.md

Multi-Threading in PHP with pthreads

A Brief Introduction to Multi-Threading in PHP

  • Foreword
  • Execution
  • Sharing
  • Synchronization
  • Pitfalls