Skip to content

Instantly share code, notes, and snippets.

@jijosg
jijosg / Sync time with ntp server.txt
Last active May 21, 2020 08:26
Synchronize time with ntp server in windows 7
net set \\your_ntp_server_ip /set /yes
@jijosg
jijosg / remotescreenlock.sh
Last active May 21, 2020 08:25
How to remotely lock screen in CentOS
# To lock
ssh -X user@node "export DISPLAY=:0; gnome-screensaver; gnome-screensaver-command -l;"
# To unlock
ssh -X user@node "export DISPLAY=:0; gnome-screensaver; gnome-screensaver-command -d;"
@jijosg
jijosg / tree.sh
Created July 3, 2020 06:47
List tree structure in Linux
find . | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/"
@jijosg
jijosg / DataFrameOps.scala
Created July 17, 2020 05:27
Extend the dataframe with custom methods
import org.apache.spark.sql.DataFrame
//create a new dataframe object to add implicit method to all dataframes
object ExtraDataFrameOperations {
object implicits {
implicit def dFWithExtraOperations(df: DataFrame) = DFWithExtraOperations(df)
}
}
// Add a custom method to drop a column from a dataframe
case class DFWithExtraOperations(df: DataFrame) {
@jijosg
jijosg / spark-scala.bat
Last active August 14, 2020 06:25
Windows utilities
@ECHO OFF
::Select the id to start services
echo 1. Scala
echo 2. Spark-Shell
echo 3. Docker
echo 4. All
set x=0
set /p id="Enter choice: "
IF %id%==1 (
@jijosg
jijosg / userDF.scala
Created August 14, 2020 06:18
Generating random dataframe
import scala.util.Random
// Generate some sample data for two data sets
var states = scala.collection.mutable.Map[Int, String]()
var items = scala.collection.mutable.Map[Int, String]()
val rnd = new scala.util.Random(42)
// Initialize states and items purchased
states += (0 -> "AZ", 1 -> "CO", 2-> "CA", 3-> "TX", 4 -> "NY", 5-> "MI")
items += (0 -> "SKU-0", 1 -> "SKU-1", 2-> "SKU-2", 3-> "SKU-3", 4 -> "SKU-4",
#set timezone in linux / wsl
sudo dpkg-reconfigure tzdata
@jijosg
jijosg / jq.md
Last active August 18, 2021 18:36
JQ utils

create table from json

cat vuln.json |jq -r '(["ID","NAME"] | (., map(length*"-"))), (.vulnerabilities[] | [.package_name,.package_path]) | @tsv' |column -ts $'\t'

Get number of vulnerabilities from trivy JSON report

❯ trivy --version                                       
Version: 0.19.2
Vulnerability DB:
@jijosg
jijosg / wsl.md
Last active August 4, 2021 04:23
WSL tips

Use gitk in WSL

If you need the current directory use . else use absolute path

cd . && gitk.exe

@jijosg
jijosg / gitconfig.sh
Created February 8, 2022 06:15
Print git log in one line
git config --global alias.logline "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
git logline