Skip to content

Instantly share code, notes, and snippets.

View MagnusThor's full-sized avatar
🏠
Working from home

Magnus 'Bagzy' Thor MagnusThor

🏠
Working from home
  • Freelancer & member of coloquium
  • Sweden
View GitHub Profile
@MagnusThor
MagnusThor / Array.find.js
Created January 25, 2016 08:33
Array.find....
if (!Array.prototype.find) {
Array.prototype.find = function (predicate) {
if (this === null) {
throw new TypeError('Array.prototype.find called on null or undefined');
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var list = Object(this);
var length = list.length >>> 0;
@MagnusThor
MagnusThor / OnOpen_Arin.cs
Created January 21, 2016 08:06
Keep alive using System.Timers.Timer();
public override async Task OnOpened() {
var t = new System.Timers.Timer();
// do your onOpen Stuff...
t.Interval = 1000 * 15;
t.Elapsed += (sender, args) => {
this.Invoke(new {
ts = DateTime.Now.Second
}, "ping");
};
t.Start();
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
</head>
<body>
<script src="js/XSockets.latest.js"></script>
<script src="js/XSockets.WebRTC.latest.js"></script>
@MagnusThor
MagnusThor / gist:00f98d53843aeb635672
Created January 7, 2016 17:33
Create transcripts using webkitSpeechRecognition by attaching a mediaStream audioTrack
var AudioTrackSpeechLog = (function () {
"use strict";
var ctor = function (track, completed, interim, lang) {
var self = this;
this.recognizing = false;
this.finalTranscript = "";
if (('webkitSpeechRecognition' in window)) {
this.recognition = new webkitSpeechRecognition();
this.recognition.continuous = true;
this.recognition.interimResults = true;
verticles = [
new Noc.Point3D(-1, -1, -1), // 0
new Noc.Point3D(1, -1, -1), // 1
new Noc.Point3D(1, 1, -1), // 2
new Noc.Point3D(-1, 1, -1), // 3
new Noc.Point3D(1, -1, 1, 0), // 5
new Noc.Point3D(1, 1, 1), // 6
new Noc.Point3D(-1, 1, 1), // 7
];
var faces = [
@MagnusThor
MagnusThor / aconfig.js
Created December 14, 2015 15:08
Pass a object , that you can grab from the c# controller using .GetParameter("foo") ...
var myParams = {
foo: "bar",
categoryId :1001
};
xsocketsControllerProvider.open("ws://" + location.host, myParams);
...
return {
restrict: 'E',
scope: {
options: '=options', // arr med data?
// [{label: '' , value: 0 },... ]
select: '&onSelect',
trigger: '=trigger',
labelField: '=labelField', // label
<div class="input-group-btn">
<ul class="dropdown-menu">
<li ng-repeat="option in options">
<a ng-click="select({item:option})"
ng-class="{'current': $index === currentIndex }">
{{option.Name}}
</a>
</li>
</ul>
@MagnusThor
MagnusThor / sym-dir-impl.html
Created December 10, 2015 08:56
sym-dir-impl.html
<input type="text" ng-keyup="find($event)" id="auto" class="form-control"/>
<sym-suggestions options="results"
on-select="selectedItem(item)" trigger="auto">
</sym-suggestions>
@MagnusThor
MagnusThor / sym-dir-tmpl.html
Created December 10, 2015 08:56
sym-dir-tmpl.html
<ul class="sym-suggestions">
<li ng-repeat="option in options">
<span ng-click="select({item:option})" >
{{option.Name}}
</span>
</li>
</ul>