Skip to content

Instantly share code, notes, and snippets.

View DarrenN's full-sized avatar
🌵
(on-a vision-quest)

Darren DarrenN

🌵
(on-a vision-quest)
View GitHub Profile
@DarrenN
DarrenN / index.html
Created October 18, 2024 11:03 — forked from egeozcan/index.html
image viewer
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fullscreen Image Viewer</title>
<style>
body {
font-family: Arial, sans-serif;
}
@DarrenN
DarrenN / LiftFunctorDataThing.js
Created September 14, 2018 16:40
Pull a field from an object and set the object to the value of that field in a new object
// needs ramda.js
const enclose = curry((a, obj) => objOf(prop(a, obj))(obj))
var example = {'id': '123', 'foo': 'bar'};
enclose('id', example)
// {"123": {"foo": "bar", "id": "123"}}
@DarrenN
DarrenN / logging.rkt
Created May 13, 2018 13:46 — forked from Metaxal/logging.rkt
Simple usage of Racket's logging facility
#lang racket/base
; One way to define a logger
(define lg (make-logger 'my-logger))
; Define a receiver for this logger, along with a log level
(define rc (make-log-receiver lg 'error)) ; also try with 'debug
; Another way to define a logger, with additional forms
(define-logger lg2)
(define rc2 (make-log-receiver lg2-logger 'debug))
@DarrenN
DarrenN / net-lens.rkt
Created January 21, 2018 20:25
Fun with Lenses, structs and net/url in Racket
#lang racket/base
(require json
lens
net/url
net/url-string
net/head
racket/dict
racket/string)
@DarrenN
DarrenN / trace.log-rkt
Created September 1, 2017 17:30 — forked from greghendershott/trace.log-rkt
Make racket/trace output go to a logger
#lang racket/base
(require racket/format
racket/list
racket/match
racket/trace)
(provide (all-defined-out)
(all-from-out racket/trace))
@DarrenN
DarrenN / find-node.el
Created January 7, 2017 16:16
Dynamically add your Node.js bin path to exec-path in Spacemacs
(defun dotspacemacs/user-init ()
;; Use whatever node is available
(setq node-path (mapconcat
'identity
(butlast (split-string (executable-find "node") "\\/")) "/"))
(add-to-list 'exec-path node-path t))
@DarrenN
DarrenN / js_http_code_constants.js
Last active October 27, 2016 23:56
HTTP Codes as ES6 Constants
// Success 2xx
export const HTTP_200_OK = 200;
export const HTTP_201_CREATED = 201;
export const HTTP_202_ACCEPTED = 202;
export const HTTP_203_NON_AUTHORITATIVE_INFORMATION = 203;
export const HTTP_204_NO_CONTENT = 204;
export const HTTP_205_RESET_CONTENT = 205;
export const HTTP_206_PARTIAL_CONTENT = 206;
export const HTTP_207_MULTI_STATUS = 207;
syntax where = function(ctx) {
const binaryOps = ["or", "and", "==", ">", "<", "-", "+", "*", "/", "."];
const dummy = #`dummy`.get(0);
function matchNext(names) {
const marker = ctx.mark();
const next = ctx.next();
ctx.reset(marker);
return !next.done && names.includes(next.value.val());
}
@DarrenN
DarrenN / sexprs.peg
Last active December 4, 2015 00:51
PEG Sexprs
{
function getType(def, head) {
switch (head) {
case "and":
case "or":
case "not":
return "booleanOperator";
case "eq":
case "ne":
@DarrenN
DarrenN / get-npm-package-version
Last active October 25, 2024 17:37 — forked from yvele/get-npm-package-version.sh
Extract version from package.json (NPM) using bash / shell
# Version key/value should be on his own line
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
echo $PACKAGE_VERSION