Skip to content

Instantly share code, notes, and snippets.

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

supermomonga supermomonga

🏠
Working from home
View GitHub Profile
@iamarcel
iamarcel / Creating Neat .NET Core Command Line Apps.md
Last active November 28, 2023 10:41
Creating Neat .NET Core Command Line Apps

Creating Neat .NET Core Command Line Apps

You can now read this on my (pretty) website! Check it out here.

Every reason to get more HackerPoints™ is a good one, so today we're going to write a neat command line app in .NET Core! The Common library has a really cool package Microsoft.Extensions.CommandlineUtils to help us parse command line arguments and structure our app, but sadly it's undocumented.

No more! In this guide, we'll explore the package and write a really neat

@valyala
valyala / README.md
Last active March 20, 2025 08:44
Optimizing postgresql table for more than 100K inserts per second

Optimizing postgresql table for more than 100K inserts per second

  • Create UNLOGGED table. This reduces the amount of data written to persistent storage by up to 2x.
  • Set WITH (autovacuum_enabled=false) on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we never DELETE or UPDATE the table).
  • Insert rows with COPY FROM STDIN. This is the fastest possible approach to insert rows into table.
  • Minimize the number of indexes in the table, since they slow down inserts. Usually an index on time timestamp with time zone is enough.
  • Add synchronous_commit = off to postgresql.conf.
  • Use table inheritance for fast removal of old data:
;;;; design
;;; (enable-literal-hash) => T ; implementation dependent.
;;; (gethash :a #H((:a . :b))) => :B ; T
;;; (princ #H((:a . :b)))
;;; #H((:a . :b)) ; side effect.
;;; => #<HASHTABLE 12345678>
(in-package :cl-user)
(defpackage :literal-hash(:use :cl)

.NET Coreコードリーディングことはじめ

このエントリはWindows & Microsoft技術 基礎 Advent Calendar 2015の6日目です。

.NETのトラブルシュートをしたり、実装に興味があったり、日々の仕事に疲れた心への癒やしとして、.NETの実装を見たいことがあると思います。このエントリでは、そういった方向けに簡単なガイドを提供します。

前提と対象

.NETの実装は色々あるのですが、この記事では.NET 5向けの実装についての話をします。それ以前のMicrosoft実装については、クラスライブラリ部分のみリファレンスソースとして公開されているので、そちらを参照すると良いでしょう(ランタイムそのもののソースコードは公開されていません)。ライセンスもMITライセンスなので安心です。ただし、クライアント側(Windows FormsやWPF)のコードはgithubには公開されておらず、Microsoftのサイトで公開されており、そのライセンスはMicrosoft Reference Source Licenseとなっていますので、デバッグや相互運用性の向上を目的としない使用には注意が必要です。XamarinやUnityで使っているMonoについては、素直にMonoのソースツリーを見ればいいでしょう。ただし、クラスライブラリはMITライセンスですが、ランタイムはLGPLなので、人によっては注意が必要かもしれません。

@tristanm
tristanm / README.md
Last active November 22, 2024 15:47
Migrating a Rails project from MySQL to PostgreSQL

Migrating a Rails project from MySQL to PostgreSQL

This brief guide is written from my own experience with migrating a large (~5GB) MySQL database to PostgreSQL for a Rails project.

No warranties, guarantees, support etc. Use at your own risk and, as always, ENSURE YOU MAKE BACKUPS FIRST!

I chose [pgloader][1] because it's extremely fast. YMMV.

  1. Replace mysql2 gem with pg in Gemfile.
  2. Update config/database.yml for PostgreSQL. I used [Rails' template][2] as a starting point.
@tresni
tresni / gist:83b9181588c7393f6853
Last active September 7, 2024 02:35
Authy to 1Password

Moving Authy to 1Password

1Password 5.3 for OSX, 5.2 for iOS, and 4.1.0.538 for Windows support OTP. I've been using Authy for a while now, but the fact is, I haven't really been using 2FA for some time. As mentioned by 1Password in a recent blog post, having the OTP generator and password on the same device is very much not 2FA. It's just an expiring OTP, which can help, but let's not kid ourselves too much.

With that out of the way. One of the things that was interesting to me was moving my OTP out of Authy and into 1Password. I like the control I get with 1Password, but I didn't want to have to reset all my OTP right away, that would suck. So, I got to dissecting the Authy Chrome App to see what I could do.

Run the Authy Chrome app and make sure it's unlocked.

Now, enable Developer mode in Chrome. We'll need this to inspect the background application that stores al

@Luzifer
Luzifer / README.md
Last active August 25, 2019 12:34
Strategies for persistent data storage on CoreOS-cluster

Persistent data storage on CoreOS-cluster

Storing the data on the host machine

Data directories are created in /home/coreos and mounted into the container using volume cli options of docker run. All data the container writes is stored on the host and as long as the host persists safe against container restarts / recreates.

  • Pro
    • No effort, just create the directories and mount them into the container
  • Contra
  • Container is bound to host (unable to failover)
(when (not (find 'extended-command-history savehist-minibuffer-history-variables))
(add-to-list 'savehist-minibuffer-history-variables 'extended-command-history))
@kumar8600
kumar8600 / lingr-api-memo.md
Last active October 27, 2015 04:59
Lingr API メモ

ここでは、Lingr Bot APIについての情報を取り扱わず、Lingr APIについてのみ扱う。

参照

@pnlybubbles
pnlybubbles / revive.rb
Last active December 15, 2015 21:37
死体を数回クリックすることで仲間を蘇生できるようにするBukkitプラグイン。Puruginを利用。
# encoding: utf-8
$glowstone_marker = true
$delete_dead_items = true
$indestructible_skull = true
class RevivePlugin
include Purugin::Plugin
description 'Revive', 0.2