Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am mcansky on github.
* I am riboulet (https://keybase.io/riboulet) on keybase.
* I have a public key ASCojPPoZJpuxXamfLB-X2CU4EGMvoKwauP0zvZT8xS5Ewo
To claim this, I am signing this object:
@mcansky
mcansky / README.md
Created June 8, 2021 17:46
&. operand vs nil object ?

What do we prefer ?

related : https://refactoring.guru/introduce-null-object

The question is : when should we go for NilObject classes : from the first method to unify the way to handle this kind of things in the code base or wait until you have something a bit complex to do it ?

Given

So let's say we have a Cup model that has tray_uuid and barcode attributes. In one case we want to get a Cup that is linked to a specific barcode and return the uuid of the tray it's stored on.

@mcansky
mcansky / article_code.rb
Created February 4, 2020 12:09
un peu de code Ruby et de Sequel
require 'sequel'
require 'byebug'
DB = Sequel.connect(adapter: 'postgres', host: '127.0.0.1', user: 'postgres', password: '', database: 'sequel_test')
if DB.table_exists?(:chapters)
DB[:chapters].truncate
else
DB.create_table :chapters do
primary_key :id
// ---- ---- ---- ---- ----
//Functions associated with shift - ctrl tap dance
void shift_ctrl_toggle (qk_tap_dance_state_t *state, void *user_data);
void shift_ctrl_reset (qk_tap_dance_state_t *state, void *user_data);
//Initialize tap structure associated with example tap dance key
static tap lsft_tap_state = {
.is_press_action = true,
.state = 0
};
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Check that apt lock is off or on. If on, wait up to 60 seconds before trying
again and returning success (if released) or failure.
Author: Thomas R. R. Riboulet <[email protected]>
'''
import logging
@mcansky
mcansky / idea.md
Last active August 29, 2015 14:17
my basic need of ruby app hosting with multiple copies of Docker containers

Docker - Hosting

For a long time deploying web applications involved one of the following :

  • package the app in a tar bar or an “evolved” tar ball (deb, rpm) and extract it on the hosts
  • use your favorite configuration management system and a remote command execution to deploy the latest tag of your branch

In both cases you can use some amount of automation with Salt/Chef/Puppet/Ansible for example.

Yet I am not happy with that process. The usual steps are as follow :

@mcansky
mcansky / hipache-3.1.json
Created July 19, 2014 09:52
Hipache config
{
"server": {
"accessLog": "/var/log/hipache/access.log",
"pidFile": "/var/run/hipache.pid",
"workers": 5,
"maxSockets": 100,
"deadBackendTTL": 90,
"port": 80,
"bind": ["0.0.0.0"],
"https": {
@mcansky
mcansky / localhost.domains.md
Last active September 28, 2015 01:18
List of domain names resolving to localhost

List of domains resolving to localhost (127.0.0.1)

  • lvh.me, @levilook , gittip : https://www.gittip.com/levicook/ ; expiration date : 02-Jun-2015
  • lclhst.link, @dylnclrk ; expiration date : 03-Jun-2015
  • vcap.me ; expiration date : 08-Feb-2015
  • fluke.ninja, @mcansky ; expiration date : 03-Jun-2017
  • localtest.me, @mauro-oto; expiration date : 02-May-2015
@mcansky
mcansky / pizza_franck.rb
Created September 25, 2013 14:06
domino's pizza has a nice iframe, I wanted to have a json
require 'nokogiri'
require 'open-uri'
require 'sinatra'
require 'json'
helpers do
def status(id)
url = "http://www.dominos.co.uk/checkout/pizzaTrackeriFrame.aspx?id=#{id}"
uri = URI.parse url
blob = uri.open.read
@mcansky
mcansky / script.js
Created September 24, 2013 08:45
testing dom manipulation with Jasmine
(function(window){
add_pic = function (options) {
$('#pic').append("<img href='http://google.com/logo.jpg'/>");
};