Skip to content

Instantly share code, notes, and snippets.

View Link-'s full-sized avatar
:octocat:

Bassem Dghaidi Link-

:octocat:
View GitHub Profile
@Link-
Link- / gist:5043704
Created February 27, 2013 00:25
# Linux # Will tarify all folders/files in a directory and create # a separate tar file for each
#!/bin/bash
# Will tarify all folders/files in a directory and create
# a separate tar file for each
for f in */; do tar -cvf "${f%/}.tar" "$f"; done
@Link-
Link- / Useful Unix
Last active November 24, 2017 15:56
Unix : Search & Rescue commands
-- Find
egrep -Rl <regular expression> <file or files>
-- Find and Replace
grep -l '' ./* | xargs sed -i "" 's/IP4445A/IP445A/'
-- Find and Replace (no RegEx)
-- Add IMO number
grep -l '' ./* | xargs sed -i "" 's|MSC:172:20+++:146::VITNAME|MSC:172:20+++9299551:146::VITNAME|g'
-- Change VVN
@Link-
Link- / inputrc
Created March 1, 2015 07:32
Up/Down history search
# Create ~/.inputrc file and paste
# this in it
"\e[A": history-search-backward
"\e[B": history-search-forward
# Example:
# cd+UP : will return all previous cd commands
# and paramters

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@Link-
Link- / wget-all
Created March 21, 2015 20:28
wget magic
# Download all files from a given online directory
# into the a local directory without mirroring the
# folder structure
wget -A <accepted only extensions> -r -l <levels of depth> -nd http://domain.com/folder/
wget -R <all except X> -r -l <levels of depth> -n http://domain.com/folder
@Link-
Link- / wifi_pass
Last active August 29, 2015 14:25
Get WiFi password of a connected network
#OS X
security find-generic-password -ga <SSID> | grep password
# Windows
netsh wlan show profile name=<SSID> key=clear
# Kill Ghost sshd sessions
pkill -o -u YOURUSERNAME sshd
@Link-
Link- / Disk_operations
Last active January 12, 2017 20:13
Raspberry Pi - Useful Disk Operations
# OSX
# Covert .iso to .img
hdiutil convert -format UDRW -o /path/to/target.img /path/to/source.iso
# Backup microSD
sudo dd if=/dev/disk[n] of=/Users/username/SDCardBackup.dmg
# Copy image to microSD
diskutil unmountDisk /dev/disk[n]
dd bs=1m if=/Directory/of/image.img of=/dev/rdisk[n]

Keybase proof

I hereby claim:

  • I am Link- on github.
  • I am bassemdy (https://keybase.io/bassemdy) on keybase.
  • I have a public key whose fingerprint is BCB0 C423 4CFD 1D98 9318 B142 B0EB 1F1D 89CE 8D1F

To claim this, I am signing this object:

@Link-
Link- / vm-rp
Created September 28, 2017 10:21
Solution to a vector to matrix recoding problem
A is 100 dimensional vector containing integers N between [1 and 10] (inclusive) distributed at intervals of 10:
i.e.
at index x -> N
at index 1 -> 1
at index 11 -> 2
at index 21 -> 3
Problem:
-----------
Need to recode A into a 10x100 (Rows x Columns) matrix such that each column is a 10 dimensional vector y with y(x) = 1 the rest is 0