Skip to content

Instantly share code, notes, and snippets.

View zckkte's full-sized avatar

Zack A. Kite zckkte

  • Copenhagen, Denmark
View GitHub Profile
@iamarcel
iamarcel / Creating Neat .NET Core Command Line Apps.md
Last active November 28, 2023 10:41
Creating Neat .NET Core Command Line Apps

Creating Neat .NET Core Command Line Apps

You can now read this on my (pretty) website! Check it out here.

Every reason to get more HackerPoints™ is a good one, so today we're going to write a neat command line app in .NET Core! The Common library has a really cool package Microsoft.Extensions.CommandlineUtils to help us parse command line arguments and structure our app, but sadly it's undocumented.

No more! In this guide, we'll explore the package and write a really neat

module tinybasic
open System
type Expression =
| Number of int
| Variable of string
| String of string
| Binary of Expression * string * Expression
| Unary of string * Expression
@hijonathan
hijonathan / notifications.md
Created December 7, 2012 19:12
Mark a notification as read

In your email:

<img src="https://path/to/mark-as-read?notificationId=1234&source=email" width="1" height="1" />

Bonus server-side:

When that endpoint is hit from an email, delay the response for 5-10s and listen for the connection being terminated early from the client. If they make it past 5-10s, then mark the notification as read. If not, then either they skimmed it or it was a fluke request.

@ga2arch
ga2arch / prolog.hs
Created November 11, 2012 18:55
Basic prolog interpreter
module Main where
import Control.Monad.State
import Data.Char
import Data.List
import Data.Maybe
import qualified Data.Map as M
type Exprs = [Expr]
type Database = Exprs
@andkerosine
andkerosine / raskell.rb
Created August 15, 2012 05:56
Haskell-like list comprehensions in Ruby
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@
@crizCraig
crizCraig / gist:2816295
Created May 27, 2012 22:52
Download images from Google Image search using Python
import json
import os
import time
import requests
from PIL import Image
from StringIO import StringIO
from requests.exceptions import ConnectionError
def go(query, path):
"""Download full size images from Google image search.
@parse
parse / shell.c
Created May 11, 2011 07:31
Simple shell in C
/* Compile with: g++ -Wall –Werror -o shell shell.c */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
@ofan
ofan / lisp.cpp
Last active April 11, 2024 11:28
Lisp interpreter in 90 lines of C++
Lisp interpreter in 90 lines of C++
I've enjoyed reading Peter Norvig's recent articles on Lisp. He implements a Scheme interpreter in 90 lines of Python in the first, and develops it further in the second.
Just for fun I wondered if I could write one in C++. My goals would be
1. A Lisp interpreter that would complete Peter's Lis.py test cases correctly...
2. ...in no more than 90 lines of C++.
Although I've been thinking about this for a few weeks, as I write this I have not written a line of the code. I'm pretty sure I will achieve 1, and 2 will be... a piece of cake!
@sanxiyn
sanxiyn / lisp.c
Created August 14, 2010 04:16
Lisp
#include <assert.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
enum type {
NIL,
@joshaven
joshaven / vash.rb
Created September 10, 2009 21:19
Volatile Ruby Hash > Vash
#############################################################################
# Class: Vash (Ruby Volatile Hash)
# Hash that returns values only for a short time. This is useful as a cache
# where I/O is involved. The primary goal of this object is to reduce I/O
# access and due to the nature of I/O being slower then memory, you should also
# see a gain in quicker response times.
#
# For example, if Person.first found the first person from the database & cache
# was an instance of Vash then the following would only contact the database for
# the first iteration: