jq is useful to slice, filter, map and transform structured json data.
brew install jq
/* | |
* To compile objective-c on the command line: | |
* | |
* gcc -framework Foundation objc-gcc.m | |
* | |
* You may have to link with -lobjc or other libs, | |
* as required. | |
*/ | |
#import <Foundation/Foundation.h> |
I'm using this gist to collect a bunch of BNF grammars I've written, extracted, or found across the web. All of them are representations of existing languages. I found them useful, someone else might as well
C
c-grammar.bnf
- An incomplete representation of the C language in BNF (from 1988, all newer versions I could find were EBNF or PEG. Let me know if you have a better one.)
Adapted from The C Programming Language, 2nd edition, by Brian W. Kernighan and Dennis M. Ritchie,Prentice Hall, 1988.
(ns git-example | |
(:require [clojure.java.shell :as shell] | |
[clojure.string :as string])) | |
(defn run-command [command & {:keys [directory] :or {directory (System/getProperty "user.dir")}}] | |
(shell/with-sh-dir directory | |
(shell/sh "sh" "-c" command))) | |
(defn resolve-command [command & [args]] | |
(reduce |
(ns se.raek.rhea.auth | |
(:use [ring.util.codec :only (base64-decode)])) | |
(defn parse-credentials | |
"Extracts the user name and password from a HTTP Basic Authentication header | |
value and returns them in a vector. | |
Example: | |
(parse-credentials \"Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\") | |
=> [\"Aladdin\" \"open sesame\"]" |
# Copy the following and place it a file called Leiningen.sublime-build in the Sublime user packages folder (~/.config/sublime-text-2/Packages/User on Linux). | |
# Select this as the build system for the project using Tools/Build System/Leiningen. | |
# You can then bring up the Sublime Command Palette (ctrl+shift+P on Windows/Linux) and issue any of the commands # (build, documentation, clean, run, test, etc). By default, build is bound to ctrl+b and run to ctrl+shift+b. | |
{ | |
"cmd": ["lein", "compile", ":all"], | |
"working_dir": "$project_path", | |
"variants": [ | |
{ "cmd": ["lein", "marg", "-m", "-d", "docs"], |
#!/bin/sh | |
sudo apt-get update && sudo apt-get upgrade | |
openssl version -a | |
#Install the necessary packages for compiling | |
sudo apt install build-essential checkinstall zlib1g-dev -y | |
#Download OpenSSL | |
cd /usr/local/src/ |
# Sources used in figuring this out: | |
# | |
# - https://developer.mozilla.org/en-US/docs/WebAssembly/C_to_wasm | |
# - https://emscripten.org/docs/compiling/Building-Projects.html#building-projects | |
# Set up Emscripten SDK | |
git clone https://github.com/emscripten-core/emsdk.git | |
cd emsdk/ | |
./emsdk install latest | |
./emsdk activate latest |
defmodule Id3Parser do | |
@id3_tag_size 128 | |
def parse(file_name) do | |
case File.read(file_name) do | |
{:ok, mp3} -> | |
# mp3 size minus 128 bytes where id3 tag is located | |
mp3_byte_size = byte_size(mp3) - @id3_tag_size |
#!/usr/bin/env bash | |
# to enable all branches, remove .gitlab-ci only:[/pr-*/] tags | |
shared=/srv | |
[ ! -e /etc/os-release ] && shared=/Users/Shared && echo "Not a Linux system.. srv=$shared" | |
shared_tags='light, docker, c3.small.x86' | |
PROJECT_REGISTRATION_TOKEN='' | |
[ "$#" -gt 0 ] && PROJECT_REGISTRATION_TOKEN=$1 | |
printf "token PROJECT_REGISTRATION_TOKEN=%s\n" "${PROJECT_REGISTRATION_TOKEN}" | |
gitlab=$(docker ps -q -a -f "name=gitlab-runner") | |
[ "$gitlab" != "" ] && docker stop $gitlab && docker rm -f $gitlab |