To force the system to free SWAP memory:

swapoff -a
swapon -a

Hence I created a function freeswap_fun at my .basrc with an alias freeswap:

freeswap_fun() {
swapoff -a
swapon -a
alias freeswap=freeswap_fun

I had a file containing ~1M SNPs in their rsid (and their position). I needed to complete the information with their chromosome.

Since the list is really large I use scan combined with a bash command (to know the length of the file).

I found this solution:


## Create connection to big file
inputName <- "input_file.gen"
outputName <- "output_file.gen"
inputCon <- file(description = inputName, open = "r")
outputCon <- file(description = outputName, open = "w")

## We need to know the number of lines of the big file
## This will work for GNU/Linux environments
command <- paste("wc -l ", inputName, " | awk '{ print $1 }'", sep="")
nLines <- as.numeric(system(command = command, intern = TRUE))

## Loop over the file connection until end of lines
pb <- txtProgressBar(min = 0, max = nLines, style = 3)
for(ii in 1:nLines) {
  readLine <- scan(file = inputCon, nlines = 1, what = "list", quiet = TRUE)

  ## Get the chr from the SNP
  x <- tryCatch({
    x <- rsidsToGRanges(readLine[[2]])
  }, error = function(e) {

  ## Update on list and save on output
  readLine[[1]] <- x
  writeLines(paste(readLine, collapse = " "), outputCon)

  setTxtProgressBar(pb, ii)


This solution is really slow but it gets the SNP’s chromosome and fills it as "---" when the SNP is not found in dbSNP.

WARNING: The SNP’s rsid must be located into the second column of the file. Take a look at readLine[[2]] in the for.

I am open to know different ways of doing this.

Using bash and ImageMagick we can crop all the pictures in a folder in a single shoot:

for file in $2/*; 
    if [[ -f $file ]]; 
        echo "$file --> $output"
        convert -crop $1 "$file" "$output"

The script, called is run as:

./ 525x240+675+150 ~/Pictures/

The first argument is the argument for the ImageMagick’s crop tool and the second argumen is the folder where the pictures to be cropped are.

For this examples the user is called darth_vader and the remote host

Single File

From host to server

In this section the user wants to upload the file called rebel_ids.tsv from his localhost to remotehost.

$ scp rebel_ids.tsv 

From server to host

The user wants to download fr the remotehost the file called flight_path.gpx.

$ scp /home/darth_vader/autopilot/ 

Multiple Files

From host to server

Now, the user wants to upload two files, alderaan.gpx and despayre.gpx, to his home into remotehost:

$ scp alderaan.gpx despayre.gpx

From server to host

The user wants to download two files, personal_solo.pdf and personal_chubaca.pdf from remotehost

$ scp{personal_solo.pdf,personal_chubaca.pdf} .


From host to server

$ scp -r foo 

From server to host

$ scp -r .

Today I was installing openbox to my Linux Mint. I wanted to add a slot into obmenu called Exit to turn off the computer but asking me how:

Exit Message

The picture above is the result. The way I created is us trough gxmessage, an alternative to xmessage. This tool allows us to create little question boxes using gtk.

So I created abash script with (~/scripts/ having the following content:


gmessage "The system will be shut down. Are your sure?" -center -title "System Shutdown" -default "Cancel" -buttons "_Shut down":1,"_Reboot":2,"_Log out":3,"_Cancel":4 > /dev/null 

case $? in
        sudo shutdown -h now;;
        sudo shutdown -r now;;
        killall openbox;;
        echo "Exit";;

So we can see out audio settings by using the alsa command:

[carleshf@earth ~]$ amixer -D pulse
Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Front Left: Playback 32360 [49%] [on]
  Front Right: Playback 32360 [49%] [on]
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch cswitch-joined
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 65536
  Front Left: Capture 16462 [25%] [on]
  Front Right: Capture 16462 [25%] [on]

So we can see that the volume range goes from 0 to 65536. In this range a 5% takes the value 3276.8, so by running …

amixer -D pulse set Master 3276+ unmute

… we are increasing a 5% the actual volume, and by running …

amixer -D pulse set Master 3276- unmute

… we are decreasing it. Moreover we can use …

amixer -D pulse set Master toggle

… to toggle between mute and unmute.

DISCLAIMER: I’m running a linux mint system with openbox.