Skip to content

Instantly share code, notes, and snippets.

View gabssnake's full-sized avatar

gabssnake gabssnake

  • Lyon
View GitHub Profile
@gabssnake
gabssnake / ipc.example.js
Created October 19, 2021 13:59 — forked from Xaekai/ipc.example.js
Example of Interprocess communication in Node.js through a UNIX domain socket
/*
**
** Example of Interprocess communication in Node.js through a UNIX domain socket
**
** Usage:
** server> MODE=server node ipc.example.js
** client> MODE=client node ipc.example.js
**
*/
@gabssnake
gabssnake / README.md
Created December 22, 2020 09:11 — forked from developius/README.md
Setup SSH keys for use with GitHub/GitLab/BitBucket etc

Create a new repository, or reuse an existing one.

Generate a new SSH key:

ssh-keygen -t rsa -C "your_email@example.com"

Copy the contents of the file ~/.ssh/id_rsa.pub to your SSH keys in your GitHub account settings (https://github.com/settings/keys).

Test SSH key:

@gabssnake
gabssnake / Good taste.md
Created December 15, 2020 10:22 — forked from santisbon/Good taste.md
What makes good taste?

On Good Taste

Linus Torvalds in an interview talked about the idea of good taste in code or what I like to call elegance. As one might expect from two slides meant to make a point during a talk, he omits a lot of details to keep it short and simple. This post digs into the specifics of his example (deleting an element from a list) and adds another example (inserting an element in a list) including working code.

Example from Linus

This is an example of removing an element from a singly-linked list. It's one of the first data structures you learn about when you start learning about computer science and programming. The reason it doesn't show particularly good taste is because we have that condition at the end where we take a different action depending on whether the element we want to remove is at the beginning of the list or somewhere in the middle.

![Bad taste](http://

@gabssnake
gabssnake / naur.md
Created October 24, 2020 19:16 — forked from dpritchett/naur.md
Programming as Theory Building

Programming as Theory Building

Peter Naur, 1985

(copied from http://alistair.cockburn.us/ASD+book+extract%3A+%22Naur,+Ehn,+Musashi%22)

Introduction

The present discussion is a contribution to the understanding of what programming is. It suggests that programming properly should be regarded as an activity by which the programmers form or achieve a certain kind of insight, a theory, of the matters at hand. This suggestion is in contrast to what appears to be a more common notion, that programming should be regarded as a production of a program and certain other texts.

@gabssnake
gabssnake / hooks.js
Created April 29, 2020 12:47
Using callbacks as iterators à la React Hooks
// Not my credit, this comes from @jedschmidt on Twitter
// https://twitter.com/jedschmidt
// Example usage:
//
// void async function() {
// let [clicks, onclick] = iterator()
// document.querySelector('button').addEventListener('click', onclick)
// for await (let click of clicks) console.log(click)
// }()
@gabssnake
gabssnake / tracker_blocking.rb
Created April 24, 2020 23:10 — forked from dhh/tracker_blocking.rb
Current list of spy pixels named'n'shamed in HEY, as of April 23, 2020
module Entry::TrackerBlocking
extend ActiveSupport::Concern
included do
has_many :blocked_trackers
end
email_service_blockers = {
"ActiveCampaign" => /lt\.php(.*)?l\=open/,
"AWeber" => "openrate.aweber.com",
@gabssnake
gabssnake / .colors
Created December 15, 2019 00:01 — forked from daytonn/.colors
Bash Color functions
# Colors
end="\033[0m"
black="\033[0;30m"
blackb="\033[1;30m"
white="\033[0;37m"
whiteb="\033[1;37m"
red="\033[0;31m"
redb="\033[1;31m"
green="\033[0;32m"
greenb="\033[1;32m"
@gabssnake
gabssnake / FizzBuzz.js
Created December 21, 2017 07:47
FizzBuzz
// Separate rules from work
const rules = { '3': 'Fizz', '5': 'Buzz' }
const fbuzz = i => Object.keys(rules).reduce((s, n) => s + (i % n ? '' : rules[n]), '') || i
for (let i = 1; i <= 100; i++) console.log(fbuzz(i))
@gabssnake
gabssnake / scrdec18-VC8.exe
Created September 1, 2017 16:54 — forked from bcse/scrdec18-VC8.exe
Windows Script Decoder 1.8 (Decoding JScript.Encoded)
@gabssnake
gabssnake / index.js
Last active January 20, 2017 21:05
Bloomrun perf tests
'use strict'
var async = require('async')
var dependency = require('bloomrun')
var tests = require('./tests')
function measure (test) {
return function (i, done) {
var time = process.hrtime()
test(err => done(err, process.hrtime(time)))