Skip to content

Instantly share code, notes, and snippets.

View bitmaybewise's full-sized avatar
🏠
Working from home

Hercules Merscher bitmaybewise

🏠
Working from home
View GitHub Profile
@kddnewton
kddnewton / json.rb
Last active August 7, 2023 19:54
Faster JSON parser in Ruby
# frozen_string_literal: true
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "json_pure"
gem "benchmark-ips"
end
@jhawthorn
jhawthorn / hawthjit.rb
Last active September 17, 2022 12:36
A "MJIT Custom Compiler" JIT in ~100 lines of Ruby
# $ ruby -v
# ruby 3.2.0dev (2022-09-11T14:08:14Z master 684353fc03) [x86_64-linux]
# $ ruby --mjit=pause --mjit-wait --mjit-min-calls=5 hawthjit.rb
# 246
# 246
# 246
# 246
# attempting to compile block in <main>
# can't compile putself
# attempting to compile double
@robinpokorny
robinpokorny / mirrorGitHub.sh
Last active August 19, 2022 13:26
Mirror GitHub repos locally on NAS
#!/bin/bash
# Mirrors all GitHub repositories the current user has read access to.
# See license at the end of the file.
# Token from https://github.com/settings/tokens
OAUTH_TOKEN="<TODO TOKEN>"
# where should the files be saved
DIR="<TODO PATH>"
@quelgar
quelgar / typed_errors.md
Last active January 16, 2024 09:36
Every Argument for Static Typing Applies to Typed Errors

Every Argument for Static Typing Applies to Typed Errors

Think of all the arguments you've heard as to why static typing is desirable — every single one of those arguments applies equally well to using types to represent error conditions.

An odd thing I’ve observed about the Scala community is how many of its members believe that a) a language with a sophisticated static type system is very valuable; and b) that using types for error handling is basically a waste of time. If static types are useful—and if you like Scala, presumably you think they are—then using them to represent error conditions is also useful.

Here's a little secret of functional programming: errors aren't some special thing that operate under a different set of rules to everything else. Yes, there are a set of common patterns we group under the loose heading "error handling", but fundamentally we're just dealing with more values. Values that can have types associated with them. There's absolutely no reason why the benefits of static ty

@jdegoes
jdegoes / fpmax.scala
Created July 13, 2018 03:18
FP to the Max — Code Examples
package fpmax
import scala.util.Try
import scala.io.StdIn.readLine
object App0 {
def main: Unit = {
println("What is your name?")
val name = readLine()
@satendra02
satendra02 / app.DockerFile
Last active July 12, 2024 02:39
docker+rails+puma+nginx+postgres (Production ready)
FROM ruby:2.3.1
# Install dependencies
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
# Set an environment variable where the Rails app is installed to inside of Docker image:
ENV RAILS_ROOT /var/www/app_name
RUN mkdir -p $RAILS_ROOT
# Set working directory, where the commands will be ran:
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active July 21, 2024 05:06
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@costajob
costajob / fact.cr
Last active September 20, 2022 21:15
Factorial implementation using Big numbers in Ruby, GO and Crystal
require "big_int"
def fact(n)
return 1 if n == 0
n * fact(n - 1)
end
n = BigInt.new(ARGV[0])
puts fact(n)
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm