Skip to content

Instantly share code, notes, and snippets.

@hipertracker
hipertracker / Nested.elm
Last active September 13, 2018 14:05
Decoding nested JSON string
module Nested exposing (api)
import Json.Decode exposing (at, int, string, list, decodeString, Decoder)
import Json.Decode.Pipeline exposing (decode, required, optional, hardcoded)
data : String
data =
"""
{"languages":
import Html exposing (..)
import Html.App exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Html.Attributes exposing (..)
import Http
import Task exposing (Task)
import Json.Decode as Json exposing ((:=))
type Msg
@perrytew
perrytew / Adding UltraCart Hosted Fields to a Javascript Checkout
Last active February 9, 2016 19:59
Main block of code most apps will need to implement hosted fields, the new way to collect credit card numbers with UltraCart.
<!-- Changes -->
<!-- 10/1/2015 -->
<!-- Added a redundant check to make sure the hosted-fields js file actually loads first. this check has a document.write -->
<!-- call in it, so make sure the code below is at the end of the body, not in the head section. -->
<!-- 7/29/2015 -->
<!-- Added a hash of options to the setup call to allow for -->
<!-- some of the issues encountered using backbone.js checkouts. -->
<!--
options: { callback: somefunction, selectorContext: elementOrjQueryObj }
@longlho
longlho / getElementsByClassName-polyfill.js
Created September 5, 2014 01:38
getElementsByClassName Polyfill for IE8
(function () {
if (!document.getElementsByClassName) {
window.Element.prototype.getElementsByClassName = document.constructor.prototype.getElementsByClassName = function (classNames) {
classNames || (classNames = '*');
classNames = classNames.split(' ').join('.');
if (classNames !== '*') {
classNames = '.' + classNames;
}
@jnwelzel
jnwelzel / GsonProvider.java
Created March 10, 2014 14:36 — forked from hstaudacher/GsonProvider.java
Integrating Gson into a JAX-RS application to replace the other shitty default providers
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
@jonathantneal
jonathantneal / README.md
Created September 19, 2012 06:34
Polyfill the EventListener interface in IE8

EventListener Polyfill

Is IE8 your new IE6? Level the playing field with polyfills.

This script polyfills addEventListener, removeEventListener, and dispatchEvent. It is less than half a kilobyte minified and gzipped.

addEventListener

addEventListener registers a single event listener on a single target.

@elidupuis
elidupuis / handlebars-helpers.js
Last active December 7, 2021 02:24
Simple Handlebars.js helpers
/*! ******************************
Handlebars helpers
*******************************/
// debug helper
// usage: {{debug}} or {{debug someValue}}
// from: @commondream (http://thinkvitamin.com/code/handlebars-js-part-3-tips-and-tricks/)
Handlebars.registerHelper("debug", function(optionalValue) {
console.log("Current Context");
console.log("====================");