Skip to content

Instantly share code, notes, and snippets.

View marcusasplund's full-sized avatar

Marcus Asplund marcusasplund

View GitHub Profile
Mila
Aubrey
Hannah
Lily
Addison
^([a-zA-Z]+)$
"$1",
// getCurrentPosition()
// .then((position) => console.log(position.coords.latitude))
const getCurrentPosition = () => {
return new Promise((resolve, reject) => {
window.navigator.geolocation
.getCurrentPosition((position) => {
resolve(position)
}, (error) => {
reject(error)

Single Line Application

SLA-Serverless and whatnot

Maybe you heard about SPA:s, Single Page Applications. But you might not heard about Single Line Applications.

A brief background

Some years ago i was into making practical js-bookmarklets for myself. A bookmarklet can look something like this:

<a href="javascript:alert('hello there!')">say hello</a>
<a href="javascript:System.import('jquery').then(function($){console.log($)})">import and log $</a>
@mixin for-size($size) {
@if $size == phone-only {
@media (max-width: 599px) { @content; }
} @else if $size == tablet-portrait-up {
@media (min-width: 600px) { @content; }
} @else if $size == tablet-portait-only {
@media (min-width: 600px) and (max-width: 899px) { @content; }
} @else if $size == tablet-landscape-up {
@media (min-width: 900px) { @content; }
} @else if $size == tablet-landscape-only {
@marcusasplund
marcusasplund / resolveNativePathInIonic2app.js
Created May 10, 2016 06:48
Resolve native imagepath in ionic2 with cordova-plugin-filepath
// with this plugin:
// https://github.com/hiddentao/cordova-plugin-filepath/
initializeApp() {
this
.platform
.ready()
.then(() => {
if (window.StatusBar) {
window
// a really, really simple proxy to request
// non-CORS enabled webservices
// Drop this script on your server and prepend
// the url you want to access like e.g.
// $.getJSON("http://pathtouyourserver.com/folderwiththisscript/corsproxy.php?url=http://theapiwithoutcors.com").success(....
//
// You find a more sophisticated one here: http://benalman.com/projects/php-simple-proxy/
<?php
$url = $_GET['url'];
$content = file_get_contents($url);
@marcusasplund
marcusasplund / Quick Fusion Tables pseudo-mouseover Map
Created December 2, 2011 22:00 — forked from chrislkeller/README.md
Quick map creating a mouseover-like event on a google map using a Fusion Tables layer...
<style>
#map_canvas { width: 600px; height: 600px; }
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<!-- INCLUDE THIS SCRIPT REFERENCE FOR MOUSEOVER -->
<script type="text/javascript" src="http://gmaps-utility-gis.googlecode.com/svn/trunk/fusiontips/src/fusiontips_compiled.js"></script>