Skip to content

Instantly share code, notes, and snippets.

View scemama's full-sized avatar
🏠
Working from home

Anthony Scemama scemama

🏠
Working from home
View GitHub Profile
@scemama
scemama / turbo.sh
Created June 30, 2015 09:57
Adjust turbo frequency manually
echo 1 > /sys/module/processor/parameters/ignore_ppc
for x in /sys/devices/system/cpu/cpu[0-3]/cpufreq/;do
echo 3601000 > $x/scaling_max_freq
done
@scemama
scemama / mega-dl.sh
Created June 8, 2015 16:35
Download file from mega.com.nz
#!/bin/bash
#
# Code found originally here on a post from t0n1 :
# http://hacktracking.blogspot.fr/2013/07/download-mega-files-from-command-line.html
#
url=$1
enc_file=$2.enc
out_file=$2
@scemama
scemama / cuthill_mckee.f
Created April 23, 2015 09:13
Reverse Cuthill-MacKee subroutine
subroutine cuthill_mckee(matrix,LDA,n,iorder)
implicit none
! Uses the Cuthill-McKee algorithm to reorder the columns and rows of the matrix
integer, intent(in) :: n,LDA
integer, intent(out) :: iorder(n)
double precision, intent(in) :: matrix(LDA,n)
integer :: i,j,k
@scemama
scemama / turn_off_screensaver.sh
Created March 22, 2015 20:22
Turn off screen saver
setterm -blank 0
xset -q
xset s off
xset -dpms
@scemama
scemama / toggle_layout.sh
Created March 22, 2015 20:20
Toggle keyboard layout
#!/bin/bash
declare -A new_layout
new_layout["us"]="us_intl"
new_layout["us_intl"]="us"
cur_layout=$(setxkbmap -query | grep layout | cut -c13-)
setxkbmap -layout ${new_layout[$cur_layout]}
@scemama
scemama / gpg.rst
Created March 22, 2015 20:20
GPG encryption

Add to ~/.gnupg/gpg.conf:

cipher-algo AES256

Encrypt a file:

gpg -c ${FILE}

Decrypt a file:

@scemama
scemama / screen.rst
Created March 22, 2015 20:19
Setup multi-user screen

Set the setuid bit on the executable

$ sudo chmod u+s /usr/bin/screen
$ ls -l /usr/bin/screen
-rwsr-xr-x 1 root screen 360952 Jan 18 2038 /usr/bin/screen

Update your .screenrc

@scemama
scemama / change_mac.sh
Created March 22, 2015 20:17
Change MAC address
ifconfig eth0 down
ifconfig eth0 hw ether 00:90:27:3b:ef:ce
ifconfig eth0 up
@scemama
scemama / gist:fdec3bc4afa533668bcb
Created March 22, 2015 20:17
SSH reverse tunnel
user@home $ ssh -R 10000:localhost:22 target.machine.org
user@target.machine.org $ ssh -p 10000 localhost # ssh to the home machine
@scemama
scemama / ssh_config
Created March 22, 2015 20:15
SSH through a gateway
Host target.host.domain target
User username_on_target
HostName target.host.domain
ProxyCommand ssh username_on_gateway@gateway.host.domain nc %h %p