Skip to content

Instantly share code, notes, and snippets.

@kongondo
kongondo / menu-builder-getmenuitems-show-more.php
Last active December 17, 2019 12:31
Example Menu Builder 'Show More' Recursive Menu
<?php
/**
* Builds a nested list (menu items) of a single menu.
*
* A recursive function to display nested list of menu items.
*
* @param integer $parent ID of menu item to start build.
* @param WireArray $menu WireArray Object of menu items to display.
* @param integer $first Helper variable to designate first menu item and <ul></ul>.
@kongondo
kongondo / parsce-csv-test.js
Created November 15, 2019 11:12 — forked from atomkirk/parsce-csv-test.js
parse csv with javascript
import parseCsv from 'zipbooks/utils/parse-csv'
import { module, test } from 'qunit'
module('Unit | Utility | parse-csv', function(_hooks) {
test('parses csv successfully', function(assert) {
let result = parseCsv('name,age\nadam,31\ntim,32\n"St, clair",26')
assert.equal(JSON.stringify(result), '[["name","age"],["adam","31"],["tim","32"],["St, clair","26"]]')
})
@kongondo
kongondo / vue.json
Created September 26, 2019 12:03 — forked from rochabianca/vue.json
Snippet to bring back scaffold on vue on vscode. To use it go to Code>Preferences>User Snippets type vue on the input and paste this code there.
{
"bring back the scaffold to vue files": {
"prefix": "scaffold",
"body": [
"<template>",
" <div>$TM_FILENAME_BASE</div>",
"</template>",
"",
"<script>",
"export default {",
@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.