Skip to content

Instantly share code, notes, and snippets.

View wemgl's full-sized avatar

Wembley Leach wemgl

View GitHub Profile
@craiglabenz
craiglabenz / chat_message_render_box.dart
Last active May 27, 2024 19:24
Demonstrates a custom RenderObject that draws chat messages like WhatsApp, where the `sentAt` timestamp is tucked into the last line if it fits
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@onlurking
onlurking / programming-as-theory-building.md
Last active May 25, 2024 15:28
Programming as Theory Building - Peter Naur

Programming as Theory Building

Peter Naur

Peter Naur's classic 1985 essay "Programming as Theory Building" argues that a program is not its source code. A program is a shared mental construct (he uses the word theory) that lives in the minds of the people who work on it. If you lose the people, you lose the program. The code is merely a written representation of the program, and it's lossy, so you can't reconstruct

@vbsteven
vbsteven / Validators.kt
Created April 8, 2019 16:27
Custom Spring annotation and validator in Kotlin
package io.license.core.validation
import javax.validation.Constraint
import javax.validation.ConstraintValidator
import javax.validation.ConstraintValidatorContext
import javax.validation.Payload
import kotlin.reflect.KClass
@Target(AnnotationTarget.FIELD)
@db0sch
db0sch / regenerate_credentials.md
Last active May 11, 2024 10:34
How to regenerate the master key for Rails 5.2 credentials

If your master.key has been compromised, you might want to regenerate it.

No key regeneration feature at the moment. We have to do it manually.

  1. Copy content of original credentials rails credentials:show somewhere temporarily.
  2. Remove config/master.key and config/credentials.yml.enc
  3. Run EDITOR=vim rails credentials:edit in the terminal: This command will create a new master.key and credentials.yml.enc if they do not exist.
  4. Paste the original credentials you copied (step 1) in the new credentials file (and save + quit vim)
  5. Add and Commit the file config/credentials.yml.enc
@asukakenji
asukakenji / go-stdlib-interface-selected.md
Last active May 30, 2024 21:07
Go (Golang) Standard Library Interfaces (Selected)

Go (Golang) Standard Library Interfaces (Selected)

This is not an exhaustive list of all interfaces in Go's standard library. I only list those I think are important. Interfaces defined in frequently used packages (like io, fmt) are included. Interfaces that have significant importance are also included.

All of the following information is based on go version go1.8.3 darwin/amd64.

@cjbarker
cjbarker / Makefile
Created June 21, 2017 22:10
Makefile for cross-compiling Golang. Just update BINARY var in Makefile and create empty vars in main.go for Version and Build
# ########################################################## #
# Makefile for Golang Project
# Includes cross-compiling, installation, cleanup
# ########################################################## #
# Check for required command tools to build or stop immediately
EXECUTABLES = git go find pwd
K := $(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH)))
@shautzin
shautzin / AES.go
Created March 24, 2017 01:59
AES/CBC/PKCS5Padding implementation by Golang
package main
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"fmt"
)
func main() {
@julz
julz / main.go
Created November 20, 2015 12:39
containersched minicontainer
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
)
func main() {
@popravich
popravich / PostgreSQL_index_naming.rst
Last active May 30, 2024 06:39
PostgreSQL index naming convention to remember

The standard names for indexes in PostgreSQL are:

{tablename}_{columnname(s)}_{suffix}

where the suffix is one of the following:

  • pkey for a Primary Key constraint;
  • key for a Unique constraint;
  • excl for an Exclusion constraint;
  • idx for any other kind of index;
@PurpleBooth
PurpleBooth / README-Template.md
Last active June 2, 2024 14:24
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites