Skip to content

Instantly share code, notes, and snippets.

View darktef's full-sized avatar
🐳
Hacking

Lin Yang darktef

🐳
Hacking
View GitHub Profile
@darktef
darktef / gist:53db9956a9172377f37ae488d8511809
Created September 23, 2016 03:43
Fish - ffmpeg&lame - convert m4a to mp3
for f in *.m4a
set name (string trim --right --chars=.m4a $f)
echo $name
ffmpeg -i $f -acodec libmp3lame -b:a 320k $name.mp3
end
@darktef
darktef / gist:69dff2055c0614bdf592d3bd04e0e7ac
Last active March 11, 2017 20:54
Fish - youtube-dl - Download playlist in
youtube-dl -f bestaudio -o 'The_Sounds_of_the_Monterey_Bay/%(playlist_index)s - %(title)s.%(ext)s' 'https://www.youtube.com/watch?v=oBik31cwRbY&list=PLUSRfoOcUe4aw6JiTXbwUET_wdQ1bnyoo'
## Download playlist in separate folder, audio only
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' -o '%(playlist_index)s-%(title)s.%(ext)s' 'https://www.youtube.com/playlist?list=PL4BBB74C7D2A1049C'
## Download playlist with best quality
@darktef
darktef / gist:dc39f10d2b99d4ba774d81cb0368bb3f
Created September 23, 2016 04:14
Fish - ffmpeg - Convert webm to mp3
for i in (find . -type f -iname "*.webm")
set int (string trim -l -c=./ $i)
set name (string trim -r -c=.webm $int)
echo $name
ffmpeg -i $i -vn -acodec libmp3lame -q:a 2 $name.mp3
end
@darktef
darktef / gist:21ff4890089631db91649ea1c24a7ed1
Created November 7, 2016 04:56
Fish - move files in parent folder to child folder
find . -maxdepth 1 -type f -exec mv '{}' ./wk1/ \;
// it seems like no -t available in fish Shell and Mac...
@darktef
darktef / gist:5aa7a9261e15470eb0cf83693a06ee93
Last active December 31, 2016 04:02
Fish - fetch all git branches
for remote in (git branch -r | grep -v HEAD)
// remove the origin/
set bran (string replace -r 'origin\/' '' $remote)
// remove the left trailing white spaces
set br (string trim -l $bran)
set r (string trim -l $remote)
// create branch local to track the origin/branch
git branch --track $br $r
end
/* ref: http://stackoverflow.com/questions/3331353/transitions-on-the-display-property */
div > ul {
visibility: hidden;
opacity: 0;
transition: visibility 0s, opacity 0.5s linear;
}
div:hover > ul {
visibility: visible;
opacity: 1;
@darktef
darktef / gist:4f0fae5edf41764c7eff34ff5e71c47f
Created April 16, 2018 03:05
Convert pdf to image with ImageMagick
convert -density 300 bujo_MondayStart_Duplex_marriedtotheearth.pdf bullet_journal.png
@darktef
darktef / gist:d985a0452d774aa6702f3bae43e5ccab
Created August 8, 2018 17:08
Bash - Open multiple files from previous git log history
mvim -p $(git log --pretty="" --name-only -1 | tr -s '\n' ' ')
@darktef
darktef / commit_history.rb
Last active September 20, 2018 20:23
Ruby - Grab the commit history of all related files
results = []
file_names = `find . -print | grep '.*referral.*'`.split("\n");nil
file_names.each do |name|
output = `git log --follow --pretty=format:'{"commit": "%H","author": "%aN <%aE>","date": "%ad","message": "%f"},' -- #{name}`
results.concat(JSON.parse('[' + output.gsub("\n", '')[0..-2] + ']'))
end
mapping = {}
results.each do |res|
find . -type d -not -empty -exec echo mv \{\}/README.md \{\}.md \;
# This is to preview the command first with echo
find . -type d -empty -print # to show the folder to be deleted
find . -type d -empty -delete # to delete the empty folder
# https://unix.stackexchange.com/questions/46322/how-can-i-recursively-delete-empty-directories-in-my-home-directory
mv myfolder/* .
# move the folder content one level up