Skip to content

Instantly share code, notes, and snippets.

Avatar

Klaas Cuvelier klaascuvelier

View GitHub Profile
@klaascuvelier
klaascuvelier / README.md
Last active Jan 12, 2016
Collapse diffs for certain file extensions in a PR
View README.md

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

View userstyle.css
.bubble.thread {
opacity: 0.65;
}
.bubble.green {
border-color: #9554D2 !important;
color: #9554D2 !important;
fill: #9554D2 !important;
}
@klaascuvelier
klaascuvelier / $q-all-spread.js
Last active Aug 29, 2015
Add spread method to $q.all promise
View $q-all-spread.js
angular
.module('$q-spread', [])
.config(function ($provide) {
$provide.decorator('$q', function ($delegate) {
var originalAll = $delegate.all;
$delegate.all = function (promises) {
var promise = originalAll(promises);
@klaascuvelier
klaascuvelier / typeCheck.js
Last active Dec 23, 2015
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.
View typeCheck.js
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';
}
View url-example.html.twig
<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>
View url-directive.js
/**
* Inject urls into the url service
*/
Module.directive('url', ['$url', function injectUrlData($url) {
return {
restrict : 'A',
compile: function() {
return {
pre: function(scope, element, attrs) {
View example-controller.js
// 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
View url-service.js
/**
* URL service, holding urls for JS
*/
Module.factory('$url', function Url() {
var $url = {
_urls: {},
/**
View symfony-controller.php
<?php
class AssetController {
/**
* Get assets via some params
* @param string $type
* @param integer $from
* @param integer $to
* @return array
View symfony-routing.html.twig
<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 %}