Skip to content

Instantly share code, notes, and snippets.

View alexanderadam's full-sized avatar
⌨️
⌨️

Alexander ADAM alexanderadam

⌨️
⌨️
View GitHub Profile
@eregon
eregon / 0_core_methods_in_ruby.md
Last active January 30, 2024 23:15
Core library methods defined with Ruby code and with a #source_location file starting with `<internal:`, by Ruby implementation and version
Ruby Core methods written in Ruby Total number of core methods % written in Ruby
CRuby 2.3 3 1637 0.2%
CRuby 2.4 3 1636 0.2%
CRuby 2.5 6 1680 0.4%
CRuby 2.6 5 1767 0.3%
CRuby 2.7 38 1802 2.1%
CRuby 3.0 89 1830 4.9%
CRuby 3.1 112 1884 5.9%
CRuby 3.2 128 1924 6.7%
@FifiTheReal
FifiTheReal / openScale-To-weightlogger.rb
Created August 27, 2020 19:16
Convert openScale database to weightlogger new script
#!/usr/bin/ruby
# encoding: utf-8
require 'sqlite3'
if ARGV.length < 2
puts "Please give two arguments:"
puts " - arg1: OpenScale sqlite3 database (*.db)"
puts " - arg2: weightlogger sqlite3 database (*.bkp)"
puts ""
@ppoffice
ppoffice / README.md
Last active May 29, 2024 16:52
Install Visual Studio Code (actually code-server) on Android
  1. Install Termux, an Android terminal emulator that provides a Linux execution environment and various tools.

  2. Update system packages in Termux:

    $ pkg update -y
@fernandes
fernandes / 00_shard.yml
Last active November 21, 2021 22:00
[Crystal Lang] Lucky Framework + Shrine File Uploader
crystal: 0.34.0
dependencies:
lucky:
github: luckyframework/lucky
version: ~> 0.21
shrine:
github: jetrockets/shrine.cr
version: ~> 0.8
@mdchaney
mdchaney / README
Last active February 6, 2024 22:20
Fix string encoding in Ruby
This function takes a string that is in Latin-1 (ISO-8859-1), UTF-8, or plain ASCII and returns the string properly encoded as UTF-8. In addition, any Microsoft smart quotes (stupid quotes) are replaced with plain ASCII equivalents. This is useful for reading CSV files or other text files from a web upload and getting to a "known good" state.
@lbarasti
lbarasti / normal_distribution.cr
Last active May 4, 2020 14:13
Sampling random variables and plotting histograms in Crystal
require "statistics"
require "ishi"
require "tablo"
include Statistics::Distributions
# Turns a named tuple into tabular representation
def table(data : NamedTuple)
Tablo::Table.new(data.map { |k, v| [k, v] }, header_frequency: nil) { |t|
t.add_column("coefficient") { |n| n[0] }
@gimiki
gimiki / traefik_tcp_mqtt_mosquitto_docker_compose.md
Last active May 19, 2024 23:51
Traefik Reverse Proxy - Mosquitto MQTT Broker - Docker Container

This gist is to configure a Mosquitto MQTT Broker behind a Traefik reverse-proxy, both in a docker container. Mosquitto will be configuread as a TCP Service.

This is a simple configuration used on the same single server. Probably to be adapted for other cases. Having mosquitto behind a reverse proxy enables you to configure TLS on Traefik (likely you already do that for other applications as well) and to load balance different MQTT instances, but that goes beyond this gist.

As noted in Traefik docs, in the router you must use the rule HostSNI(`*`) when using non-TLS routers like in this example. Ref. https://docs.traefik.io/routing/routers/#rule_1

docker-compose.yml

Crystal on WASM

Running

  • crystal wasm.cr
  • php -S localhost:3000
  • open your browser
  • open dev tool js console
  • crystal.add(1, 2)
@mortenson
mortenson / notes.md
Last active August 26, 2023 03:35
Dell XPS 13 9300 Ubuntu setup notes

Random notes from woring with a new XPS 13 9300 with Ubuntu

Notes from when I was on the default Dell OEM Ubuntu

Disable trackpad middle click:

sudo vim /usr/share/X11/xorg.conf.d/40-libinput.conf

Add Option "ButtonMapping" "1 1 3 4 5" under

@blacksheep--
blacksheep-- / Dockerfile
Created March 11, 2020 12:26
Traefik Catch-All to return HTTP421 for unresolved routes
FROM golang:1.14-alpine
COPY . /go/src/app
WORKDIR /go/src/app
RUN go get -v -d
RUN go install
CMD ["app"]