Skip to content

Instantly share code, notes, and snippets.

@djvs
djvs / AwesomeAngularAudioPlayer.md
Last active August 29, 2015 14:27
AngularJS multi track audio player (JS Audio API - depends on underscore.js, AngularJS, font-awesome)

An update on my earlier player ( https://gist.github.com/djvs/24006c975ff11fd889e3 ), with some fixes (removed Bootstrap/Glyphicons dependency, now depends only on Font-Awesome, underscore JS, Angular itself, and the attached images). And added multitrack functionality! Consider this an alternative to clunky browser-mandated HTML5 audio tag players, or alternative to JPlayer etc..

example

Javascript:

app.directive('audios',function($interval) {
    return {

restrict:'A',

@djvs
djvs / uptimetest.rb
Last active August 29, 2015 14:26
Ubuntu neo4j uptime watcher (alpha)
require 'timeout'
def restartneo4j
puts "restarting neo4j"
`sudo service neo4j-service restart"`
end
begin
Timeout::timeout(5){
@output = `curl http://localhost:7474`
# fix routes - this should only run once
Course.all.each_with_index do |c,ind|
fixhash = c.routes.map{|x| {x.originalid => x.id}}.reduce(:merge) || {}
routes = c.routes
routes.each do |r|
r.ancestors = r.ancestors.map{|x| (fixhash[x] == nil) ? (x.to_s.length < 22 ? x : nil ) : fixhash[x]}.compact
r.save
end
end
module Handler.Echo where
import Import
getEchoR :: String -> Handler Html
getEchoR theText = defaultLayout [whamlet|<h1>#{theText}|]
push(){
git config remote.origin.url >& /dev/null
if [ $? -eq 0 ]; then
if [ $# -eq 0 ]; then
echo "you need to give a commit message! example: \n push \"my message\"" ; return
fi
git add -A :/;
git commit -a -m $1;
git push origin $(git branch | sed -n -e 's/^\* \(\.*\)/\1/p' );
else
WM_STATE(WM_STATE):
window state: Normal
icon window: 0x0
XdndAware(ATOM) = BITMAP
_MOTIF_DRAG_RECEIVER_INFO(_MOTIF_DRAG_RECEIVER_INFO) = 0x6c, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0
WM_HINTS(WM_HINTS):
Client accepts input or input focus: True
Initial state is Normal State.
window id # of group leader: 0x2800001
_NET_WM_STRUT_PARTIAL(CARDINAL) = 0, 0, 25, 0, 0, 0, 0, 0, 0, 1919, 0, 0
-- Compiler flags --
{-# LANGUAGE NoMonomorphismRestriction #-}
-- Imports --
-- stuff
import XMonad
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import System.Exit
@djvs
djvs / gist:24006c975ff11fd889e3
Last active August 12, 2021 06:31
AngularJS (Angular) HTML5 Audio Player directive from scratch

Write your own HTML5 Audio/AngularJS audio player

example

I tried AudioJS, JPlayer, and a couple of the angular directives. Somehow they all sucked! And yet the HTML5 audio API was totally open and in theory should work fine with Angular. Time to get my hands dirty as usual....

Javascript:

app.directive('aplayer',function($interval) {

<!DOCTYPE html><html lang="en" ><head><meta name="description" content="Web word processing, presentations and spreadsheets"><link rel="shortcut icon" href="//ssl.gstatic.com/docs/common/drive_favicon1.ico"><title>Google Drive -- Page Not Found</title><link href="//fonts.googleapis.com/css?family=Open+Sans:300" rel="stylesheet" type="text/css"><style>/* Copyright 2014 Google Inc. All Rights Reserved. */
.goog-inline-block{position:relative;display:-moz-inline-box;display:inline-block}* html .goog-inline-block{display:inline}*:first-child+html .goog-inline-block{display:inline}#drive-logo{color:#91959c;font-family:"Open Sans",Arial,sans-serif;font-size:27px;font-weight:300;position:absolute;text-shadow:0 1px 1px white;white-space:nowrap}#drive-logo img{padding:0 0.4em 0 0;position:relative;top:2px;vertical-align:middle}#drive-logo a{color:#91959c;text-decoration:none}#drive-logo span.goog-inline-block{margin-top:2px;vertical-align:top}</style><style type="text/css">body {background-color: #fff; font-family: Ar
@djvs
djvs / gist:f5fb6b7ed4ae6be06338
Created November 30, 2014 23:00
smart home compatible with weird urxvt + vim + zsh
" smart home "
set nocompatible
map <Esc>[1~ <Home>
imap <Esc>[1~ <Home>
function! Smarthome()
if col('.') == 1
execute 'normal! ^'
else
execute 'normal! 0'