Skip to content

Instantly share code, notes, and snippets.

@nojaf
nojaf / debounce.js
Created January 15, 2017 15:29
debounce
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
@nojaf
nojaf / index.html
Created January 16, 2017 19:29
New html page
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<link rel="icon" href="favicon.ico?v=1" type="image/icon">
</head>
<body>
</body>
</html>
@nojaf
nojaf / App.fs
Created January 24, 2017 21:46
Suave with custom port
module MyWebApi.Program
open Suave
open Suave.Successful
open System.Net
[<EntryPoint>]
let main argv =
let config =
@nojaf
nojaf / proxy.config
Created January 26, 2017 20:11
ssl proxy example
server {
listen 80;
return 301 https://$host$request_uri;
}
server {
listen 443;
server_name cantare.local;
@nojaf
nojaf / App.fs
Created February 2, 2017 15:26
Basic Suave filter api
// Learn more about F# at http://fsharp.org
// See the 'F# Tutorial' project for more help.
open FSharp.Data
open System.IO
open Suave
open Suave.Filters
open Suave.Operators
open Suave.Successful
open System.Net
@nojaf
nojaf / Main.elm
Created February 16, 2017 12:28
Elm http example
module Main exposing (..)
import Html exposing (Html, text, div, button)
import Html.Events exposing (onClick)
import Json.Encode
import Json.Decode
import Http exposing (..)
-- elm-package install -- yes
@nojaf
nojaf / Main.elm
Last active February 17, 2017 09:29
Basic Elm Http example without encoding, https://runelm.io/c/hsq
module Main exposing (..)
import Http
import Html exposing (Html, div, text, program, button)
import Html.Events exposing (onClick)
type alias Model =
String
@nojaf
nojaf / index.js
Created March 28, 2017 08:34
Base64 images with express
const express = require("express");
const app = express();
const fs = require("fs");
function base64_encode(file) {
// read binary data
return new Promise((resolve, reject) => {
fs.readFile(file, (err, data) => {
if(err){
reject(err);
@nojaf
nojaf / Tests.cs
Created April 5, 2017 06:37
MStest cheat sheet
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SampleClassLib;
using System;
using System.Windows.Forms;
namespace TestNamespace
{
[TestClass()]
public sealed class DivideClassTest
{
@nojaf
nojaf / Program.fs
Last active April 11, 2017 12:38
Giraffe Railway json parser
module redgiraffe
open System
open System.IO
open System.Text
open System.Security.Claims
open System.Collections.Generic
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Hosting
open Microsoft.AspNetCore.Http