Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / ethereumLottery.sol
Created January 17, 2018 10:56
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.19+commit.c4cbbb05.js&optimize=false&gist=
pragma solidity ^0.4.0;
contract Lottery {
address owner = 0xf94e9009C8edC5FD7c408f944836860744cb009E;
uint public pot;
uint public winningsLimit;
uint public participantLimit;
address[] public participants;
@wilensky
wilensky / git_sm_co.sh
Last active October 15, 2019 06:10
Script checkouts each submodule on a given branch if latter exists (or fallback branch is used) and pulls if behind
#!/usr/bin/env bash
fetch=$(git fetch);
if [ "$(git show-ref refs/remotes/origin/$1)" ]; then # Checking branch for existence on remote
co=$(git checkout "$1"); # Checkouting branch that we checked for existence above
else
defaultFb="master"; # Default fallback
fb=${2:-$defaultFb} # Resulting fallback
echo "- Branch $1 does not exist. Switching to ${fb}";
@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
@fliptopbox
fliptopbox / string.compress.js
Created October 15, 2013 12:32
JavaScript String compression
/*
@fliptopbox
LZW Compression/Decompression for Strings
Implementation of LZW algorithms from:
http://rosettacode.org/wiki/LZW_compression#JavaScript
Usage:
var a = 'a very very long string to be squashed';
var b = a.compress(); // 'a veryāăąlong striċ to bečquashed'
@nikic
nikic / bench.php
Last active November 2, 2023 22:49
Benchmark of call_user_func_array vs switch optimization vs argument unpacking syntax
<?php error_reporting(E_ALL);
function test() {}
$nIter = 1000000;
$argNums = [0, 1, 2, 3, 4, 5, 100];
$func = 'test';
foreach ($argNums as $argNum) {