Skip to content

Instantly share code, notes, and snippets.

View marco-m's full-sized avatar
🥕

Marco Molteni marco-m

🥕
View GitHub Profile
@esauser
esauser / build.bat
Created May 6, 2019 19:13
Concourse Windows Worker
@echo off
nuget restore -Verbosity normal
if %errorlevel% neq 0 exit /b %errorlevel%
msbuild -p:Configuration=Release ^
-p:WarningLevel=0
if %errorlevel% neq 0 exit /b %errorlevel%
dotnet.exe test TestProject.csproj --configuration Release --no-build -v n
@jbrown123
jbrown123 / -Recursive Queries Using Common Table Expressions.md
Last active August 18, 2025 10:49
Creating arbitrary-depth recursive queries in SQLITE (works for any SQL compliant system) using CTEs (common table expressions)

Recursive Queries Using Common Table Expressions

Common Table Expressions (CTEs) are a bit complex and difficult to understand at first blush. Many of the tutorials and examples on the net don't make it any easier for those just starting out. I thought I'd put together a quick gist that tries to simplify the concept and demonstrate how to do recursive queries using CTEs.

Keep in mind that CTEs have other uses besides just recursive queries but this gist is just about how they can be used to create recursive searches.

I'm using SQLite in this example but any SQL language that implements the WITH keyword should be able to do the same thing. If you've never used SQLite before, you are missing out on an amazing, open source, stand alone, SQL engine. I encourage you to check it out.

A practical example

@peterhellberg
peterhellberg / graceful.go
Last active November 13, 2024 20:20
*http.Server in Go 1.8 supports graceful shutdown. This is a small example.
package main
import (
"context"
"log"
"net/http"
"os"
"os/signal"
"time"
)
@efcasado
efcasado / eqc.md
Last active January 16, 2025 16:22
A gentle introduction to (Erlang) QuickCheck

Erlang QuickCheck

What is QuickCheck?

QuickCheck is a language for stating properties of programs.

?FORALL(X, nat(), X*X >= 0)
odessa(~/src/github.com/pkg/mach) % cat sys_darwin_amd64.s
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// System calls and other sys.stuff for AMD64, Darwin
// See http://fxr.watson.org/fxr/source/bsd/kern/syscalls.c?v=xnu-1228
// or /usr/include/sys/syscall.h (on a Mac) for system call numbers.
//
@rjattrill
rjattrill / multiline-values.yaml
Created November 18, 2013 06:33
Break YAML over multiple lines
# Join multiple lines without new line
value: >
part 1
part 2
# Join with newline
value2: |
line 1
line 2
@maxlapshin
maxlapshin / tcp_bench.erl
Created April 5, 2012 10:37
gen_tcp:send vs port_command
-module(bench).
-compile(export_all).
-define(COUNT, 1000).
-define(SIZE, 10000).
-define(PORT, 9001).
read_all(Socket, Limit) when Limit > 0 ->
case gen_tcp:recv(Socket, 100*?SIZE) of
{ok, Bin} ->
@blacktaxi
blacktaxi / ruby-fmt.clj
Created January 25, 2012 14:42
Ruby-like string interpolation in Clojure
; Ruby has an awesome feature -- string interpolation. Read about it on the internet.
; On the other hand, Clojure only has cumbersome Java string formatting, which can not be
; used without pain after you've tried Ruby.
; So here's this simple macro that basically allows you to do most things you could do
; with Ruby string interpolation in Clojure.
(ns eis.stuff
(:require [clojure.string]))
@darrenderidder
darrenderidder / bashpath.sh
Created May 16, 2011 15:24
Get path of running script in bash
#!/bin/bash
# A simple test script to demonstrate how to find the
# "absolute path" at which a script is running. Used
# to avoid some of the pitfals of using 'pwd' or hard-
# coded paths when running scripts from cron or another
# directory.
#
# Try it out:
# run the script from the current directory, then