Skip to content

Instantly share code, notes, and snippets.

@Yimiprod
Yimiprod / difference.js
Last active May 10, 2024 16:49
Deep diff between two object, using lodash
/**
* This code is licensed under the terms of the MIT license
*
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
@gmazzap
gmazzap / Controller.php
Last active April 22, 2024 12:08
WordPress plugin to ease the creation of virtual pages.
<?php
namespace GM\VirtualPages;
/**
* @author Giuseppe Mazzapica <giuseppe.mazzapica@gmail.com>
* @license http://opensource.org/licenses/MIT MIT
*/
class Controller implements ControllerInterface {
private $pages;
@sogko
sogko / app.js
Last active November 8, 2022 12:31
gulp + expressjs + nodemon + browser-sync
'use strict';
// simple express server
var express = require('express');
var app = express();
var router = express.Router();
app.use(express.static('public'));
app.get('/', function(req, res) {
res.sendfile('./public/index.html');
@joshfeck
joshfeck / example-query.php
Last active May 10, 2018 19:27
An example of a query that can be placed into a page template that displays a list of events for Event Espresso 4
<ul class="events">
<?php
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$atts = array(
'paged' => $paged,
'title' => NULL,
'limit' => 100,
'css_class' => NULL,
'show_expired' => FALSE,
'month' => NULL,
@hissy
hissy / gist:7352933
Created November 7, 2013 11:07
[WordPress] Add file to media library programmatically
<?php
$file = '/path/to/file.png';
$filename = basename($file);
$upload_file = wp_upload_bits($filename, null, file_get_contents($file));
if (!$upload_file['error']) {
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_parent' => $parent_post_id,
@terkel
terkel / _decimal.scss
Last active November 23, 2023 18:36
Rounding decimals in Sass
// _decimal.scss | MIT License | gist.github.com/terkel/4373420
// Round a number to specified digits.
//
// @param {Number} $number A number to round
// @param {Number} [$digits:0] Digits to output
// @param {String} [$mode:round] (round|ceil|floor) How to round a number
// @return {Number} A rounded number
// @example
// decimal-round(0.333) => 0
@briangonzalez
briangonzalez / README.md
Created October 21, 2012 04:25
img2boxshadow - a ruby script to convert images to CSS [http://codepen.io/briangonzalez/details/AvrGI#pen-details-tab]

img2boxshadow.rb

a ruby script to convert images to CSS (box-shadows)

Installation

gem install rmagick    # you'll need ImageMagick & Ruby first
gem install colormath
gem install micro-optparse
anonymous
anonymous / gist:2387816
Created April 14, 2012 20:48
Example of using Meteor.methods() and Meteor.call()
if (Meteor.is_client) {
Template.hello.greeting = function () {
return "Welcome to XYZ.";
};
Template.hello.events = {
'click input' : function () {
// template data, if any, is available in 'this'
if (typeof console !== 'undefined')
console.log("You pressed the button");
@jussi-kalliokoski
jussi-kalliokoski / example.js
Created February 6, 2012 16:11
A simple proposal for the interfaces needed for useful MIDI access
// Example usage, a MIDI proxy that picks the first available MIDI input and routes its messages to the first MIDI outputs
navigator.getUserMedia({midi: true}, function (MIDIAccess) {
try {
var input = MIDIAccess.getInput(MIDIAccess.enumerateInputs()[0]);
var output = MIDIAccess.getOutput(MIDIAccess.enumerateInputs()[0]);
} catch (e) {
console.error("Couldn't find suitable MIDI devices");
}
@gre
gre / easing.js
Last active May 17, 2024 03:33
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the COPYING file for more details.
*/
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {