Skip to content

Instantly share code, notes, and snippets.

@Made-of-Clay
Made-of-Clay / array_combine.js
Created December 19, 2017 22:01
Recreating PHP's array_combine function; generates a map/object literal from two arrays
/**
* This function mimics PHP's array_combine function
* @param {array} keys Array to be used as new object's keys
* @param {array} values Array to be mapped to respective keys
* @example
* array_combine(['Rick', 'Morty'], ['Sanchez', 'Smith']); // returns { Rick:'Smith', Morty:'Smith' }
*/
function array_combine(keys, values) {
let obj = {};
keys.forEach((k, i) => obj[k] = values[i]);
@Made-of-Clay
Made-of-Clay / pubsub-simple.js
Last active July 12, 2023 13:26 — forked from fatihacet/pubsub-simple.js
Simple PubSub implementation with JavaScript - taken from Addy Osmani's design patterns book & ESM-ified
let topics = {}, subUid = -1;
// https://gist.github.com/fatihacet/1290216
export default {
subscribe(topic, func) {
if (!topics[topic]) {
topics[topic] = [];
}
let token = (++subUid).toString();
topics[topic].push({
token,
@Made-of-Clay
Made-of-Clay / datatables-1.10-param-convert-map.json
Last active October 18, 2016 14:39
Datatables parameter conversion map for converting Hungarian (1.9-) to camelCase (1.10+)
{
"__note": "keys with value of 'null' have been removed",
"aaData" : "data",
"aaSorting" : "order",
"aaSortingFixed" : "orderFixed",
"aDataSort" : "columns.orderData",
"aLengthMenu" : "lengthMenu",
"aTargets" : "columnDefs.targets",
"aoColumns" : "columns",
"aoColumnDefs" : "columnDefs",
@Made-of-Clay
Made-of-Clay / Draggable.js
Created December 9, 2015 13:44 — forked from Rob-ot/Draggable.js
Draggable and dropable views for backbone, uses html5 drag and drop api, requires jquery and underscore, not tested in IE yet
return View.extend({
initialize: function () {
this.el.attr("draggable", "true")
this.el.bind("dragstart", _.bind(this._dragStartEvent, this))
},
_dragStartEvent: function (e) {
var data
if (e.originalEvent) e = e.originalEvent
e.dataTransfer.effectAllowed = "copy" // default to copy
/*----- Before Minit -----*/
/* line 12, sassy_s/_theme.scss */
body {
background: url("http://domain.com/_subdir_/wp-content/themes/_themename_/images/header_graphic_fin.png") repeat-x transparent;
}
/*------ After Minit -----*/
/* line 12, sassy_s/_theme.scss */
body {
background: url('http://domain.com/_subdir_/wp-content/themes/_themename_//_subdir_/wp-content/themes/_themename_/images/header_graphic_fin.png') repeat-x transparent;