Skip to content

Instantly share code, notes, and snippets.

View francoisjacques's full-sized avatar

François Jacques francoisjacques

View GitHub Profile
@francoisjacques
francoisjacques / gdb_ruby_backtrace.py
Created February 7, 2018 19:45 — forked from csfrancis/gdb_ruby_backtrace.py
Dump an MRI call stack from gdb
# Updated for Ruby 2.3
string_t = None
def get_rstring(addr):
s = addr.cast(string_t.pointer())
if s['basic']['flags'] & (1 << 13):
return s['as']['heap']['ptr'].string()
else:
return s['as']['ary'].string()
How to use 'pci pass-through' to run Linux in Qemu accessing real Ath9k adapter
===============================================================================
# Boot kernel with 'intel_iommu=on'
# Unbind driver from the device and bind 'pci-stub' to it
echo "168c 0030" > /sys/bus/pci/drivers/pci-stub/new_id
echo 0000:0b:00.0 > /sys/bus/pci/devices/0000:0b:00.0/driver/unbind
echo 0000:0b:00.0 > /sys/bus/pci/drivers/pci-stub/bind
@francoisjacques
francoisjacques / where_is.rb
Created April 5, 2017 03:59 — forked from wtaysom/where_is.rb
A little Ruby module for finding the source location where class and methods are defined.
module Where
class <<self
attr_accessor :editor
def is_proc(proc)
source_location(proc)
end
def is_method(klass, method_name)
source_location(klass.method(method_name))
@francoisjacques
francoisjacques / docker-wordpress.sh
Created February 5, 2017 18:19 — forked from tatemz/docker-wordpress.sh
A quick way to get a WordPress installation up and running with Docker
#!/bin/bash
mkdir wordpress-site && cd wordpress-site
touch docker-compose.yml
cat > docker-compose.yml <<EOL
version: "2"
services:
my-wpdb:
@francoisjacques
francoisjacques / basic.sql
Created September 2, 2016 16:40 — forked from nesquena/basic.sql
PostgreSQL Common Utility Queries
/* How to calculate postgreSQL database size in disk ? */
SELECT pg_size_pretty(pg_database_size('thedbname'));
/* Calculate size of a table including or excluding the index */
SELECT pg_size_pretty(pg_total_relation_size('big_table'));
SELECT pg_size_pretty(pg_relation_size('big_table')); /* without index */
/* See indexes on a table with `\d tablename` */
@francoisjacques
francoisjacques / query_planner.markdown
Created September 2, 2016 15:51 — forked from hgmnz/query_planner.markdown
PostgreSQL query plan and SQL performance notes

Types of index scans

Indexes

Sequential Scan:

  • Read every row in the table
  • No reading of index. Reading from indexes is also expensive.
@francoisjacques
francoisjacques / ddns-start
Last active December 10, 2021 00:51
dns-o-matic client for asuswrt
#!/bin/sh
# Typical location - /jffs/scripts/ddns-start
# NOTE - USERNAME and PASSWORD must be URL encoded, example @ becomes %40
USERNAME=CHANGE_ME_URL_ENCODED
PASSWORD=CHANGE_ME_URL_ENCODED
HOSTNAME=all.dnsomatic.com
IP=`curl --silent http://canhazip.com`
# Should be no need to modify anything beyond this point
/usr/sbin/curl --silent "https://$USERNAME:[email protected]/nic/update?hostname=$HOSTNAME&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG&myip=$IP" > /dev/null
@francoisjacques
francoisjacques / gist:3969dda6280987622ab4
Created October 27, 2015 05:09
2nd attempt for VMWare Workstation.
***** 304-hardened.patch *****
PWD: /var/tmp/portage/app-emulation/vmware-modules-304.2/work
PATCH TOOL: patch -> /usr/bin/patch
VERSION INFO:
GNU patch 2.7.5
Copyright (C) 2003, 2009-2012 Free Software Foundation, Inc.
Copyright (C) 1988 Larry Wall
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
@francoisjacques
francoisjacques / gist:100c3a71d8e02efe088c
Created October 26, 2015 15:20
VMWare 12 experimental emerge failure
***** 308-hardened.patch *****
PWD: /var/tmp/portage/app-emulation/vmware-modules-308.0-r1/work
PATCH TOOL: patch -> /usr/bin/patch
VERSION INFO:
GNU patch 2.7.5
Copyright (C) 2003, 2009-2012 Free Software Foundation, Inc.
Copyright (C) 1988 Larry Wall
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
# Change Java Runtime:
sudo update-alternatives --config java
# Delete Open-JDK
sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
# Change fonts - remove hinting:
http://askubuntu.com/questions/32624/ugly-fonts-in-netbeans-how-can-i-make-it-use-the-system-font
# Change RubyMine AntiAliasing first: