Skip to content

Instantly share code, notes, and snippets.

View YuukanOO's full-sized avatar
💡
Working on seelf!

Julien LEICHER YuukanOO

💡
Working on seelf!
View GitHub Profile
@ismasan
ismasan / sse.go
Last active March 19, 2024 18:13
Example SSE server in Golang
// Copyright (c) 2017 Ismael Celis
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// Brightness math based on:
// http://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx
$red-magic-number: 241;
$green-magic-number: 691;
$blue-magic-number: 68;
$brightness-divisor: $red-magic-number + $green-magic-number + $blue-magic-number;
@function brightness($color) {
// Extract color components
@noamtm
noamtm / attrdict.py
Last active May 29, 2018 20:26
Python: read-only access to dictionary keys as attributes
# There are other solutions across the interwebs. This is one that avoids complexities
# because it's read-only (useful when you just want to read json data, for example).
# It also makes it possible to read nested dictionaries in the same way.
# Based on ideas from http://code.activestate.com/recipes/473786-dictionary-with-attribute-style-access/
class attrdict (dict):
'''
Read-only access to dictionary keys as attributes.
>>> d=attrdict({"a":1, "b":2, "c":{"a":1, "b":2, "c":{"a":1, "b":2}}})
>>> d.a
@JamesChevalier
JamesChevalier / mac_utf8_insanity.md
Last active May 2, 2024 23:38
Unicode on Mac is insane. Mac OS X uses NFD while everything else uses NFC. This fixes that.

convmv manpage

Install convmv if you don't have it

sudo apt-get install convmv

Convert all files in a directory from NFD to NFC:

convmv -r -f utf8 -t utf8 --nfc --notest .

@jayjanssen
jayjanssen / semaphore.js
Created May 27, 2011 18:30
Node.js semaphores
var Semaphore = function(callback, context) {
this.semaphore = 0;
this.callback = callback;
this.context = context || this;
};
Semaphore.prototype.increment = function() {
this.semaphore++;
};