Skip to content

Instantly share code, notes, and snippets.

View owickstrom's full-sized avatar

Oskar Wickström owickstrom

View GitHub Profile
@owickstrom
owickstrom / protocols.go
Last active April 11, 2016 12:06
Protocols sketches for Oden
//----------//
// SEMIRING //
//----------//
// Types that support addition and multiplication.
protocol Semiring(a) {
add : a -> a -> a
zero : a
mul : a -> a -> a
one : a
@owickstrom
owickstrom / based-on-existing-syntax.lisp
Last active January 22, 2016 08:52
Alternate syntax
(pkg main)
(import fmt)
;; if expressions
(: fib (int -> int))
(def (fib n)
(if (== n 1)
0
(if (== n 2)
@owickstrom
owickstrom / defer.go
Last active December 23, 2015 07:09
Going Async in Go
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
syslog, err := os.Open("/var/log/system.log")
@owickstrom
owickstrom / create_user.rake
Last active December 18, 2015 09:58
This is an update of https://gist.github.com/svanzoest/4028058 for Gitlab 5.2.0.
# gitlab 5.2.0 create user
# rake create_user["john@doe.com","johndoe","John Doe"] RAILS_ENV=production
desc "Create new user"
task :create_user, [:email, :username, :name] => :environment do |t, args|
puts "creating user '" + args.username + "' ('" + args.name + "') with email '" + args.email + "'"
@user = User.new({ email: args.email, name: args.name, username: args.username, force_random_password: true, projects_limit: 10 }, as: :admin)
if @user.save
puts "success"
else
@owickstrom
owickstrom / GetFromTo.cs
Created December 30, 2012 14:27
Possible solution (not tested)
public virtual IEnumerable<Commit> GetFromTo(DateTime start, DateTime end)
{
this.ThrowWhenDisposed();
Logger.Debug(Resources.GettingAllCommitsFromToTime, start, end);
var selectedCommitIds = this.stamps.Where(x => x.Value >= start && x.Value < end).Select(x => x.Key);
var firstCommitId = selectedCommitIds.FirstOrDefault();
var lastCommitId = selectedCommitIds.LastOrDefault();
if (lastCommitId == Guid.Empty && lastCommitId == Guid.Empty)
@owickstrom
owickstrom / README.md
Last active October 27, 2015 08:46
Kashmir Programming Language - Draft
@owickstrom
owickstrom / type-system.rkt
Created October 12, 2015 06:14
Minimalistic type system hack in Racket.
#lang racket
(require "minikanren/mk.rkt")
(struct e/var (name) #:transparent)
(struct e/app (fn param) #:transparent)
(struct e/lam (arg body) #:transparent)
(define (t/fn domain range)
(list ':fn domain range))
@owickstrom
owickstrom / Thing.cs
Created October 17, 2012 07:54
A simple Continuous Integration and Deployment workflow with ASP.NET MVC, GitHub and Jenkins (Changing the model)
public class Thing
{
public long ThingId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}
(ns scratch.core
(:require [clojure.core.typed :as t]))
(t/defalias DropboxEntry
(t/Rec [x]
(t/U '{:type (Value :file)
:path String
:mime-type String}
'{:type (Value :directory)
:path String
{
"graph": {
"label": "Some Title",
"metadata": {
"id": "uc1"
},
"nodes": [
{
"id": "user",
"label": "User",