Skip to content

Instantly share code, notes, and snippets.

Eirik Brandtzæg eirikb

Block or report user

Report or block eirikb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View JSPM+AVA.md
  1. Download zip.
  2. npm install.
  3. npm test.
@eirikb
eirikb / gulpfile.js
Last active Sep 26, 2017
Gulp + Babel + JSX
View gulpfile.js
var gulp = require('gulp');
var fs = require('fs');
var browserify = require('browserify');
var babelify = require('babelify');
var watchify = require('watchify');
var source = require('vinyl-source-stream');
var livereload = require('gulp-livereload');
var less = require('gulp-less');
var concat = require('gulp-concat');
var connect = require('gulp-connect');
View example.js
var nodify = require('nodify');
// Prints build time
console.log(nodify(function() {
return new Date();
}));
// Prints current time
console.log(new Date());
@eirikb
eirikb / paging.html
Created Nov 16, 2014
SharePoint paging
View paging.html
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/css/bootstrap.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0/angular.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0/angular-sanitize.min.js"></script>
<div ng-app="test-paging" ng-controller="ListController">
<table class="table table-bordered">
<tr ng-repeat="item in items">
<td>{{item.Title}}</td>
<td ng-bind-html="item.Body"></td>
</tr>
@eirikb
eirikb / dep.js
Created Jun 24, 2014
Dependencyhackjection
View dep.js
var d={a:1,b:2},f=function(a,b){return a+b};f.apply(null,(''+f).match(/function[^(]*\(([^)]*)\)/)[1].split(/,\s*/).map(function(x){return d[x]}))
View OpenBinaryDirect.cs
public static FileInformation GetFile(ClientContext clientContext, string fileRef)
{
using (var clientContextHack = new ClientContext(clientContext.Url))
{
return File.OpenBinaryDirect(clientContextHack, fileRef);
}
}
@eirikb
eirikb / imgur-oauth-test.html
Last active Aug 30, 2019
Post to imgur using oauth (api v3) on a static (no server) site
View imgur-oauth-test.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>imgur oauth</title>
<script src="http://code.jquery.com/jquery.min.js"></script>
<script>
$(function () {
var extractToken = function(hash) {
@eirikb
eirikb / index.html
Last active Dec 20, 2015
Komplett-sort 2000
View index.html
<p>Lagre som bookmarks/favoritter:</p>
<p>
<a href="javascript:$('div[class*=prod]').sort(function(a,b){function d(x){var d=$(x).find('.value').text().match(/\d+/);if(!d)return 0;return parseInt(d[0],10)};return d(b)-d(a)}).each(function(i){$('div[class*=prod]').eq(i).replaceWith(this)});">Komplettsalg - prosent</a>
</p>
<p>
<a href="javascript:$('div[class*=prod]').sort(function(a,b){function d(x,y){var d=$(x).find(y).text().replace(/\./g,'').match(/\d+/);return d?parseInt(d[0]):0}function dd(x){return d(x,'.priceBefore')-d(x,'.price')}return dd(b)-dd(a)}).each(function(i){$('div[class*=prod]').eq(i).replaceWith(this)});">Komplettsalg - prisforskjell</a>
</p>
View IsNumeric.cs
using System;
using System.Linq;
public static class IsNumericExtension
{
public static bool IsNumeric(this string orig)
{
return orig.Length > 0 && orig.ToCharArray().All(Char.IsNumber);
}
}
You can’t perform that action at this time.