Skip to content

Instantly share code, notes, and snippets.

View jasonhofer's full-sized avatar

Jason Hofer jasonhofer

  • Sarnia, Ontario
View GitHub Profile
@jasonhofer
jasonhofer / classnames.php
Last active July 13, 2018 21:26
PHP port of classnames.js
<?php
/**
* PHP port of https://github.com/JedWatson/classnames
*
* Examples:
* <code>
* classnames('foo', 'bar'); // "foo bar"
* classnames('foo', ['bar' => true]); // "foo bar"
* classnames(['foo-bar' => true]); // "foo-bar"
jQuery.fn.dataBind = function (bindings) {
if (this.length) {
var pairs = [];
for (var name in bindings) {
if (bindings.hasOwnProperty(name)) {
pairs.push(name + ': ' + bindings[name]);
}
}
this.attr('data-bind', pairs.join(', '));
}
<?php
/**
* Show a status bar in the console.
*
* <code>
* for ($x = 1; $x <= 100; ++$x) {
* show_status($x, 100);
* usleep(100000);
* }
* </code>
@jasonhofer
jasonhofer / router.js
Last active April 4, 2019 16:52
CC Certified
import EmberRouter from '@ember/routing/router';
import config from './config/environment';
const Router = EmberRouter.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
@jasonhofer
jasonhofer / CrudRepository.js
Last active October 5, 2021 14:02
Svelte/Sapper project files.
import isEmpty from 'lodash/isEmpty';
/* import isValidObjectId from 'Utils/isValidObjectId'; */
/* import matchByIdOr from 'Utils/matchByIdOr'; */
/**
* Assumes you are using Mongoose.
*/
export default class CrudRepository
{
#ModelClass;