Skip to content

Instantly share code, notes, and snippets.

View nouse's full-sized avatar

Mike Wu nouse

View GitHub Profile
@nouse
nouse / get-environments.sh
Created October 13, 2020 09:13 — forked from natemccurdy/get-environments.sh
Get the list of environments known to a puppet master
#!/bin/bash
# GIST_URL: https://gist.github.com/natemccurdy/65676368168708810c29
# Get the list of classes that the Puppetserver knows about.
# https://docs.puppetlabs.com/puppet/latest/reference/http_api/http_environments.html
CERT="$(puppet agent --configprint hostcert)"
CACERT="$(puppet agent --configprint localcacert)"
PRVKEY="$(puppet agent --configprint hostprivkey)"
OPTIONS="--cert ${CERT} --cacert ${CACERT} --key ${PRVKEY}"
MASTER="$(puppet agent --configprint server)"
@nouse
nouse / FIB_BENCH_RESULT_LINUX
Last active January 27, 2022 15:40
Fibonacci benchmark correctly in Golang and Ruby
wujiang@jiang-docker:~$ ruby fib.rb
Warming up --------------------------------------
iterate adding 100000
1.000 i/100ms
fast doubling 100000 168.000 i/100ms
matrix multiplying 100000
37.000 i/100ms
Calculating -------------------------------------
iterate adding 100000
4.113 (± 0.0%) i/s - 21.000 in 5.107523s
@nouse
nouse / code.zip
Last active August 5, 2016 15:32
code sample
@nouse
nouse / queens.go
Last active May 24, 2016 01:39
8 queens puzzle in Go
package main
import (
"bytes"
"fmt"
"math/rand"
"os"
"time"
)
@nouse
nouse / knight.go
Created May 23, 2016 13:28
solve knight touring problem
package main
import (
"bytes"
"fmt"
"math/rand"
"os"
"sort"
"time"
)
name: GistAPI
version: 0.1.0.0
synopsis: GistAPI with swagger support
description: Please see README.md
homepage: https://gist.github.com/nouse/ab3d5ac15558170a0952/edit
license: BSD3
author: Jiang Wu
copyright:
category: Web
build-type: Simple
@nouse
nouse / Upgrate2Swagger2.1.markdown
Created July 29, 2015 03:47
Changes after upgrade to Swagger 2.1
  1. datetime and url types are not supported datetime should change to {type: "string", format: "date-time"}, and url is not fallback to string.

  2. loginEndPoint before is a hash with key url, now is a string

  3. initOAuth method, now requires clientSecret, even with implicit flow

  4. now SwaggerUi should be initiated with validatorUrl: null in development mode

@nouse
nouse / aop.rb
Created March 8, 2015 02:56
ruby AOP
class A
def a
puts "a"
end
end
module Logger
def log(method_name)
m = self.instance_method(method_name)
undef_method method_name
module BM
def self.search(haystack, needle)
Pattern.new(needle).search(haystack)
end
class Pattern < BasicObject
def initialize(needle)
@needle = needle
@length = @needle.length
generate_good_suffices
@nouse
nouse / Gemfile
Last active May 12, 2018 14:38
Roda Server Push Demo
source 'https://rubygems.org'
gem 'roda'
gem 'typhoeus'
gem 'thin'