Skip to content

Instantly share code, notes, and snippets.

View rikschennink's full-sized avatar

Rik rikschennink

View GitHub Profile
<div data-module="/ui/component.js" 
     data-context="@media (min-width:30em) and was @visible">

</div>
@rikschennink
rikschennink / readme.md
Last active November 2, 2017 12:41
Browserify, relative paths?
  • src
    • main.js
    • ui
      • foo.js
      • bar.js

This command generates modules where identifiers have been set to absolute module paths:

browserify ./src/**/*.js -o ./dist/bundle.js --full-paths

@rikschennink
rikschennink / parser.js
Last active January 12, 2017 07:35
Parsing strings with JavaScript
const arrow = (str, i) => str[i] === '-' && str[i+1] === '>';
const string = (c) => c === "'" || c === '"';
const comma = (c) => c === ',';
const opener = (c) => c === '(';
const closer = (c) => c === ')';
@rikschennink
rikschennink / readme.md
Last active December 6, 2016 14:59
Pagination #a11y

Assumption: Next button is most clicked button in a pagination control.

The trap is to layout the HTML to match the design of the control. With the next button last and the previous button first.

By reformatting the HTML we can make things easier for everyone:

  • Visual users still see the classic paging (CSS takes care of that);
  • Tab focus for keyboard users is immidiately brought to next button, no need to tab over all pages;
  • Screenreader users have the same benefit and also hear which page is currently active;

Any suggestions on what more we could improve?

@rikschennink
rikschennink / README.md
Last active January 29, 2019 09:44
Sass OO Mixins: OOCSS without the HTML clutter

Sass OO Mixins: OOCSS without the HTML clutter

  • Less HTML clutter (caused by all those fragmented class names).
<button class="btn btn-primary btn-large btn-outline">Buy!</button>
  • Descriptive classes (or no classes at all) in the HTML results in cleaner and easier to read HTML.
Buy!
@rikschennink
rikschennink / animate.js
Created April 11, 2016 08:17
Function for doing quick animations
var animate = (function(){
'use strict';
var PI = Math.PI;
var PI_HALF = Math.PI/2;
var deltas = {
linear:function(p) {return p;},
easeInSine:function(p) {return Math.cos(p * PI_HALF);},
@rikschennink
rikschennink / Stylesheet.swift
Last active November 8, 2019 14:38
A UIView extension that adds a style property which allows you to style UI elements using tags.
// Default button style
StyleCollection.addStyle("btn-default", paint: {(view) -> Void in
// These buttons should all have rounded corners and a dropshadow
view.layer.cornerRadius = view.frame.height * 0.5
view.layer.backgroundColor = UIColor(hex:0x294A5F).CGColor
view.layer.shadowColor = UIColor.blackColor().CGColor
view.layer.shadowOffset = CGSizeMake(0, 2)
view.layer.shadowRadius = 2
@rikschennink
rikschennink / UIViewConvenience.swift
Created November 24, 2015 07:58
My brain has some trouble with hidden = true vs. hidden = false. hide() and show() not so much.
import UIKit
extension UIView {
func hide() {
hidden = true
}
func show() {
hidden = false
@rikschennink
rikschennink / silence-spotify.sh
Last active October 26, 2015 08:48
Adds Spotify to Notification Center so you can prevent it from showing the notification badge in the menu bar. Credits: http://apple.stackexchange.com/questions/153182/remove-dock-notification-badge-for-apps-not-in-notification-center/194316#194316
# "Usernoted" seems to be the "user notifications daemon", so get it's PID.
pid=$(ps aux | grep -i [u]sernoted | awk '{print $2}')
# Find the sqlite3 database that this program has open. It's in a "private" folder (app sandboxing).
db="$(lsof -p $pid | grep com.apple.notificationcenter/db/db\$ | awk '{print $9}')"
# I got the bundleid from Spotify.app/Contents/Info.plist
bundleid="com.spotify.client"
# I use 0 as the flags because you can change all the settings in System Preferences

Keybase proof

I hereby claim:

  • I am rikschennink on github.
  • I am rikschennink (https://keybase.io/rikschennink) on keybase.
  • I have a public key whose fingerprint is 679B 6933 62E6 CD78 C5A4 3DE9 3FB0 0B55 E5D3 8AEE

To claim this, I am signing this object: