Skip to content

Instantly share code, notes, and snippets.

View gmichokostas's full-sized avatar

Yiorgos Michokostas gmichokostas

View GitHub Profile
module GuessTheNumber where
import System.Random
startGame :: IO ()
startGame = do
let tries = 5
num <- randomRIO (0, 9) :: IO Int
makeGuess num tries
@gmichokostas
gmichokostas / stack.go
Last active August 15, 2017 19:04
LIFO Stack implemented with Go
package stack
import "fmt"
// Stack is a LIFO data structure
type Stack struct {
len int
top *node
}
#include <iostream>
using namespace std;
auto upto(int& beg, int& end) -> decltype(std::function<int()>()) {
return [&]() {
if (beg <= end) {
return beg++;
}
return 0;
@gmichokostas
gmichokostas / pgstore.rb
Created July 6, 2023 18:36 — forked from noteflakes/pgstore.rb
A lightweight PostgreSQL ORM using JSONB. Provides an API for retreiving documents by arbitrary key, and performing queries on arbitrary keys and sub-keys.
require 'pg'
PGDB = PG.connect(host: '/tmp', dbname: 'mydb')
PGDB.type_map_for_results = PG::BasicTypeMapForResults.new(PGDB)
class Hash
def symbolize_keys
inject({}) { |m, kv| v = kv[1];
m[kv[0].to_sym] = v.is_a?(Hash) ? v.symbolize_keys : v; m }
end
end