Skip to content

Instantly share code, notes, and snippets.

@funcmike
funcmike / generate.go
Created September 5, 2024 06:28 — forked from dontlaugh/generate.go
generate random ipv4 address in go
func randomIPFromRange(cidr string) (net.IP, error) {
GENERATE:
ip, ipnet, err := net.ParseCIDR(cidr)
if err != nil {
return nil, err
}
@funcmike
funcmike / sql
Created July 11, 2023 12:59 — forked from rpbouman/sql
select concat(
'mysqldump'
, ' --user=wcm_dwh'
, ' --password=wcm_dwh'
, ' --no-create-info'
, ' --where="'
, case p2.partition_method
when 'hash' then
concat(
p2.partition_expression, ' % '
@funcmike
funcmike / aproducer.py
Created May 14, 2023 07:48 — forked from dabeaz/aproducer.py
"Build Your Own Async" Workshop - PyCon India - October 14, 2019 - https://www.youtube.com/watch?v=Y4Gt3Xjd7G8
# aproducer.py
#
# Async Producer-consumer problem.
# Challenge: How to implement the same functionality, but no threads.
import time
from collections import deque
import heapq
class Scheduler:
@funcmike
funcmike / tic-tac-toe-io.fsx
Created September 3, 2022 14:01 — forked from mjgpy3/tic-tac-toe-io.fsx
Tic Tac Toe IO
type Letter = | X | O
type Value =
| Unspecified
| Letter of Letter
type OneThroughThree = | One | Two | Three
type Row = Value*Value*Value
@funcmike
funcmike / irssi twitch.txt
Created January 22, 2021 22:37 — forked from lambdan/irssi twitch.txt
Twitch chat with irssi - June 2020
Tested working 15 Jun 2020, irssi version 1.2.2
This is a TLDR version of https://blog.crunchprank.net/connecting-to-twitch-chat-via-irssi/
Get your OAuth token (password) here: https://twitchapps.com/tmi/
# Network setup:
/network add -nick YOUR_TWITCH_USERNAME Twitch
/server add -auto -ssl -network Twitch irc.chat.twitch.tv 6697 YOUR_OAUTH_TOKEN
@funcmike
funcmike / richhickey.md
Created July 24, 2019 19:49 — forked from prakhar1989/richhickey.md
richhickey.md

Rich Hickey on becoming a better developer

Rich Hickey • 3 years ago

Sorry, I have to disagree with the entire premise here.

A wide variety of experiences might lead to well-roundedness, but not to greatness, nor even goodness. By constantly switching from one thing to another you are always reaching above your comfort zone, yes, but doing so by resetting your skill and knowledge level to zero.

Mastery comes from a combination of at least several of the following:

@funcmike
funcmike / output-transparent-pixel.go
Created January 12, 2019 22:12 — forked from RobinUS2/output-transparent-pixel.go
Output a 1x1 transparent gif pixel in Go webserver response. Please note, this is only the relevant code, does not work "out-of-the-box".
import (
"fmt"
"net/http"
"time"
)
const transPixel = "\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B"
func pixelHandler(w http.ResponseWriter, r *http.Request) {
// Pixel
@funcmike
funcmike / ants.clj
Created September 12, 2018 08:06 — forked from michiakig/ants.clj
Clojure ant sim from Rich Hickey
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
; which can be found in the file CPL.TXT at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
;dimensions of square world