Skip to content

Instantly share code, notes, and snippets.

View kajstrom's full-sized avatar

Kaj Ström kajstrom

View GitHub Profile
@kajstrom
kajstrom / webpack3.config.js
Created June 13, 2018 08:02
Webpack 3 to Webpack 4
{
entry: {
pageA: "path/to/pageA_entry.js",
pageB: "path/to/pageB_entry.js",
vendor: "path/to/vendor_entry.js",
},
//.. other configuration not relevant here
plugins: [
@kajstrom
kajstrom / delete.php
Last active December 5, 2019 19:50
Delete an item from an array without a loop if you don't know the index of the item
$items = [1, 2, 3, 4];
$itemToDelete = 3;
$itemsWithout3 = array_values(array_diff($items, [$itemToDelete]));
//$itemsWithout3 => [1, 2, 4]
@kajstrom
kajstrom / quote-word-counts.clj
Created April 25, 2018 08:18
Counting words for quotes in parallel
(ns clojure-noob.meta-exercises
(:gen-class))
(def word-count (atom {}))
(defn set-words [m words]
(reduce (fn [m word]
(if (contains? m word)
(update-in m [word] inc)
(assoc m word 1)))
name := """minimal-scala"""
version := "1.0"
scalaVersion := "2.11.7"
libraryDependencies += "com.typesafe.play" %% "play-json" % "2.5.13"
Backbone.View = (function(View) {
return View.extend({
constructor: function(options) {
this.options = _.defaults(options, _.clone(this.options));
View.apply(this, arguments);
}
});
})(Backbone.View);
<?php
$list = new MyListContainingClass();
$list->add("stuff", "more", "yeah", "woo");
$list->remove("more", "yeah");