Skip to content

Instantly share code, notes, and snippets.

View nightscape's full-sized avatar

Martin Mauch nightscape

View GitHub Profile

Keybase proof

I hereby claim:

  • I am nightscape on github.
  • I am martin_mauch (https://keybase.io/martin_mauch) on keybase.
  • I have a public key ASANKmCnGWQPuICUpO04ADSCDuaZNEwurtN66RO1XXzD4Qo

To claim this, I am signing this object:

@nightscape
nightscape / zmv-examples.md
Last active February 28, 2023 20:39 — forked from niksmac/zmv-examples.md
ZMV-Examples (require autoload zmv)

rename a section of a filename, i. e. example.1.{txt,conf,db} or 12345.1.{wav,ogg,mp3} and change the 1 to a 2 in the filename while preserving the rest of it.

  zmv -n '(*.)(<->)(.[^.]#)' '$1$(($2+1))$3' # would rename x.0001.y to x.2.y.
  zmv -n '(*.0#)(<->)(.[^.]#)' '$1$(($2+1))$3'

Rename files to lower case

  $ zmv '*' '${(L)f}'
@nightscape
nightscape / scoop-updated-manifests.nu
Last active January 30, 2023 09:16
Querying the description of recently update Scoop manifests in NuShell
git diff (git log -1 --before=@{5.days.ago} --format=%H) --stat | parse -r "bucket/(?P<mani>.*?)\\.json .*" | insert description { |m| open --raw $"bucket/($m.mani).json" | from json | get description } | insert homepage { |m| open --raw $"bucket/($m.mani).json" | from json | get homepage }
@nightscape
nightscape / Json.xtext
Last active December 27, 2022 10:30
Xtext grammar for JSON documents
grammar org.json.Json with org.eclipse.xtext.common.Terminals
generate json "http://www.json.org/"
Object:
'{' ((members+=Member) (',' members+=Member)*)? '}';
Member:
key=STRING ':' value=Value;
@nightscape
nightscape / Example.java
Created October 21, 2016 19:59
Simple RxJava-based adapter for an Android RecyclerView
public class ReactiveTextViewHolder<T> extends ReactiveViewHolder<T> {
private TextView label;
private T currentItem;
public ReactiveTextViewHolder(View itemView) {
super(itemView);
label = (TextView) itemView.findViewById(android.R.id.text1);
}
@nightscape
nightscape / bone_mac.kbd
Created November 5, 2021 08:12
KMonad BONE Keyboard layout
(defcfg
;; For Linux (set your device input file here)
;; input (device-file "/dev/input/by-path/platform-i8042-serio-0-event-kbd")
;; output (uinput-sink "KMonad output"
;; "/bin/sleep 1 && /bin/setxkbmap us -option compose:ralt")
;; For Windows
;; input (low-level-hook)
;; output (send-event-sink)
console.log("It works");
@nightscape
nightscape / sexp.peg
Created August 16, 2012 18:27
S-Expression grammar for PEG.js
/*
* Grammar to generate an S-Expressions parser for Javascript using http://pegjs.majda.cz/
*/
start
= expression*
integer "integer"
= digits:[0-9]+ { return parseInt(digits.join(""), 10); }
@nightscape
nightscape / simple_cors_server.py
Last active January 30, 2021 22:31 — forked from acdha/simple_cors_server.py
Python 3: serve the current directory as HTTP while setting CORS headers for XHR debugging
#!/usr/bin/env python3
# encoding: utf-8
"""Use instead of `python3 -m http.server` when you need CORS"""
from http.server import HTTPServer, SimpleHTTPRequestHandler
class CORSRequestHandler(SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header('Access-Control-Allow-Origin', '*')
@nightscape
nightscape / ConvertUtils.scala
Created March 31, 2015 23:46
Parquet to CSV
import ComparisonChain._
import java.io.BufferedInputStream
import java.io.BufferedOutputStream
import java.io.BufferedReader
import java.io.BufferedWriter
import java.io.Closeable
import java.io.File
import java.io.File
import java.io.FileInputStream
import java.io.FilenameFilter