Skip to content

Instantly share code, notes, and snippets.

View stefanmaric's full-sized avatar
🐿️
ship it

Stefan Maric stefanmaric

🐿️
ship it
View GitHub Profile
@stefanmaric
stefanmaric / btn-pill.less
Last active December 16, 2015 03:21
.btn-pill class in LESS to include with Bootstrap's less files.
// Button styles
// -------------------------
// Pill button variants
.btn.btn-pill {
// border-radius depends on button' height
@border-radius-pill: (@font-size-base * @line-height-base + @padding-base-vertical * 2) / 2;
border-radius: @border-radius-pill;
@stefanmaric
stefanmaric / mostUsed.md
Last active December 21, 2015 19:49
Unicode Characters / Faces / Emoticons

Creepy

ಠ‿ಠ

ಠ⌣ಠ

כּ‗כּ

ó‿ó

@stefanmaric
stefanmaric / gist:8599834
Created January 24, 2014 15:45
Fix for Atheros AR5005G unstable wireless connection issue in Linux - AR2413/AR2414

Ethernet controller: Atheros Communications Inc. AR2413/AR2414 Wireless Network Adapter [AR5005G(S) 802.11bg]

Test & try:

sudo rmmod ath5k
@stefanmaric
stefanmaric / areEquivalents.js
Last active September 2, 2016 03:15
Recursive areEquivalents function.
function areEquivalents (a, b) {
if (a && b && typeof a === 'object' && typeof a === typeof b && a.length === b.length) {
for (var prop in a) {
if (a.hasOwnProperty(prop) && !areEquivalents(a[prop], b[prop])) {
return false
}
}
for (var prop in b) {
if (b.hasOwnProperty(prop) && !areEquivalents(b[prop], a[prop])) {
return false
@stefanmaric
stefanmaric / deep-diff-angular.js
Last active September 2, 2016 03:22
Deep (recursive) diff function implementation in Angular, lodash and ES6 / ES2015.
function deepDiffRight (left, right) {
// if they are equals, return undefined
if (angular.equals(left, right)) return
// form now on, we can assure that `left` and `right` are not equals (equivalents)
// if `left` and `right` are primitives, value changed
// if `left` is a primitive and `right` an object, value has been replaced with an object
// if `left` is an object and `right` a primitive, value has been replaced with a primitive
// use `_.copy` to prevent object referrence issues
if (!angular.isObject(left) || !angular.isObject(right)) return angular.copy(right)
@stefanmaric
stefanmaric / path.js
Last active February 11, 2018 03:16
Javascript recursive path / get function in plain ES5 and ES6
/**
* Gets the value at route of object.
* Look at: https://lodash.com/docs/4.17.4#get
*
* @param {Array|string} route The path of the property to get.
* @param {Object} obj The object to query.
* @return {*} Resolved value, or undefined.
*/
function path (route, obj) {
if (!Array.isArray(route)) return path(route.split('.'), obj)
@stefanmaric
stefanmaric / flattenObject.es5.js
Last active March 22, 2018 20:09
Flatten object function in plain ES5 javascript and ES2015
'use strict'
function flatten (source, dest, separator, path) {
dest = typeof dest !== 'undefined' ? dest : {}
separator = typeof separator !== 'undefined' ? separator : '-'
path = typeof path !== 'undefined' ? path : []
for (var key in source) {
if (!source.hasOwnProperty(key)) continue
@stefanmaric
stefanmaric / exclusion-a.mjs
Created July 26, 2018 23:36
Alternatives for exclusion with lodash
import * as _ from 'lodash'
const exclusion = (...arrays) =>
_.flatMap(arrays, x => _.difference(x, ..._.without(arrays, x)))
@stefanmaric
stefanmaric / notes.md
Created August 13, 2018 13:33
Fixes for Linux running on the Dell XPS 15 9550

Bluetooth

Download the BCM20703A1-0a5c-6410.hcd file as /lib/firmware/brcm/BCM-0a5c-6410.hcd.

@stefanmaric
stefanmaric / tick.mjs
Created December 18, 2018 17:41
Javascript tick function, wrapper around requestAnimationFrame for easier usage
/**
* Wrapper around requestAnimationFrame for easier usage.
* @param {Function} callback Function to call on each tick, receives last value as only param.
* @param {*} [initValue] Optional initial value.
* @returns {Function} Clear interval function.
*/
const tick = (callback, initValue) => {
let unsubscribed = false
let lastValue = initValue