Skip to content

Instantly share code, notes, and snippets.

@imnutz
imnutz / server_time_sync.js
Created October 25, 2018 00:11 — forked from ethaizone/server_time_sync.js
Sync server time to client browser with JS. Implement follow Network Time Protocol.
// Thanks http://stackoverflow.com/questions/1638337/the-best-way-to-synchronize-client-side-javascript-clock-with-server-date
var serverTimeOffset = false;
function getServerTime(callback) {
if (serverTimeOffset === false) {
var scripts = document.getElementsByTagName("script"),
URL = scripts[scripts.length - 1].src;
var clientTimestamp = Date.parse(new Date().toUTCString());
@imnutz
imnutz / certificate.sh
Created July 29, 2018 03:58 — forked from WebReflection/certificate.sh
A basic Self Signed SSL Certificate utility
#!/usr/bin/env bash
# A basic Self Signed SSL Certificate utility
# by Andrea Giammarchi @WebReflection
# https://www.webreflection.co.uk/blog/2015/08/08/bringing-ssl-to-your-private-network
# # to make it executable and use it
# $ chmod +x certificate
# $ ./certificate # to read the how-to
@imnutz
imnutz / using_mailboxes_in_elm.md
Created October 30, 2015 02:54 — forked from mgold/using_mailboxes_in_elm.md
Using Mailboxes in Elm: a tutorial blog post

Using Mailboxes in Elm

Max Goldstein | July 30, 2015 | Elm 0.15.1

In Elm, signals always have a data source associated with them. Window.dimensions is exactly what you think it is, and you can't send your own events on it. You can derive your own signals from these primitives using map, filter, and merge, but the timing of events is beyond your control.

This becomes a problem when you try to add UI elements. We want to be able to add checkboxes and dropdown menus, and to receive the current state of these elements as a signal. So how do we do that?

The Bad Old Days

@imnutz
imnutz / artistSearchExample.elm
Created October 20, 2015 14:51 — forked from TheSeamau5/artistSearchExample.elm
Artist Search Example
--------------------------
-- CORE LIBRARY IMPORTS --
--------------------------
import Json.Decode as Decode exposing (Decoder, object2, map, string, list, (:=))
import Task exposing (Task, andThen, succeed, fail, onError)
import Signal exposing (Signal, Mailbox, mailbox, message, send)
import String
-------------------------
@imnutz
imnutz / multipageform.elm
Last active August 29, 2015 14:25 — forked from TheSeamau5/multipageform.elm
Simple multi-page form
import Html exposing (Html, Attribute)
import Html.Attributes
import Html.Events
import Signal exposing (Address)
import List
import String
import StartApp
------------------
--- HELPER CODE --
@imnutz
imnutz / ScrollList.elm
Last active August 29, 2015 14:25 — forked from TheSeamau5/ScrollList.elm
Scroll List in Elm
import Html exposing (Html, Attribute)
import Html.Attributes
import Html.Events
import Json.Decode exposing (Decoder, (:=))
import List
import Signal exposing (Address)
import StartApp
import Array exposing (Array)
import Window
@imnutz
imnutz / RedditHomePage.elm
Last active August 29, 2015 14:25 — forked from TheSeamau5/RedditHomePage.elm
Getting the Reddit Home Page using Elm Promises
--------------------------
-- CORE LIBRARY IMPORTS --
--------------------------
import Task exposing (Task, succeed, andThen, onError)
import Json.Decode exposing (Decoder, object2, (:=), string, int, list, map)
import Signal exposing (Signal, Mailbox, mailbox, send)
import List
---------------------------------
-- THIRD PARTY LIBRARY IMPORTS --
@imnutz
imnutz / HackerNewsExample.elm
Last active August 29, 2015 14:25 — forked from TheSeamau5/HackerNewsExample.elm
Hacker news requests example
--------------------------
-- CORE LIBRARY IMPORTS --
--------------------------
import Task exposing (Task, ThreadID, andThen, sequence, succeed, spawn)
import Json.Decode exposing (Decoder, list, int, string, (:=), map, object2)
import Signal exposing (Signal, Mailbox, mailbox, send)
import List
---------------------------------
-- THIRD PARTY LIBRARY IMPORTS --
@imnutz
imnutz / todomvcrewrite.elm
Last active August 29, 2015 14:25 — forked from TheSeamau5/todomvcrewrite.elm
Todo MVC Rewrite with field setter syntax
module Todo where
{-| TodoMVC implemented in Elm, using plain HTML and CSS for rendering.
This application is broken up into four distinct parts:
1. Model - a full definition of the application's state
2. Update - a way to step the application state forward
3. View - a way to visualize our application state with HTML
4. Inputs - the signals necessary to manage events
This clean division of concerns is a core part of Elm. You can read more about
this in the Pong tutorial: http://elm-lang.org/blog/Pong.elm
This program is not particularly large, so definitely see the following
@imnutz
imnutz / gist:20d3ba61ffa176a23c26
Created June 29, 2015 09:02
Semantic Grid in GSS (Gwt)
/*---------------------------------------
GRID
-----------------------------------------*/
@def TOTAL_WIDTH 100%;
@def COLUMN_WIDTH 60;
@def GUTTER_WIDTH 20;
@def COLUMNS 12;
@def TOTAL_WIDTH 100%;
@defmixin row(COLUMNS_PARAM) {