Skip to content

Instantly share code, notes, and snippets.

View nlemoine's full-sized avatar

Nicolas Lemoine nlemoine

View GitHub Profile
@danielpost
danielpost / main.css
Last active October 28, 2018 20:01
Reduce motion on your website if it's enabled by the user (https://css-tricks.com/introduction-reduced-motion-media-query/)
.some-component {
:not(.reduced-motion) & {
animation: animation-name 3s linear infinite;
}
}
@abhishekjairath
abhishekjairath / nodobjc-macOS-notification-listener.js
Created March 12, 2017 06:33
Using 'nodobjc' a nodeJS->ObjectveC bridge to listen to distributed notification centre of macOS/OSX.
var $ = require('nodobjc')
$.framework('Foundation')
$.framework('AppKit')
var GetSongs = $.NSObject.extend('Delegate');
GetSongs.addMethod('getMySongs:', 'v@:@', function(self, _cmd, notif){
var userInfo = notif('userInfo')
var keys = userInfo('keyEnumerator');
'use strict';
var $ = require('nodobjc');
// Load the AppKit framework.
$.framework('AppKit');
// Create delegate that gets notified
var Delegate = $.NSObject.extend('Delegate');
@shanewholloway
shanewholloway / EventLoop.js
Last active May 30, 2017 08:22
Demo applicationDidFinishLaunching using NodObjC EventLoop
/* Cocoa application event loop implementation for NodObjC.
* Code created for https://github.com/TooTallNate/NodObjC/pull/56
* Working as of 2015-Jan-11 on Mac OS 10.10, Node 0.10.35, NodObjC 1.0.0
*
* Copyright (c) 2015, Shane Holloway
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
@sscovil
sscovil / plugin-class-autoloader.php
Last active December 20, 2015 08:09
This class autoloader function eliminates the need to include_once every class file in your WordPress plugin. It adheres to WordPress file naming conventions, so instantiating a class named MyClass would attempt to include_once a file called inc/class-myclass.php.
<?php
/**
* Plugin Name: My Plugin
* Description: A sample plugin with class autoloader, for object-oriented programming.
* Version: 0.1
* Plugin URI: http://shaunscovil.com/
* Author: Shaun Scovil
* Author URI: http://shaunscovil.com/
* License: GPL2
*/
@tomjn
tomjn / custom_page.php
Last active July 3, 2018 11:50
A base class used to create arbitrary content at arbitrary URLs in WordPress without needing a post or listing/archive to host it
<?php
/**
* A helper class to implement arbitrary content at arbitrary URLs without a supporting post or page.
* Inherit from this class and implement the render_page method
*
* @author: Tom J Nowell ww.tomjn.com
* @License: GPL 2+
*/
abstract class Tomjn_Custom_Page {
@jgalea
jgalea / microtime.php
Last active December 7, 2022 01:30
Test execution time of WordPress PHP function
<?php
function my_function() {
$start = microtime(true);
// function code here
$time_taken = microtime(true) - $start;
wp_die( $time_taken ); // in seconds
}
@kwylez
kwylez / gist:5337918
Last active March 2, 2020 06:09
Example implementation of listening for iTunes/Spotify track changes and displaying information in the NotificationCenter. Article reference: http://blog.corywiles.com/now-playing-with-spotify-and-itunes
//
// AppDelegate.m
//
//
// Created by Cory D. Wiles on 10/8/12.
// Copyright (c) 2013 Cory D. Wiles. All rights reserved.
//
#import "AppDelegate.h"
#import "iTunes.h"
@BFTrick
BFTrick / sql-command.sql
Last active April 25, 2022 14:31
A SQL command to delete all orphaned post meta data
DELETE pm
FROM wp_postmeta pm
LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
WHERE wp.ID IS NULL
@harikt
harikt / index.html.php
Created August 4, 2012 14:50 — forked from webmozart/composer.json
Symfony 2.1 stand-alone form usage with PHP templates
<html>
<head>
<title>Standalone Form Component</title>
</head>
<body>
<form action="#" method="post">
<?php echo $view['form']->widget($form); ?>
<input type="submit" />
</form>
</body>