Skip to content

Instantly share code, notes, and snippets.

@TomCan
TomCan / gist:9611446
Last active November 3, 2017 14:30
Compile PHP on clean debian 7
apt-get update
apt-get -y install libxml2-dev libssl-dev pkg-config libbz2-dev libcurl4-openssl-dev libpng-dev libjpeg-dev libfreetype6-dev libgmp-dev libc-client-dev libicu-dev libmcrypt-dev freetds-dev libmysqlclient-dev libpq-dev libxslt-dev apache2-suexec-custom
ln -s /usr/lib/x86_64-linux-gnu/libsybdb.so.5 /usr/lib/libsybdb.so.5
ln -s /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/libsybdb.so
cd php-5.X.XX
./configure --with-freetype-dir=/usr/lib --prefix=/usr/local/php-5.X.XX --with-mysql --with-mysqli --with-mssql --enable-exif --enable-soap --with-mcrypt --with-mhash --with-curl --enable-mbstring --with-gettext --with-zlib --enable-ftp --with-openssl --with-xsl --with-pgsql --enable-calendar --enable-bcmath --with-bz2 --with-imap --with-imap-ssl --with-pdo-mysql --with-jpeg-dir --with-png-dir --with-gd --enable-zip --with-xmlrpc --enable-sockets --enable-intl --with-gmp
@TomCan
TomCan / gist:9644966
Last active May 2, 2024 16:09
Inject drivers in Windows installation after motherboard change
Today, after working with Windows for over 15 years now, I finally came across the solution to the
dreadfull BSOD STOP 0x0000007B after replacing the motherboard of a computer, or after moving the
harddrive to another computer, or after doing a P2V, or after ... you get the point.
Requirements:
- Windows install / boot CD
- Chipset / Mobo / Storage drivers of the new motherboard or storage controller
Steps:
- extract all the drivers to a USB thumb drive
# Vagrantfile - update to use the shell provision module to run a bootstrap script
config.vm.provision :shell, :path => "bootstrap.sh"
# bootstrap.sh
#!/usr/bin/env bash
#
# Bootstrap the vagrant VM by installing Ansible and
# letting ansible do the provisioning in local connection mode
#
@TomCan
TomCan / restart-samba.sh
Created July 23, 2015 14:53
Restart Mac OS X smb service from terminal/cli
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.smbd.plist
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.smbd.plist
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server.plist EnabledServices -array disk
#!/bin/bash
# Get current swap usage for all running processes
SUM=0
OVERALL=0
for DIR in `find /proc/ -maxdepth 1 -type d | egrep "^/proc/[0-9]"` ; do
PID=`echo $DIR | cut -d / -f 3`
PROGNAME=`ps -p $PID -o comm --no-headers`
for SWAP in `grep Swap $DIR/smaps 2>/dev/null| awk '{ print $2 }'`
do
let SUM=$SUM+$SWAP
@TomCan
TomCan / gist:69e6200458cd73058cee
Last active January 5, 2016 16:17
Fortigate log traffic per IP
diagnose debug reset
diagnose debug enable
diagnose debug flow show console enable
diagnose debug flow filter add <IP-ADDRESS-TO-FILTER>
diagnose debug flow trace start <NUMBER-OF-PACKETS>
@TomCan
TomCan / gist:b88afca8f2d4f1131f50d6b031280319
Last active January 9, 2017 08:52
Add apt keys NO_PUBKEY error
for KEY in ABCDEFGHIJKLMN
do
gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv $KEY
gpg --export --armor $KEY | apt-key add -
done
# oneliner
for KEY in ABCDEFGHIJKLMN; do gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv $KEY; gpg --export --armor $KEY | apt-key add -; done
@TomCan
TomCan / varnish.vcl
Created June 8, 2016 08:38
Enable gzip compression in Varnish
sub vcl_recv {
...
if (req.http.Accept-Encoding) {
if (req.url ~ "\.(jpeg|jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") {
unset req.http.Accept-Encoding;
} elsif (req.http.Accept-Encoding ~ "gzip") {
set req.http.Accept-Encoding = "gzip";
} elsif (req.http.Accept-Encoding ~ "deflate" &&
req.http.user-agent !~ "MSIE") {
set req.http.Accept-Encoding = "deflate";
# in case of VM and live update of harddisk size, first rescan scsi bus to refect changes
for DEV in `ls -1 /sys/class/scsi_device/`; do echo 1 > /sys/class/scsi_device/$DEV/device/rescan; done
# resize partitions, assumes /dev/sda2 is extended and /dev/sda5 is logical in /dev/sda2
parted /dev/sda
> resizepart 2 -1s
> resizepart 5 -1s
> q
# rescan partion table
# this requires that MySQL is accessed through TCP/IP, not the unix socket.
# run tcpdump for 30 seconds capturing traffic on port 3306
timeout 30 tcpdump -s 65535 -x -nn -q -tttt -i any port 3306 > mysql.tcp.txt
# run pt-query-digest on collected file
pt-query-digest --type tcpdump mysql.tcp.txt >pt.out