Skip to content

Instantly share code, notes, and snippets.

@kongondo
kongondo / restrict-same-user-session.php
Last active October 1, 2018 12:53
ProcessWire: Restrict logins for users so that one user cannot be loggedin in more than once simultaneously
<?php namespace ProcessWire;
// code goes in ready.php
// Hook into login/logout sessions
wire()->addHookAfter('Session::loginSuccess', null, 'checkLoggedIn');
wire()->addHookBefore('Session::logout', null, 'removeLoggedIn');// Hook before to get $user->id
/**
* Check if a user is already logged in
*
* If user logged in, take an action (notify,logout,etc).
@kongondo
kongondo / processwire_api_visual_studio_code_snippets.json
Last active December 16, 2018 12:23
ProcessWire API Visual Studio Code Snippets
{
"pages->find(\"selector\")": {
"prefix": "pages find(\"selector\")",
"body": [
"\\$${1:pages}->find(\"${2:selector}\");"
],
"description": "Find and return all pages matching the given selector string. Returns a filtered PageArray unless an include mode is specified."
},
"pages->count(\"selector\")": {
"prefix": "pages count(\"selector\")",
@kongondo
kongondo / .block
Created February 25, 2018 00:16 — forked from mbostock/.block
Multi-Series Line Chart
license: gpl-3.0
@kongondo
kongondo / .block
Created February 22, 2018 16:54 — forked from mbostock/.block
Grouped Bar Chart
license: gpl-3.0
@kongondo
kongondo / BarChart.js
Created February 21, 2018 00:04 — forked from ThomasBurleson/BarChart.js
Reusable Chart component for D3 - using prototypes and factories
(function() {
// Based on article @ http://www.toptal.com/d3-js/towards-reusable-d3-js-charts
// Publish a factory method for Chart instances
// @usage:
// var runningChart = BarChart.instanceOf( {barPadding : 2 } );
// var weatherChart = BarChart.instanceOf()
// .fillColor('coral');
window.BarChart = {
@kongondo
kongondo / README.md
Created February 18, 2018 15:20 — forked from robert-moore/README.md
A New Pattern for Updatable D3.js Charts

Using a new updatable chart format. Update functions are made accessible to the caller, handing over chart controls with full functionality to the caller in a modular manner. Data binding is done with method chaining, like any other configuration variable, and can be changed after initialization. This allows for changes to be rendered in the context of chart history, leveraging D3's transitions and update logic.

@kongondo
kongondo / example-recursive-function1a.php
Last active August 30, 2023 08:45
Menu Builder getMenuItems() Examples
<?php
/**
* Builds a nested list (menu items) of a single menu.
*
* A recursive function to display nested list of menu items.
*
* @access private
* @param Int $parent ID of menu item.
* @param Array $menu Object of menu items to display.
@kongondo
kongondo / MimeTypes.php
Created February 19, 2016 18:58 — forked from nimasdj/MimeTypes.php
List of MimeTypes mapped to file extensions
<?php
// I made this array by joining all the following lists + .php extension which is missing in all of them.
// please contribute to this list to make it as accurate and complete as possible.
// https://gist.github.com/plasticbrain/3887245
// http://pastie.org/5668002
// http://pastebin.com/iuTy6K6d
// total: 1223 extensions as of 16 November 2015
$mime_types = array(
'3dm' => array('x-world/x-3dmf'),
'3dmf' => array('x-world/x-3dmf'),
@kongondo
kongondo / remote-file-copy.php
Created January 14, 2016 13:01
Remote file copying with progress reporting in PHP.
<?php
/*
* Remote File Copy PHP Script 2.0.0
*
* Copyright 2012, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
@kongondo
kongondo / Multisite.module.php
Last active August 29, 2015 14:27 — forked from LostKobrakai/Multisite.module.php
Multisite routing for ProcessWire
<?php
// source: https://processwire.com/talk/topic/680-multiple-sites-from-one-install/?p=8778
class Multisite extends WireData implements Module, ConfigurableModule {
public static function getModuleInfo() {
return array(
'title' => 'Multisite',
'version' => 1,