Skip to content

Instantly share code, notes, and snippets.

View zemd's full-sized avatar
🇺🇦

Dmytro Zelenetskyi zemd

🇺🇦
  • Ikea IT AB
  • Malmö, Sweden
View GitHub Profile
@zemd
zemd / chroma.ts
Created July 2, 2024 17:41 — forked from Artoria2e5/chroma.ts
Maximize chroma in Oklch without changing L and h
// This is just https://bottosson.github.io/posts/gamutclipping/ crudely translated to TS
type Lab = { L: number; a: number; b: number };
type RGB = { r: number; g: number; b: number };
type sRGB = { r: number; g: number; b: number };
function linear_srgb_to_oklab(c: RGB): Lab {
const l = 0.4122214708 * c.r + 0.5363325363 * c.g + 0.0514459929 * c.b;
const m = 0.2119034982 * c.r + 0.6806995451 * c.g + 0.1073969566 * c.b;
const s = 0.0883024619 * c.r + 0.2817188376 * c.g + 0.6299787005 * c.b;
@zemd
zemd / postgres-cheatsheet.md
Created August 13, 2018 19:46 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@zemd
zemd / README.md
Created January 30, 2014 22:14 — forked from fnichol/README.md

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

@zemd
zemd / gist:8386119
Created January 12, 2014 15:34 — forked from zbal/gist:7800423
# Based on https://gist.github.com/fernandoaleman/5083680
# Start the old vagrant
$ vagrant init ubuntu_saucy
$ vagrant up
# You should see a message like:
# [default] The guest additions on this VM do not match the install version of
# VirtualBox! This may cause things such as forwarded ports, shared
# folders, and more to not work properly. If any of those things fail on
<!DOCTYPE html>
<!--[if IE 8]> <html lang="sv-SE" class="no-js ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="sv-SE" class="no-js"> <!--<![endif]-->
<head>
<meta charset="UTF-8">
<title>Breakpoint detection test</title>
<style type="text/css" media="screen">
@media screen and (min-width: 320px) {
#page:after {
content: 'smallest'; /* represent the current width-bracket */
$sprites: sprite-map("sprites/*.png");
$sprites-retina: sprite-map("sprites-retina/*.png");
@mixin sprite-background($name) {
background-image: sprite-url($sprites);
background-position: sprite-position($sprites, $name);
background-repeat: no-repeat;
display: block;
height: image-height(sprite-file($sprites, $name));
width: image-width(sprite-file($sprites, $name));
# Generate Private Key
$ openssl genrsa -out server.key 2048
# Generate CSR
$ openssl req -new -out server.csr -key server.key -config openssl.cnf
# => Fill in info
# Check CSR
$ openssl req -text -noout -in server.csr
# Sign Cert
$ openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt -extensions v3_req -extfile openssl.cnf