Skip to content

Instantly share code, notes, and snippets.

@sgade
sgade / UnitElectricEnergyEfficiency.swift
Created January 11, 2023 00:26
Swift: UnitElectricEnergyEfficiency
//
// UnitElectricEnergyEfficiency.swift
//
// Created by Sören Gade on 13.12.21.
// Copyright © 2021 Sören Gade. All rights reserved.
//
import Foundation
/// A unit of measure for electric energy efficiency.
@sgade
sgade / fizzbuzz.swift
Created July 31, 2017 20:46
A small fizz buzz implementation
// add your text blocks here
// values are added based on their sorted keys
let valueRepresentations = [
3: "Fizz",
5: "Buzz"
]
let sortedKeys = valueRepresentations.keys.sorted()
func representation(of value: Int) -> String {
var output = ""
# sg-magic.zsh-theme
# Based on af-magic.zsh-theme from https://github.com/andyfleming/oh-my-zsh/blob/master/themes/af-magic.zsh-theme.
if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
# primary prompt
PROMPT='$FG[032]%~\
$(git_prompt_info) \
$FG[105]%(!.#.»)%{$reset_color%} '
@sgade
sgade / rand.go
Created November 29, 2016 09:52
Randomly output one of the input lines
// Copyright (c) 2016 Sören Gade
package main
import (
"bufio"
"fmt"
"math/rand"
"os"
"time"
)
@sgade
sgade / fib.go
Created April 17, 2016 18:24
Fibonacci with big numbers (and progress)
package main
import (
"bufio"
"fmt"
"math/big"
"os"
"strconv"
"strings"
"time"
@sgade
sgade / streaming-client.go
Created April 16, 2016 18:17
Golang streaming (http) client
package main
import (
"fmt"
"io"
"net"
"time"
)
const (
@sgade
sgade / streaming.go
Created April 16, 2016 17:12
Golang Streaming Server
package main
import (
"fmt"
"net/http"
"sync"
"time"
)
func main() {
@sgade
sgade / fibonacci.go
Created May 23, 2015 20:55
Fibonacci using Goroutines.
package main
import (
"fmt"
)
var cache map[int64]int64 = make(map[int64]int64)
func fib_useCache() bool {
return true
@sgade
sgade / link-graph.js
Created February 3, 2015 23:35
Downlink/Uplink graph
@sgade
sgade / workflow.js
Last active August 29, 2015 14:11
Get content and information about Workflows.
/*
* Workflow.js
* by: Sören Gade
*
* Extracts information from Workflow's share URLs.
*
* For more information, see their website: https://my.workflow.is/.
*/
var http = require('http'),