Skip to content

Instantly share code, notes, and snippets.

View f-mer's full-sized avatar

Fabian Mersch f-mer

View GitHub Profile
@tj
tj / querying.md
Last active February 8, 2024 17:48
Querying for https://apex.sh/logs/

Apex Logs utilizes a purpose-built query language for searching and aggregating structured log events.

Events

An Apex Log event requires the following properties:

Name Type Description
id string The unique identifier of the event.
@dmitshur
dmitshur / main.go
Last active March 16, 2020 10:59
A simple server for HTTPS and HTTP protocols.
// A simple server for HTTPS and HTTP protocols. It implements these behaviors:
//
// • uses Let's Encrypt to acquire and automatically refresh HTTPS certificates
//
// • redirects HTTPS requests to canonical hosts, reverse proxies requests to internal backing servers
//
// • redirects all HTTP requests to HTTPS
//
// • gates certain endpoints with basic auth, using bcrypt-hashed passwords
//
@bqst
bqst / style.css
Last active June 20, 2021 17:44
339 bytes of responsive CSS
// https://blog.koley.in/2019/339-bytes-of-responsive-css
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
line-height: 1.6;
color: #222;
max-width: 40rem;
padding: 2rem;
margin: auto;
background: #fafafa;
@dmshvetsov
dmshvetsov / worker_and_queue_perfect_pair.rb
Created February 5, 2019 05:33
Example of how we may use queue with threads to make efficient background worker.
class Worker
def self.start(num_threads:, queue_size:)
queue = SizedQueue.new(queue_size)
worker = new(num_threads: num_threads, queue: queue)
worker.spawn_threads
worker
end
def initialize(num_threads:, queue:)
@num_threads = num_threads
@freedmand
freedmand / tester.js
Last active November 7, 2018 11:13
JavaScript unit testing in under 30 lines
const PASS = ['32']; // green
const FAIL = ['31', '1']; // red, bold
function logStyle(ansiEscapeCodes, text) {
console.log(`\x1b[${ansiEscapeCodes.join(';')}m${text}\x1b[0m`);
}
class Tester {
constructor() {}
@cesarandreu
cesarandreu / sensible-defaults.css
Created June 2, 2018 10:04
Sensible css defaults taken from css-layout
div, span {
box-sizing: border-box;
position: relative;
display: flex;
flex-direction: column;
align-items: stretch;
flex-shrink: 0;
align-content: flex-start;
@andyyou
andyyou / rails_webpacker_bootstrap_expose_jquery.md
Last active August 9, 2022 07:38
Rails 5.2 with webpacker, bootstrap, stimulus starter

Rails 5.2 with webpacker, bootstrap, stimulus starter

This gist will collects all issues we solved with Rails 5.2 and Webpacker

Create Project

# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test
@UsamaAshraf
UsamaAshraf / Gemfile
Last active May 23, 2021 16:42
N+1 Queries, Batch Loading and Active Model Serializers
# ...
# https://github.com/exAspArk/batch-loader
gem 'batch-loader'
@MylesBorins
MylesBorins / ls.c
Created January 8, 2018 16:21
example of super basic ls implementation in c to build `gcc ls.c`
#include <stdio.h>
#include <dirent.h>
int main (int argc, char *argv[ ])
{
DIR *dp;
struct dirent *dirp;
if (argc != 2) {
fprintf(stderr, "usage: ls directory_name\n");
@shystruk
shystruk / subPub.js
Created November 29, 2017 07:01
Subscriber Publisher
var subPub = Object.seal({
key: 0,
subscribers: {},
subscribe: function(subscriber) {
this.subscribers[this.key] = subscriber;
return this.key++;
},
publish: function(args) {
for (var sub in this.subscribers) {