Skip to content

Instantly share code, notes, and snippets.

View utkarshkukreti's full-sized avatar

Utkarsh Kukreti utkarshkukreti

View GitHub Profile
@alpacaaa
alpacaaa / Explanation.md
Last active December 2, 2021 08:00
Hard things about ports being Tasks in Elm

evancz Mar 23, 2017 00:43
Just so folks are aware, one of the hard things about having ports just be a Task is the following. Right now, a Task is guaranteed to terminate with an error or a result. The only way it could be otherwise is if you have something of type Task Never Never Now, if you are calling out to random JS that is written by anyone, that guarantee goes away. You have to call some callback to give the value back to Elm, but what if that is never called? Maybe there's an error, maybe there is a weird code path. Now Elm code can "leak" tasks that never get completed because of problems in JS code. One way to protect against this is to have timeouts, such that there is some guaranteed end. My point here is just that it is more complicated than "what if it was a task?" and then everything would be nice.

@pelotom
pelotom / existential.ts
Last active May 18, 2022 10:08
Encoding of existential types in TypeScript
type StackOps<S, A> = {
init(): S
push(s: S, x: A): void
pop(s: S): A
size(s: S): number
}
type Stack<A> = <R>(go: <S>(ops: StackOps<S, A>) => R) => R
const arrayStack = <A>(): Stack<A> =>
@deep-spaced
deep-spaced / snake_case.ex
Last active April 23, 2016 01:05
A series of solutions to the snake_case problem posed by @jackc's at ACR 2016.
# From the ACR 2016 coding challenge.
defmodule SnakeCase do
@doc """
Brute force, single process.
"""
def single do
range = 0..round(:math.pow(2, 20))
count = Enum.count(range, fn x -> check_one_bits(x) == 10 end)
@omnibs
omnibs / phoenix showdown rackspace onmetal io.md
Last active January 25, 2023 18:33
Phoenix Showdown Comparative Benchmarks @ Rackspace

Comparative Benchmark Numbers @ Rackspace

I've taken the benchmarks from Matthew Rothenberg's phoenix-showdown, updated Phoenix to 0.13.1 and ran the tests on the most powerful machines available at Rackspace.

Results

Framework Throughput (req/s) Latency (ms) Consistency (σ ms)
digraph widening {
node [style=filled, colorscheme=pastel13, color=2] "i8"; "i16"; "i32"; "i64";
node [style=filled, colorscheme=pastel13, color=3] "u8"; "u16"; "u32"; "u64";
"i8" -> "i16"
"i8" -> "i32"
"i8" -> "i64"
"i16" -> "i32"
"i16" -> "i64"
"i32" -> "i64"
Alien = class()
-- Free game by juaxix
-- http://www.xixgames.com
-- Copyright LGPL - 11/2011
function Alien:init(avoidy)
self.position = vec2(0,math.max(math.abs(math.random(HEIGHT)-avoidy)),66)
self.angle = math.pi
self.points= 500
end
import System.Directory
import System.Environment
import System.FilePath
import Control.Applicative ((<$>))
import Control.Arrow (first, second)
import Control.Monad (void)
import Data.Either (rights)
import Data.List (isSuffixOf)
import Data.Set (Set, (\\), empty, fromList, insert, singleton, toList, union)
import Text.Parsec
@bvssvni
bvssvni / gist:9674632
Last active December 23, 2023 22:56
A Rust Chain Macro
//! Chain macro in Rust
//!
//! A typical usage is to avoid nested match expressions.
//!
//! Supports:
//! - Pattern matching
//! - Or expressions (A | B => ...)
//! - Guarded statements (x if <cond> => ...)
//! - Implicit else (requires all arms to return same type)
@sneak
sneak / gist:8166630
Created December 29, 2013 01:58
exclude patterns for OS apps in /Applications
EX=""
EX+=" --exclude=.DS_Store"
EX+=" --exclude=/iBooks.app/"
EX+=" --exclude=/iTunes.app/"
EX+=" --exclude=/FaceTime.app/"
EX+=" --exclude=/Calendar.app/"
EX+=" --exclude=/Mail.app/"
EX+=" --exclude=/QuickTime?Player.app/"
EX+=" --exclude=/Safari.app/"
EX+=" --exclude=/Preview.app/"
@hgfischer
hgfischer / benchmark+go+nginx.md
Last active April 11, 2024 22:09
Benchmarking Nginx with Go

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI