Combine default parameters and destructuring for a compact version of the defaults / overrides pattern.
function foo ({
bar = 'no',
baz = 'works!'
} = {}) {
{ | |
// Sets the colors used within the text area | |
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme", | |
// Note that the font_face and font_size are overriden in the platform | |
// specific settings file, for example, "Base File (Linux).sublime-settings". | |
// Because of this, setting them here will have no effect: you must set them | |
// in your User File Preferences. | |
"font_face": "Monaco", | |
"font_size": 12, |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); | |
/** | |
* Generic CodeIgniter Database Model - One table version | |
* | |
* Set your Database table and table fields at the top, | |
* and screw creating models for interfacing with one table. | |
* | |
* Disclaimer: I'll answer questions or whatever, but I'm creating | |
* this to speed my own development up. I hope it helps, but it's not supported. |
//return an array of objects according to key, value, or key and value matching | |
function getObjects(obj, key, val) { | |
var objects = []; | |
for (var i in obj) { | |
if (!obj.hasOwnProperty(i)) continue; | |
if (typeof obj[i] == 'object') { | |
objects = objects.concat(getObjects(obj[i], key, val)); | |
} else | |
//if key matches and value matches or if key matches and value is not passed (eliminating the case where key matches but passed value does not) | |
if (i == key && obj[i] == val || i == key && val == '') { // |
<?php | |
/** | |
* @file | |
* Default theme implementation to display the basic html structure of a single | |
* Drupal page. | |
* | |
* Variables: | |
* - $css: An array of CSS files for the current page. | |
* - $language: (object) The language the site is being displayed in. |
<?php | |
/* | |
* Plugin Name: Example Modify Price | |
*/ | |
class Example_Modify_Price { | |
private static $instance; | |
public static function register() { | |
if (self::$instance == null) { |
app.filter('sprintf', function() { | |
function parse(str) { | |
var args = [].slice.call(arguments, 1), | |
i = 0; | |
return str.replace(/%s/g, function() { | |
return args[i++]; | |
}); | |
} |
// This assumes you've already installed Node.js and any related dependencies. | |
// 1. Drop this and package.json into your theme root | |
// 2. Run: npm install | |
// 3. Run: grunt | |
// 4. ?????? | |
// 5. Profit | |
module.exports = function ( grunt ) { | |
grunt.initConfig( { |
#!/usr/bin/env ruby | |
# | |
# CLI tool for locating and removing a Homebrew installation | |
# http://brew.sh/ | |
# | |
# Copyright (C) 2014 Stephen C. Benner | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or |
<script type="text/javascript"> | |
function prepareToDoSomething() { | |
if ( timer ) { | |
clearTimeout( timer ); | |
} |