Skip to content

Instantly share code, notes, and snippets.

View argelius's full-sized avatar

Andreas Argelius argelius

View GitHub Profile
@argelius
argelius / matoyas.ino
Created May 19, 2014 21:24
Matoyas cavern from FFI on Arduino
/*
* Plays the melody "Matoyas cavern" from Final Fantasy I with Arduino.
*
* Connect two pins to a speaker with ~100ohm resistors and listen.
*/
#include <Tone.h>
Tone tone1, tone2;
@argelius
argelius / frechet.js
Last active August 25, 2022 18:40
Discrete Frechet Distance
/* Discrete Fréchet Distance
* By Andreas Argelius http://argeli.us/
*
* Implementation of Discrete Frechet Distance in Javascript.
*
* The paths are defined as [[x0, y0], [x1, y1], ...]
*
*/
(function() {
@argelius
argelius / geolocation.js
Last active August 29, 2015 14:09
Geolocation API as AngularJS service
angular.module('app', [])
.factory('$geolocation', function($q) {
return {
get: function() {
var deferred = $q.defer();
navigator.geolocation.getCurrentPosition(
function(result) {
deferred.resolve(result);
@argelius
argelius / services.js
Last active August 29, 2015 14:11
Onsen weather sample services
// services.js
(function() {
'use strict';
angular.module('app')
// Get current location.
.factory('$geolocation', function($q) {
this.get = function() {
@argelius
argelius / controllers.js
Created December 15, 2014 04:08
Onsen weather sample controllers
// controllers.js
(function() {
'use strict';
angular.module('app')
.controller('WeatherController', function($scope, $window, $geolocation, $weather, $interval) {
// Create popover when Onsen UI is loaded.
@argelius
argelius / index.html
Last active August 29, 2015 14:11
Onsen weather sample index.html
<html ng-app="app">
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/onsen-css-components.css" />
<link rel="stylesheet" type="text/css" href="css/onsenui.css" />
<title>Onsen Weather</title>
<style>
@argelius
argelius / app.js
Created December 15, 2014 05:57
Onsen weather sample app
// app.js
(function() {
'use strict';
angular.module('app', ['onsen'])
// OpenWeatherMap API returns temperature in degrees Kelvin.
.filter('kelvinToCelsius', function() {
return function(kelvin) {
@argelius
argelius / load-firebase.html
Last active August 29, 2015 14:14
Code to load Firebase from CDN and create Firebase object.
<script src="https://cdn.firebase.com/js/client/2.1.1/firebase.js"></script>
<script>
var fb = new Firebase('https://hacker-news.firebaseio.com/v0');
</script>
@argelius
argelius / create-firebase-reference.js
Created January 27, 2015 09:20
Create reference to Firebase child resource.
// Create a reference to https://hacker-news.firebaseio.com/v0/topstories
var topStoriesRef = fb.child('topstories');
@argelius
argelius / fire-base-event-listener.js
Created January 27, 2015 09:26
Listen for Firebase resource changes.
topStoriesRef.on('value', function(snapshot) {
console.log(snapshot.val());
});