Skip to content

Instantly share code, notes, and snippets.

Dag-Inge Aas dagingaa

Block or report user

Report or block dagingaa

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
@dagingaa
dagingaa / oauth-client.rb
Created Jul 9, 2012
A minimal Sinatra OAuth 2.0 client and resource server.
View oauth-client.rb
require 'sinatra'
require 'open-uri'
require 'json'
# This application is the bare minimum to authorize with OAuth 2.0
# using the authorization grant scheme. No error handling included.
# The application is both a client and a resource server.
# Start it by using 'ruby <file>' and navigate to http://localhost:4567
#
# The application also needs the oauth-server written in Java.
View gist:7485786
// javascript
var takeSnapshot = function (clientId) {
var videoElem = document.getElementById(clientId);
var canvas = document.getElementById(“chat-paint-canvas”);
var ctx = canvas.getContext(‘2d’);
ctx.drawImage(videoElem, 0, 0, 30, 30);
return canvas.toDataURL();
};
// html
@dagingaa
dagingaa / .vimrc
Last active Jan 3, 2016
My .vimrc on my work laptop
View .vimrc
filetype off
call pathogen#infect()
call pathogen#helptags()
syntax on
filetype plugin indent on
set smarttab
set shiftwidth=4
set autoindent
@dagingaa
dagingaa / getusermedia.html
Created Oct 27, 2014
Example files for Abakus course
View getusermedia.html
<!DOCTYPE html>
<html>
<head><title>getUserMedia</title></head>
<body>
<video autoplay></video>
<canvas></canvas>
<button>Click me</button>
<img src="" alt="captured image from webcam">
<script>
@dagingaa
dagingaa / hide-kissmetrics.js
Created Dec 8, 2014
Hide kissmetrics events
View hide-kissmetrics.js
// Run inside Chrome DevTools to mass hide events matching eventName
var removeEvents = function (eventName) {
h3s = document.querySelectorAll("div.section h3");
var rtcElems = [];
for (var i = 0; i < h3s.length; i++) {
var h3 = h3s[i];
if (h3.innerHTML.indexOf(eventName) !== -1) {
rtcElems.push(h3.parentElement);
}
}
@dagingaa
dagingaa / systemjs-react.js
Last active Sep 15, 2016
SystemJS + React PoC
View systemjs-react.js
import React from 'react';
class Hello {
render() {
return React.createElement("div", null, "Hello ", this.props.name);
}
}
Hello.prototype.displayName = "Hello";
var HelloElement = React.createClass(Hello.prototype);
View basic-systemjs-template.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SystemJS</title>
</head>
<body>
<script src="jspm_packages/system.js"></script>
View maximally-minimal-es6-classes.js
// Source: http://wiki.ecmascript.org/doku.php?id=strawman:maximally_minimal_classes
class Monster {
// A method named "constructor" defines the class’s constructor function.
constructor(name, health) {
// public name object
this.name = name;
// private name object
this[pHealth] = health;
}
View es6-template-proposal.js
// The following is a thought experiment of how it COULD work
// todos-template.js
export default (todos) => {
return `
<div class="todo-wrapper">
<p>Remaining: ${ todos.length }</p>
<ul class="todos">
${ todos.map(todo => `<li class="${ todo.completed }">${ todo.text }</li>`) }
</ul>
@dagingaa
dagingaa / LocalMediaStream.java
Last active Aug 29, 2015
How to get a mediastream in Android
View LocalMediaStream.java
VideoCapturer capturer = VideoCapturer.create("");
MediaStream mediaStream = peerConnectionFactory.createLocalMediaStream("APPEAR");
VideoSource videoSource = this.peerConnectionFactory.createVideoSource(capturer, new MediaConstraints());
VideoTrack videoTrack = this.peerConnectionFactory.createVideoTrack("APPEARv0", videoSource);
videoTrack.addRenderer(new VideoRenderer());
mediaStream.addTrack(videoTrack);
You can’t perform that action at this time.