Skip to content

Instantly share code, notes, and snippets.

View asakasinsky's full-sized avatar

Vasily Asakasinsky asakasinsky

View GitHub Profile
@asakasinsky
asakasinsky / objc-gcc.m
Created May 22, 2023 16:05 — forked from cslarsen/objc-gcc.m
How to compile Objective-C on the command line on Mac OS X
/*
* 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>
@asakasinsky
asakasinsky / jq-cheetsheet.md
Created May 15, 2023 22:51 — forked from olih/jq-cheetsheet.md
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@asakasinsky
asakasinsky / README.md
Created March 28, 2023 21:41 — forked from gideongrinberg/README.md
BNF Grammars

BNF Grammars

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

Languages:

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
@asakasinsky
asakasinsky / auth.clj
Created March 4, 2023 19:11 — forked from raek/auth.clj
HTTP Basic Authentication Ring Middleware
(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"],
@asakasinsky
asakasinsky / OpenSSL.sh
Created January 19, 2023 19:58 — forked from iamfip/OpenSSL.sh
Installing OpenSSL on Ubuntu 18.04 LTS
#!/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/
@asakasinsky
asakasinsky / compile-lynx-wasm.sh
Created January 18, 2023 15:29 — forked from Potherca/compile-lynx-wasm.sh
Steps to compile the Lynx web browser to Web Assembly
# 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
@asakasinsky
asakasinsky / ids_parser.exs
Created December 30, 2022 00:36 — forked from hauntedhost/ids_parser.exs
Elixir mp3 id3 parser
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
@asakasinsky
asakasinsky / gitlab-runner-docker.sh
Created December 30, 2022 00:32 — forked from b23prodtm/gitlab-runner-docker.sh
Setup a Unix Runner on GitLab. To perform our own gitlab-runner at home.
#!/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