Skip to content

Instantly share code, notes, and snippets.

View pauln's full-sized avatar

Paul Nicholls pauln

  • Christchurch, New Zealand
View GitHub Profile
@pauln
pauln / dabblet.css
Created February 2, 2012 08:35 — forked from anonymous/dabblet.css
Ratings Stars
/*
Ratings Stars
(with as little code as possible)
*/
.rating {
unicode-bidi: bidi-override;
direction: rtl;
text-align: center;
}
.rating > span {
@pauln
pauln / README.md
Created May 5, 2017 00:11
Simple WordPress bulk insert function

Simple WordPress Bulk Insert

A very simple function to perform bulk SQL inserts, since WPDB doesn't provide one directly. The aim is for simplicity - both in the function itself, and in using it - rather than being a massive beast which covers all possible incorrect usage scenarios. Provide it with clean, consistent data, and it should hopefully be able to do what you want without issue.

Notes:

  • Provide a table name and an array of associative arrays of rows to insert
  • Column names are pulled from the first row of data automatically
  • Make sure you provide the same fields in each row (there's no protection for this)
  • Data types (for WPDB placeholders) are auto-detected for each individual value (using is_numeric())
  • There is no protection for exceeding maximum query size (i.e. MySQL's max_allowed_packet); you could pre-batch into smaller "safe" chunks if you need to handle this case - or just find a better way to insert such a large amount of data
@pauln
pauln / README.md
Last active January 25, 2023 18:29
ember-simple-auth oauth2 implicit grant authenticator

oauth2 Implicit Grant authenticator for ember-simple-auth

This is a sample ember-simple-auth authenticator implementation for the oauth2 Implicit Grant which implements "silent reauthentication" (fetching a new token from the IDP via the prompt=none flow). It also uses ember-master-tab to run the refresh process in only a single tab (if the application is open in multiple tabs); at time of writing, it's necessary to use the master branch rather than the version published to npm as it makes use of a recent change to try to recover from the master tab crashing (as opposed to being closed cleanly).

This implementation also expects the token to be a JWT; you may need to adjust the token-related parts if you're not using JWTs.

So how do I use this?

This gist is not a fully developed, drop-in, ready-to-use implementation. It's intended as a starting point for your own implementation, so you'll need to do some work yourself to use it -

@pauln
pauln / controllers.application.js
Last active July 17, 2017 23:50
close-paper-menu
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
doNothing() {
},
doSomething() {
alert("Do something here!");
}
@pauln
pauln / controllers.application.js
Created October 2, 2017 01:22
model-fragments-array-testing
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init() {
this._super(...arguments);
let grandparent = this.get('store').createRecord('grandparent', {
child: {
frags: [
{myArray:[]},
@pauln
pauln / paper-icon-colorful.js
Last active October 18, 2017 20:59
paper-icon-colorful
import Ember from 'ember';
import PaperIcon from 'ember-paper/components/paper-icon';
export default PaperIcon.extend({
attributeBindings: ['aria-label', 'title', 'iconStyle:style', 'iconClass:md-font-icon'],
iconStyle: Ember.computed('sizeStyle', 'color', function() {
let color = this.get('color');
let sizeStyle = this.get('sizeStyle');
let colorStyle = '';
import Ember from 'ember';
const { inject: {service} } = Ember;
export default Ember.Controller.extend({
store: service(),
appName: 'Ember Twiddle',
init() {
this._super(...arguments);
let store = this.get('store');