Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# usage :
# sudo killtree pid
killtree() {
local _pid=$1
kill -STOP ${_pid}
for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
killtree ${_child}
@ThomasSevestre
ThomasSevestre / sqlite-distance.rb
Created February 3, 2021 16:33 — forked from robmiller/sqlite-distance.rb
Ruby/SQLite code for finding places within a certain distance from another place. In other words, Ruby code that adds a "DISTANCE(lat1, lon1, lat2, lon2)" to SQLite, allowing you to select records based on the distance between two points of latitude and longitude. Magic! Adapted from the ObjectiveC version here: http://daveaddey.com/?p=71
db = SQLite3::Database.new ":memory:"
# A sample SQLite table; all that's necessary is the lat and log fields
db.execute <<-SQL
CREATE TABLE users (
email VARCHAR(255),
lat FLOAT,
lon FLOAT
)
SQL
@ThomasSevestre
ThomasSevestre / ffmpeg.md
Created October 26, 2020 13:43 — forked from protrolium/ffmpeg.md
ffmpeg guide

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

#!/usr/bin/env ruby
# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
# https://dalibornasevic.com/posts/54-how-to-debug-stuck-ruby-processes
require 'tempfile'
require 'rbconfig'
@ThomasSevestre
ThomasSevestre / sems_max_forward.patch
Last active October 16, 2018 14:47
SEMS : add max_forwards decrease on SBC module (based on b260d53745220b14b20d810042078ca31210617f)
diff --git a/apps/sbc/CallLeg.cpp b/apps/sbc/CallLeg.cpp
index 84096adb..37b4cb52 100644
--- a/apps/sbc/CallLeg.cpp
+++ b/apps/sbc/CallLeg.cpp
@@ -646,7 +646,7 @@ void CallLeg::onB2BConnect(ConnectLegEvent* co_ev)
}
int res = dlg->sendRequest(SIP_METH_INVITE, &body,
- co_ev->hdrs, SIP_FLAGS_VERBATIM);
+ co_ev->hdrs, SIP_FLAGS_VERBATIM, co_ev->r_max_forwards - 1);
@ThomasSevestre
ThomasSevestre / pcap2wav
Created November 29, 2017 13:00 — forked from avimar/pcap2wav
Convert raw PCAP files into a .wav file
#!/bin/bash
#
# pcap2wav
# Original Author: Michael Collins <[email protected]>
#Standard disclaimer: batteries not included, your mileage may vary...
# Updated by Avi Marcus <[email protected]>
#
# Accepts arg of pcap file w/only 2 RTP streams
# Creates a .<codec> file and a .wav file
# For codecs other than PCMA and PCMU the script calls fs_cli and does a little recording to create the wav file(s)
@ThomasSevestre
ThomasSevestre / kamailio.cfg
Created October 31, 2016 17:00 — forked from iwanbk/kamailio.cfg
kamailio.cfg with SIP over websocket. Modified from kamailio 4.0.1 example
#!KAMAILIO
#
# Simple/sample kamailio.cfg for running a proxy/registrar with TLS and
# WebSockets support.
###!substdef "!DBURL!sqlite:///etc/kamailio/db.sqlite!g"
#!substdef "!DBURL!mysql://kamailio:kamailiorw@localhost/kamailio!g"
#!substdef "!MY_IP_ADDR!10.0.11.175!g"
#!substdef "!MY_DOMAIN!ubukam.lan!g"
#!substdef "!MY_WS_PORT!5065!g"
@ThomasSevestre
ThomasSevestre / partial_validation.rb
Last active January 9, 2019 14:32
ActiveRecord - Partial model validation
###
# DISCLAIMER - USE AT YOUR OWN RISK
# I'm using it with rails from version 4.2.4 to 4.2.6
#
# This file can be pasted in app/models/concerns
#
# This module needs to be included in the model to enable partial validation.
# It is designed to make partial validation transparent for the model.
# The controller is ... in control ;)
#