Skip to content

Instantly share code, notes, and snippets.

View dgieselaar's full-sized avatar

Dario Gieselaar dgieselaar

View GitHub Profile
/*global angular,_*/
(function ( ) {
angular.module('Zaaksysteem')
.directive('zsCrudTableAutoSize', [ '$window', '$timeout', function ( $window, $timeout ) {
return {
link: function ( scope, element/*, attrs*/ ) {
function setAutoWidth ( ) {
/*global module*/
var lrserver = require('tiny-lr')();
module.exports = function ( grunt ) {
grunt.initConfig({
watch: {
sass: {
files: [ '**/*.scss' ],
/*global angular*/
(function ( ) {
/* This interceptor allows you to target partials
within lazy loaded html files. Usage:
index.html:
<div>
data-ng-include="/partials/components.html#single-component>
</div>

App logic and structure expressed in HTML, which is enchanting for beginners (Look’ma no JS, magic!), but terrible for real development. We are developers, we write and debug code. But Angular is HTML parser. I really don’t want to debug any string based parser instead of my code. HTML should be just a projection of app state, not a source of truth!

Te veel logica in je template zetten is inderdaad geen goed idee. Wat dat betreft is Angular zijn expression parser misschien te vergevend. Assignments in je click handlers in de HTML zetten (bijv ng-click="state='open'") of iets dergelijks is een slecht idee en zou eigenlijk niet ondersteund moeten worden.

Dat gezegd hebbende, ik heb bij mijn huidige werkgever een brok javascript geërfd waarbij functionaliteit op basis van aanwezige classes wordt toegevoegd. Dit is verschrikkelijk om te debuggen. Bij Angular kijk je welke directives (attributes) op de button zitten waar je op klikt, of het element wat getoond wordt, en je hebt binnen no time het verantwoordel

<div class="scrollable" coen-scroll>
<ul class="actual-menu" data-ng-show="coenScroll.getScroll()>100">
</ul>
</div>
<script type="text/javascript">
angular.module('coen')
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\bower\bin\bower" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\bower\bin\bower" %*
)
@dgieselaar
dgieselaar / cmdwrap
Last active August 29, 2015 14:07
If you run `npm install` on Windows, the build script creates .cmd wrappers for the package scripts in `node_modules/.bin`. This is to ensure commands like "bower install" works on Windows in your `scripts`. However, if you run `npm install` on a Unix machine, those .cmd files won't be added, which causes your scripts to fail on a Windows machin…
for f in $(find './node_modules/.bin' -maxdepth 1 ! -name "*.*"); do
name=$(basename $f);
cp cmdwrap.tpl "$f.cmd";
sed -i "s,PACKAGE_NAME,$name,g" $f.cmd;
done
function js ( ) {
var stream = gulp.src([ 'src/**/_*.js', 'src/**/*.js' ] )
.pipe(sourcemaps.init())
.pipe(cached('js'))
.pipe(plumber())
.pipe(babel( {
blacklist: [ "useStrict" ],
babelHelpers: {
outputType: 'var'
}
I'm using webpack to compile my application source. It splits up the files in chunks which are lazily loaded when necessary. However, the sourcemaps for the first file (main.js) breaks if the second file (2.js) is loaded in.
Here's when it _does_ work.
- if I throw an error in main.js immediately instead of with a timeout
- if 2.js is not lazily-loaded but available in a script tag when the page is rendered
Here's what I've tried to make it work
- remove the sourcemap for 2.js
- remove the content of 2.js
@dgieselaar
dgieselaar / gist:3377aa5c2223098e8622
Created June 23, 2015 14:17
Hide videos which have under a 1000 views from a youtube channel's video list
Array.prototype.slice.call(document.querySelectorAll('.yt-lockup-meta-info > li:first-child')).forEach(function ( el ) {
var views = Number(el.textContent.match(/(\d+,?\d+)/)[0].replace(',','')),
parent;
if(views < 1000) {
parent = el.parentNode;
while(!parent.classList.contains('channels-content-item')) {
parent = parent.parentNode;
}
parent.parentNode.removeChild(parent);