Skip to content

Instantly share code, notes, and snippets.

View mdouchement's full-sized avatar
♨️
❨╯°□°❩╯︵┸━┸

mdouchement mdouchement

♨️
❨╯°□°❩╯︵┸━┸
View GitHub Profile
package main
import (
"bytes"
"encoding/gob"
"fmt"
"github.com/peterbourgon/diskv"
)
@mdouchement
mdouchement / profiler.go
Last active June 3, 2016 14:29
Golang memory profiler
package profiler
import (
"github.com/wblakecaldwell/profiler"
"net/http"
"sync"
)
var cache = struct {
sync.RWMutex
@mdouchement
mdouchement / trim_pfsense2.2.4.md
Last active February 13, 2024 08:19
Enable TRIM on pfsense 2.2.4

Installation

Use memstick-licecd to install pfsense on your SSD.

Enable TRIM

  • Initialize fstab:
[2.2.4-RELEASE][root@pfSense.localdomain]/root: /usr/local/sbin/ufslabels.sh

It may do nothing because all is already initialize but it's only in a case of

@mdouchement
mdouchement / 50-synaptics.conf
Created October 28, 2014 20:25
Touchpad configuration (/etc/X11/xorg.conf.d/50-synaptics.conf)
Section "InputClass"
Identifier "touchpad catchall"
Driver "synaptics"
MatchIsTouchpad "on"
Option "TapButton1" "1"
Option "TapButton2" "3"
Option "TapButton3" "2"
Option "VertEdgeScroll" "1"
Option "HorizEdgeScroll" "1"
Option "VertTwoFingerScroll" "1"
@mdouchement
mdouchement / before_filter.rb
Last active August 29, 2015 14:07
Ruby before filter
module MethodInterception
def before_filter(*meths, &blk)
return @wrap_next_method = true if meths.empty?
meths.delete_if { |meth| wrap(meth, &blk) if method_defined?(meth) }
@intercepted_methods += meths
end
private
def wrap(meth, &blk)
@mdouchement
mdouchement / 1_selective_instance_eval.rb
Last active August 29, 2015 14:07
Selective instance eval
String.class_eval do
alias_method :original_initialize, :initialize
def initialize(*args)
# https://www.ruby-forum.com/topic/1893190
c = caller(0)
case
when c.to_s.include?('module:V1')
instance_eval do
def to_v1
@mdouchement
mdouchement / ruby_abstract.rb
Created July 11, 2014 07:30
Ruby module (abstract) example
module Abstract
def self.included(base)
base.extend(ClassMethods)
end
def hello
'hello from instance method'
end
module ClassMethods
@mdouchement
mdouchement / barrier.sh
Last active August 29, 2015 14:03
Bash: synchronisation barrier
#!/bin/bash
./process_1.sh &
pid_1=`echo $!`
./process_2.sh &
pid_2=`echo $!`
./process_3.sh &
pid_3=`echo $!`