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

We couldn’t find that file to show.
var server = ClientExpress.createServer();
server.configure(function() {
server.use(server.content_target_area("content"));
server.set('views', '/example/views/');
server.set('view engine', 'html');
server.register('.html', template_engine);
});
server.configure('development', function() {
@MarkNijhof
MarkNijhof / mongodb_initializer.rb
Created February 1, 2011 16:23
mongodb_initializer.rb
include MongoMapper
host = ENV['MONGODB_HOST']
port = ENV['MONGODB_PORT']
database = ENV['MONGODB_DATABASE']
username = ENV['MONGODB_USER_NAME']
password = ENV['MONGODB_PASSWORD']
MongoMapper.connection = Mongo::Connection.new(host || 'localhost',
port || 27017,