Skip to content

Instantly share code, notes, and snippets.

:- module(sudoku, [solve/1, print_puzzle/1]).
:- use_module(library(apply)).
:- use_module(library(apply_macros)).
:- use_module(library(clpfd)).
:- use_module(library(list_util), [split_at/4, iterate/3]).
:- use_module(library(lists), [append/2]).
:- use_module(library(yall)).
blocks(_, [], []) :- !.
@jamesnvc
jamesnvc / unicode_input.py
Created January 12, 2018 19:32
Linux Unicode input
#!/usr/bin/env python3
"""
Emulate Gnome's Unicode input method.
Requires `pyxhook` and `xdotool` to be installed
`pip install pyxhook`
`sudo apt-get install xdotool`
"""
@jamesnvc
jamesnvc / classes.js
Last active April 12, 2019 14:31
LHL W6D5 - 2019-04-12
class ShoppingCart {
constructor(name) {
this.name = name;
this.items = [];
}
addItem(item) {
this.items.unshift(item);
}
@jamesnvc
jamesnvc / 1password2pass.rb
Last active March 9, 2018 02:10
Enhancement of the default script to also include OTP keys
#!/usr/bin/env ruby
# Copyright (C) 2014 Tobias V. Langhoff <tobias@langhoff.no>. All Rights Reserved.
# This file is licensed under GPLv2+. Please see COPYING for more information.
#
# 1Password Importer
#
# Reads files exported from 1Password and imports them into pass. Supports comma
# and tab delimited text files, as well as logins (but not other items) stored
# in the 1Password Interchange File (1PIF) format.
@jamesnvc
jamesnvc / things.sh
Created January 27, 2017 17:14
Shell script template to only act on "clean" git repos
#!/bin/bash
set -euo pipefail
set +e
if ! git diff-files --quiet --ignore-submodules ; then
echo "Uncommited changes; stash or commit before deploying"
exit 1
fi
if ! git diff-index --cached --quiet HEAD --ignore-submodules ; then
@jamesnvc
jamesnvc / perlin.cljc
Last active November 29, 2016 18:47
Perlin noise in Clojure(Script) (based on eevee's implementation)
(ns spacebaluch.perlin)
; Based on eevee's implementation
; https://gist.github.com/eevee/26f547457522755cb1fb8739d0ea89a1
; and blog post
; https://eev.ee/blog/2016/05/29/perlin-noise/
(def sqrt
#?(:cljs js/Math.sqrt
:clj #(Math/sqrt %)))
@jamesnvc
jamesnvc / Dvorak-LCD.kbd.json
Created November 17, 2016 01:09 — forked from tremby/Dvorak-LCD.kbd.json
Dvorak LCD
[
{
"backcolor": "#ffffff",
"name": "Dvorak LCD",
"author": "Bart Nagel",
"background": {
"name": "Maple orange",
"style": "background-image: url('/bg/wood/maple-orange.jpg');"
},
"switchMount": "alps",
@jamesnvc
jamesnvc / ViewController.swift
Created February 17, 2016 15:45
Core Animation demo
//
// ViewController.swift
// AnimDemo
//
// Created by James Cash on 17-02-16.
// Copyright © 2016 Occasionally Cogent. All rights reserved.
//
import UIKit
/*****************************************************
* SLADE Configuration File
* Don't edit this unless you know what you're doing
*****************************************************/
cvars
{
archive_load_data 0
elist_colname_width 80
elist_colsize_width 64
(ns blog.precompile
(:require [me.raynes.fs :as fs]
[cljs.closure :as cljsc]
[clojure.java.io :as io])
(:import [javax.script ScriptEngineManager ScriptException]))
(defn eval-js
[js]
(let [engine (.getEngineByName (ScriptEngineManager. ) "nashorn")]
(.eval engine js)))