Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / index.html
Created June 1, 2015 09:03
Google Map and Kendo UI // source http://jsbin.com/cipuq
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="minimal-ui" />
<title>Google Map and Kendo UI</title>
<link href="http://cdn.kendostatic.com/2014.1.318/styles/kendo.mobile.all.min.css" rel="stylesheet" />
<script src="http://cdn.kendostatic.com/2014.1.318/js/jquery.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.1.318/js/kendo.mobile.min.js"></script>
<script src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
<style id="jsbin-css">
@mitch-cohen
mitch-cohen / Convert WKT to Json for ESRI JSAPI
Created March 14, 2014 13:18
This function will convert the Well Known Text to JSON for ESRI Geometry creation. See example at http://jsfiddle.net/mac1175/6hcax/
function fromWKT2Json(WKTstr) {
var mods = {};
var convertToPointArray = function (ptArrayString) {
var points = [],
ptStringArray = ptArrayString.replace(/\)|\(/gi, "").split(",");
ptStringArray.forEach(function (pt) {
var splitpt = pt.trim().split(" "),
x = parseFloat(splitpt[0], 10),
y = parseFloat(splitpt[1], 10);
@bennadel
bennadel / watch-vs-watch-collection.htm
Created December 17, 2013 14:58
Scope $watch() vs. $watchCollection() In AngularJS
<!doctype html>
<html ng-app="Demo">
<head>
<meta charset="utf-8" />
<title>
Scope $watch() vs. $watchCollection() In AngularJS
</title>
<style type="text/css">
// extension for jQuery
(function (root) {
if (root.Enumerable == null) {
throw new Error("can't find Enumerable. linq.jquery.js must load after linq.js");
}
if (root.jQuery == null) {
throw new Error("can't find jQuery. linq.jquery.js must load after jQuery");
}
@thegrubbsian
thegrubbsian / current_timezone.js
Created September 30, 2012 21:45
Get the Current Timezone Offset in Hours in JavaScript, adjusting for Daylight Savings Time
function currentTimezoneOffset() {
var dstPeriod = {
2012: [new Date(2012, 2, 11), new Date(2012, 10, 4)],
2013: [new Date(2013, 2, 10), new Date(2013, 10, 3)],
2014: [new Date(2014, 2, 9), new Date(2014, 10, 2)],
2015: [new Date(2015, 2, 8), new Date(2015, 10, 1)],
2016: [new Date(2016, 2, 13), new Date(2016, 10, 6)],
2017: [new Date(2017, 2, 12), new Date(2017, 10, 5)],
2018: [new Date(2018, 2, 11), new Date(2018, 10, 4)],
2019: [new Date(2019, 2, 10), new Date(2019, 10, 3)],
@robnyman
robnyman / blob-filereader-localStorage.js
Last active May 21, 2025 16:09
Get file as a blob, read through FileReader and save in localStorage
// Getting a file through XMLHttpRequest as an arraybuffer and creating a Blob
var rhinoStorage = localStorage.getItem("rhino"),
rhino = document.getElementById("rhino");
if (rhinoStorage) {
// Reuse existing Data URL from localStorage
rhino.setAttribute("src", rhinoStorage);
}
else {
// Create XHR and FileReader objects
var xhr = new XMLHttpRequest(),
@robnyman
robnyman / arraybuffer-blob-filereader-localStorage.js
Last active January 30, 2024 09:22
Get file as an arraybuffer, create blob, read through FileReader and save in localStorage
// Getting a file through XMLHttpRequest as an arraybuffer and creating a Blob
var rhinoStorage = localStorage.getItem("rhino"),
rhino = document.getElementById("rhino");
if (rhinoStorage) {
// Reuse existing Data URL from localStorage
rhino.setAttribute("src", rhinoStorage);
}
else {
// Create XHR, Blob and FileReader objects
var xhr = new XMLHttpRequest(),
@robnyman
robnyman / localStorage-canvas-data-url.js
Created February 21, 2012 08:39
Use localStorage and canvas to same image as a Data URL
// localStorage with image
var storageFiles = JSON.parse(localStorage.getItem("storageFiles")) || {},
elephant = document.getElementById("elephant"),
storageFilesDate = storageFiles.date,
date = new Date(),
todaysDate = (date.getMonth() + 1).toString() + date.getDate().toString();
// Compare date and create localStorage if it's not existing/too old
if (typeof storageFilesDate === "undefined" || storageFilesDate < todaysDate) {
// Take action when the image has loaded
@jonleighton
jonleighton / base64ArrayBuffer.js
Last active March 31, 2026 18:26
Encode an ArrayBuffer as a base64 string
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then
// use window.btoa' step. According to my tests, this appears to be a faster approach:
// http://jsperf.com/encoding-xhr-image-data/5
/*
MIT LICENSE
Copyright 2011 Jon Leighton
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: