This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myArray = [{name: "terry", id: 1}, {name: "terry", id: 2}, {name: "john", id: 3}] | |
// Reduce + Filter | |
myArray.reduce( ( acc, cur ) => [ | |
...acc.filter( ( obj ) => obj.name !== cur.name ), cur | |
], [] ); | |
// Acc builds up, but starts off small so more manageable. | |
// Reduce + Find |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<label class="label" for="postcodeInput">Postcode</label> | |
<div class="field has-addons"> | |
<div class="control is-expanded"> | |
<input id="postcodeInput" class="input" type="text" placeholder="E8 1BQ" value="sw15 2pw"> | |
</div> | |
<div class="control"> | |
<a id="submit" class="button is-primary">Go</a> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var submit = document.getElementById('submit') | |
var input = document.getElementById('postcodeInput') | |
var results = document.getElementById('results') | |
var stores = [ | |
{ | |
name: 'The Good Wine Shop', | |
lat: 51.4934165703256, | |
lng: -0.249506824970951 | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
language: node_js | |
node_js: | |
- stable | |
addons: | |
ssh_known_hosts: xxx.webfaction.com | |
env: | |
global: | |
secure: xxx-DEPLOY_USER-as-encrypted-string-xxx | |
after_success: | |
- npm run coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var createSquareFuncWithAdjustment = function(offset) { | |
return function(val) { return Math.round((val - offset) * 5 / 9); }; | |
}; | |
var fahrenheit = [0, 32, 45, 50, 75, 80, 99, 120]; | |
fahrenheit.map(createSquareFuncWithAdjustment(32)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SearchForm = function(e) { | |
return this instanceof SearchForm ? (this.$el = $(e), | |
void this.$el.on("submit", $.proxy(this.handleSubmit, this))) : new SearchForm(e) | |
}; | |
SearchForm.prototype.handleSubmit = function(e) { | |
e.preventDefault(); | |
var a = $.trim(this.$el.find("#search-input").val()); | |
a && $(document).trigger("search", a) | |
} | |
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
L.WalkingCircleLayer = (L.Layer ? L.Layer : L.Class).extend({ | |
initialize: function() { | |
this._prefix = this._prefixMatch(["webkit", "ms", "Moz", "O"]), | |
this._canvasPadding = 4, | |
this._isActive = !1 | |
}, | |
onAdd: function(t) { | |
var a = L.DomUtil.create("div", "leaflet-control-walkingcircle leaflet-bar leaflet-control"); | |
this._link = L.DomUtil.create("a", "leaflet-bar-part leaflet-bar-part-single", a), | |
this._icon = L.DomUtil.create("span", "fa fa-location-arrow", this._link), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assumes a vertical sprite sheet | |
$icon-size: 18px; | |
.icon { | |
display: inline-block; | |
background-repeat: no-repeat; | |
background-image: url(../images/sprite.png); | |
width: $icon-size; | |
height: $icon-size; | |
background-size: $icon-size; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% for fieldLayoutField in entry.getFieldLayout().getFields() %} | |
{# get the field Model from the fieldId #} | |
{% set field = craft.fields.getFieldById(fieldLayoutField.fieldId) %} | |
{# print the field handle and the field content #} | |
{{ field.handle | inspect }} | |
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# Set outside of block iterator #} | |
{% set number_of_halves = 0 %} | |
{% for block in entry.casestudyModules %} | |
{# Full width block types #} | |
{% if block.type == "slider" %} | |
{% if block.slideImage | length %} | |
{% include 'modules/slider-module' %} | |
{% endif %} |
NewerOlder