Skip to content

Instantly share code, notes, and snippets.

View jacmaes's full-sized avatar

Jacques Maes jacmaes

View GitHub Profile
@millipedia
millipedia / calculate_reading_time.php
Last active December 20, 2021 12:23
Processwire hook to calculate article reading time
<?php
/**
*
* Calculate reading time on page save.
* Add this to your ready.php file.
* Uses a field called 'article_read_time' to store the value
* and the field 'page_content' as the readable content.
* You'll need to update those field names if yours are different.
*
@hdragomir
hdragomir / sm-annotated.html
Last active July 27, 2024 15:01
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);
@grandmanitou
grandmanitou / gist:8863248
Created February 7, 2014 14:10
Place multiple markers with infowindow on Google Maps API v3, use external links to trigger click and center map on desired location.
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?language=fra&amp;sensor=false"></script>
<script type="text/javascript">
var map;
var Markers = {};
var infowindow;
var locations = [
[
'Samsung Store Madeleine',
'<strong>Samsung Store Madeleine</strong><p>5 Boulevard Malesherbes, 75008 Paris<br>10h – 20h</p>',
48.8701925,
@davatron5000
davatron5000 / Sublime Text Setup.md
Last active April 15, 2023 15:39
A new user's guide to SublimeText 2. Estimated reading time: 2 mins. Estimated workthrough time: 12 minutes.

Make it useful

  • Install Package Control. For SublimeText 2, paste the following in Terminal:
import urllib2,os; pf='Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler( ))); open( os.path.join( ipp, pf), 'wb' ).write( urllib2.urlopen( 'http://sublime.wbond.net/' +pf.replace( ' ','%20' )).read()); print( 'Please restart Sublime Text to finish installation')

From here on out, use Package Control to install everything. +Shift+P, then type Install to get a list of installable packages you can 'livesearch through. After installing plugins, they should be running.

@Da-Fecto
Da-Fecto / RepeaterTable.module
Last active December 22, 2015 15:38
create table from repeater
<?php
class RepeaterTable extends WireData implements Module {
public static function getModuleInfo() {
return array(
'title' => 'RepeaterTable',
'version' => 100,
'summary' => 'RepeaterTable',
'singular' => false,
@toddmotto
toddmotto / gist:5477991
Created April 28, 2013 18:56
Center Google Maps Marker positioning on window.resize
google.maps.event.addDomListener(window, 'resize', function() {
var center = map.getCenter()
google.maps.event.trigger(map, "resize")
map.setCenter(center)
})
@somatonic
somatonic / upload_images_to_page_form.php
Created November 26, 2012 22:08
Upload Images to new created Page Form Example
<?php
// front-end form example with multiple images upload
// add new page created on the fly and adding images
$message = '';
if($input->post->submit){
// tmp upload folder for additional security
@angrycat
angrycat / PW2 tree.php
Created June 19, 2012 11:15
ProcessWire Build tree for navigation
<?php
define("n","\n");
define("br","<br />");
function buildTopMenu($pages, &$depth, $selector='', $maxDepth=2) {
global $active;
$out = '';
if($depth <= $maxDepth && $pages->getTotal() > 0) {
$depth++;
$out .= "<ul class='depth-{$depth}'>".n;
foreach($pages as $p) {
@adactio
adactio / mediaquerycolums.html
Created January 12, 2012 16:55
Multiple columns dependent on media queries that test for height as well as width.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Media Query Multiple Columns</title>
<meta name="viewport" content="width=device-width, intial-scale=1">
<style>
@media all and (min-width: 40em) and (min-height: 36em) {
[role="main"] {
-webkit-column-count: 2;
@formmailer
formmailer / breadcrumbs.php
Created November 15, 2011 08:44
This is a general way to create breadcrumbs for ProcessWire pages. It retreives in an array all the parents and will walk through the array to display the title and URL of the parents. The last echo returns the title of the current page, without a link.
<?
/*Breadcrumbs
=====================
This is a general way to create breadcrumbs for ProcessWire pages.
It retreives in an array all the parents and will walk through the array to display the title and URL of the parents.
The last echo returns the title of the current page, without a link.
=====================*/
?>
<div id="breadcrumbs">