Skip to content

Instantly share code, notes, and snippets.

View NISH1001's full-sized avatar
💭
Staring into the abyss...

Nish NISH1001

💭
Staring into the abyss...
View GitHub Profile
@NISH1001
NISH1001 / bash-logger.md
Created January 19, 2019 04:18
log bash history to file

Vanilla Configuration

If you are not using any third party variants of bash like oh-my-bash, put the following command in your .bashrc:

export PROMPT_COMMAND='if [ "$(id -u)" -ne 0 ]; then echo "$(date "+%Y-%m-%d.%H:%M:%S") $(pwd) $(history 1)" >> ~/.logs/bash-history-$(date "+%Y-%m-%d").log; fi'

Close bashrc and open new terminal. Now, your history are saved in the folder ~/.logs according to timestamp.
Example file

/home/paradox/.logs/bash-history-2018-12-15.log
@NISH1001
NISH1001 / TopicModelZoo.md
Created January 24, 2019 07:24 — forked from scapegoat06/TopicModelZoo.md
Topic Model Zoo
@NISH1001
NISH1001 / watermark.sh
Created January 26, 2019 23:45
add watermark to video
# add watermark
ffmpeg -y -i demo.mp4 -i logo.png -filter_complex \
"[1]lut=a=val*0.3[a];[0][a]overlay=5:600" \
-c:v libx264 -an output.mp4
@NISH1001
NISH1001 / cropper.sh
Last active October 15, 2019 11:26
crop video using ffmpeg
# WIDTH:HEIGHT:Xstart:Ystart
ffmpeg -i output.mp4 -filter:v "crop=700:1170:0:50" cropped.mp4
# cut video
ffmpeg -ss 00:03:00.8 -i test.mp4 -c copy -t 00:00:02.2 output.mp4 -y
# embed subtitle
ffmpeg -i inp.mp4 -vf ass=subtitles.ass out.mp4
@NISH1001
NISH1001 / oracle.md
Last active July 9, 2021 05:21
oracle

Check If archivelog mode is enabled

select log_mode from v$database;

Enable Archive mode

alter database archivelog;
@NISH1001
NISH1001 / hdfs.md
Last active March 12, 2019 19:49
Hadoop File System (HDFS) shit

Append File to File

hdfs dfs -appendToFile <src> <dest>

Echo to File

echo "hello world" | hadoop fs -appendToFile - /dir/hadoop/hello_world.txt
@NISH1001
NISH1001 / linux-noob.md
Last active March 27, 2020 02:02
linux command

Sort Filenames by Size

du ./ | sort -n -r | head -n 20

Search string in files

grep -rnw -e "string" .
@NISH1001
NISH1001 / scala.md
Created March 6, 2019 11:42
some scala shit

Data Type Conversion

//first read data to dataframe with any way suitable for you
var df: DataFrame = ???
val dfSchema = df.schema

import org.apache.spark.sql.functions._
import org.apache.spark.sql.types.DecimalType
dfSchema.foreach { field =>
 field.dataType match {
@NISH1001
NISH1001 / sql-server-cdc.md
Last active September 28, 2024 20:03
CDC (change data capture) for Microsoft SQL server

MSSQL CLI

github...

UI

https://dbeaver.io/

sqlcmd -S <ip> -d <dbname> -U <username> -P <password> -I
@NISH1001
NISH1001 / ffmpeg-audio-gif.sh
Last active March 6, 2024 18:44
merge audio with a looped GIF using ffmpeg
#!/bin/bash
echo "i am paradox"
#ffmpeg -i audio.mp3 -ignore_loop 0 -i test.gif -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -shortest -strict -2 -c:v libx264 -threads 5 -c:a aac -b:a 192k -pix_fmt yuv420p -shortest final.mp4
# ffmpeg -i audio.mp3 -ignore_loop 0 -i test.gif -shortest -strict -2 -c:v libx264 -threads 5 -c:a aac -b:a 192k -pix_fmt yuv420p -shortest final.mp4
# ffmpeg -i audio.mp3 -ignore_loop 0 -i test.gif -vf "scale=trunc(iw/2)*1:trunc(ih/2)*2" -shortest -strict -2 -c:v libx264 -threads 5 -c:a aac -b:a 192k -pix_fmt yuv420p -shortest final.mp4