Skip to content

Instantly share code, notes, and snippets.

View klaascuvelier's full-sized avatar

Klaas Cuvelier klaascuvelier

View GitHub Profile
@klaascuvelier
klaascuvelier / responsive.html
Created February 8, 2012 13:56 — forked from lensco/responsive.html
Responsive design tester - Fork of Lenscos gist for reponsive design tester (https://gist.github.com/1685127) added allow-scripts and update all frame locations when one of the frames location changes
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Responsive Design Testing</title>
<style>
body { margin: 20px; font-family: sans-serif; overflow-x: scroll; }
.wrapper { width: 6000px; }
.frame { float: left; }
h2 { margin: 0 0 5px 0; }
@klaascuvelier
klaascuvelier / README.md
Last active January 12, 2016 13:01
Collapse diffs for certain file extensions in a PR

Collapse file diffs for files with a certain exentions. The list of extensions is on the end of gist.

@klaascuvelier
klaascuvelier / typeCheck.js
Last active December 23, 2015 08:29
Type check for JavaScript objects. Based on code from @jonbretman's slides from JsConf (https://speakerdeck.com/jonbretman/ask-not-what-javascript-can-do-for-you, slide 25) Fix for non-isNaN types.
var toString = Object.prototype.toString,
regex = /\[object (.*?)\]/,
type = function (o) {
var match, typeMatch;
// Special case for DOM elements
if (o && o.nodeType === 1) {
return 'element';
}
<script type="url/text" url>
acme_assets_get_all = {{ url('acme_assets_get_all', { type: ':type' }) }};
acme_assets_get_from_to = {{ url('acme_assets_get_from_to', { type: ':type', from: ':from', to: ':to' }) }};
</script>
// some exampe controller
Module.controller('Example', ['$scope', '$http', '$url', function ($scope, $http, $url) {
// fetch assets from php controller
$scope.fetchFromTo(from, to) {
var url = $url.get('acme_get_assets_from_to', { type: 'documents', from: from, to: to });
$http.get(url)
.success(function () {
// do something with the result
/**
* URL service, holding urls for JS
*/
Module.factory('$url', function Url() {
var $url = {
_urls: {},
/**
/**
* Inject urls into the url service
*/
Module.directive('url', ['$url', function injectUrlData($url) {
return {
restrict : 'A',
compile: function() {
return {
pre: function(scope, element, attrs) {
<?php
class AssetController {
/**
* Get assets via some params
* @param string $type
* @param integer $from
* @param integer $to
* @return array
<ul>
<li>
<a href="{{ url('acme_assets_get_all', { type: 'documents' }) }}">
{% trans %}All Documents{% endtrans %}
</a>
</li>
<li>
<a href="{{ url('acme_assets_get_from_to', { type: 'documents', from: 10, to: 15 }) }}">
{% trans %}Just a page{% endtrans %}
@klaascuvelier
klaascuvelier / earport-extension.js
Last active December 16, 2015 03:29
Extension for Earport.fm: Drag & Drop mp3 files and m3u playlists on the screen to add them to the Earport playlist.
(function () {
var $dropView = $('<div style="position: absolute; left: 0; top: 0; bottom: 0; right: 0; background: rgba(0, 0, 0, 0.5); z-index: 9999; color: #fff; padding: 100px; text-align: center; font-size: 32px">drop music or playlists</div>'),
$body = $('body'),
songsToAdd = [],
filesToParse = [];
$body.append('<script src="https://raw.github.com/vjeux/jDataView/master/src/jdataview.js"></script>');
Earport.Api.socket.on('search.query', songsFound);
Earport.Api.socket.on('playlist.queue', songQueued);