Skip to content

Instantly share code, notes, and snippets.

@berkin
berkin / install_dbus.sh
Created December 6, 2016 14:42
Install DBus under Mac OS X.
#!/usr/bin/env bash
# Created @ 13.01.2015 by Christian Mayer <http://fox21.at>
brew install dbus
cp /usr/local/Cellar/d-bus/1.8.8/org.freedesktop.dbus-session.plist ~/Library/LaunchAgents
# Load DBus
launchctl load -w ~/Library/LaunchAgents/org.freedesktop.dbus-session.plist
#!/bin/bash
album=`dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 2 "album"|egrep -v "album"|egrep -v "array"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$`
artist=`dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 2 "artist"|egrep -v "artist"|egrep -v "array"|cut -b 27-|cut -d '"' -f 1|egrep -v ^$`
title=`dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 1 "title"|egrep -v "title"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$`
echo $artist " - " $album " - " $title;
const events = ['click', 'touchstart', 'touchmove', 'touchend', 'mousedown', 'mousemove', 'mouseup', 'keydown', 'keyup'];
const defaults = {
timeout: 5000
};
let timer = null;
function BlockUi(context, options) {
@berkin
berkin / authorization-middleware.js
Last active August 16, 2018 11:08
redux authorization header middleware
import axios from 'axios'
export default ({ getState }) => next => action => {
const prevToken = getState().auth.access_token
// if authorization header is null and we have token, set it for the next action
if (!axios.defaults.headers['Authorization'] && prevToken) {
axios.defaults.headers['Authorization'] = `Bearer ${prevToken}`
}