Skip to content

Instantly share code, notes, and snippets.

View MarkNijhof's full-sized avatar

Mark Nijhof MarkNijhof

View GitHub Profile
var get_payment_methods = function() {
var callback = function(httpRequest) {
if (httpRequest.readyState === 4) {
if (httpRequest.status >= 200 && httpRequest.status < 300) {
var response = JSON.parse(httpRequest.response);
<%= if afterpay_enabled do %>
// To make sure this only happens in Norway and Sweden
// I want to have the Afterpay method below Klarna Slice It
// or Pay Later or if neither is there on top.
@MarkNijhof
MarkNijhof / ecto_postgres_fulltext_search_querying_example.ex
Created January 21, 2020 00:09 — forked from pmarreck/ecto_postgres_fulltext_search_querying_example.ex
How to set up postgres fulltext search triggers, index, and tsvector column on Elixir/Phoenix, with Ecto querying, including ranking and sorting by rank
defmodule YourAppName.Search do
# ...
@doc """
Queries listings.
"""
def query_listings(query, current_user) do
default_scope = from l in Listing, where: l.draft == false or l.user_id == ^current_user.id, order_by: [desc: l.updated_at], limit: 50
id = _try_integer(query)
function parseQueryString() {
if (location.href.indexOf("?") === -1) return;
var sets = location.href.split("?")[1].split("&");
var source = "organic";
var medium = "";
var campaign = "";
var content = "";
for (var i = 0; i < sets.length; i++) {
var set = sets[i].split("=");
@MarkNijhof
MarkNijhof / counter.elm
Created December 20, 2016 02:45 — forked from CliffordAnderson/counter.elm
Elm Counter Example
module Main exposing (..)
import Html exposing (br, button, div, text)
import Html.Events exposing (onClick)
import Html.App exposing (beginnerProgram)
main : Program Never
main =
beginnerProgram { model = model, view = view, update = update }
@MarkNijhof
MarkNijhof / Foo.elm
Created December 11, 2016 21:41 — forked from michie1/Foo.elm
Decode Maybe type
module Foo exposing (..)
import Json.Decode exposing (..)
import Json.Decode.Pipeline exposing (..)
type alias Boat =
{ color : Maybe Color
}
@MarkNijhof
MarkNijhof / movedigiphotos.bash
Created August 2, 2016 13:18 — forked from jvhaarst/movedigiphotos.bash
Bash script to move images, based on exif data and file timestamp
#!/bin/bash
# Reads EXIF creation date from all .JPG files in the
# current directory and moves them carefully under
#
# $BASEDIR/YYYY/YYYY-MM/YYYY-MM-DD/
#
# ...where 'carefully' means that it does not overwrite
# differing files if they already exist and will not delete
# the original file if copying fails for some reason.
@MarkNijhof
MarkNijhof / osx-10.9-setup.md
Created November 3, 2015 22:04 — forked from kevinelliott/osx-10.9-setup.md
Clean Install – Mac OS X 10.9 Mavericks

Mac OS X 10.9 Mavericks

Custom recipe to get OS X 10.9 Mavericks running from scratch, setup applications and developer environment. I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install.

Install Software

The software selected is software that is "tried and true" --- software I need after any fresh install. I often install other software not listed here, but is handled in a case-by-case basis.

Install from App Store

defmodule Drive.ApiRouter do
require Logger
require Path
use Plug.Router
import Plug.Conn
plug Plug.Logger
plug Plug.Head
@MarkNijhof
MarkNijhof / does_not_work
Created November 24, 2014 21:54
erl_crash.dump
{ok, _Pid} = cberl:start_link(
cberl_default,
5,
config:couchbase_url(),
"",
"",
### Keybase proof
I hereby claim:
* I am MarkNijhof on github.
* I am marknijhof (https://keybase.io/marknijhof) on keybase.
* I have a public key whose fingerprint is 22D7 F695 E9B6 978C 2A2A 3C1C 0792 ED8F 32C5 0BDA
To claim this, I am signing this object: