Skip to content

Instantly share code, notes, and snippets.

@mujahidk
mujahidk / debian-enable-disable-sleep.md
Last active February 23, 2024 01:24
Debian enable/disable sleep

Debian enable/disable sleep

From: https://wiki.debian.org/Suspend

To Disable Sleep

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

To Enable

@mujahidk
mujahidk / gpg-key-signing.md
Last active January 18, 2024 22:14
GPG Key signing for Git.

Generating GPG Keys and adding it to Git.

Generating GPG Keys

gpg --gen-key

List all GPG Keys

gpg --list-secret-keys --keyid-format LONG
@mujahidk
mujahidk / fetch-url.groovy
Last active January 15, 2024 09:50
One line command to fetch content from an URL in Groovy
// Simple way to fetch content from an URL using Groovy
println "https://example.com".toURL().text
// More information about Groovy URL class: http://docs.groovy-lang.org/latest/html/groovy-jdk/java/net/URL.html
@mujahidk
mujahidk / ls-mega-bytes.sh
Created December 23, 2016 15:01
List files using ls and size in MB (mega bytes)
# https://xkcd.com/1168/ :)
ls -l --block-size=M
@mujahidk
mujahidk / curl.ps1
Last active May 19, 2023 20:48
PowerShell WebClient script with basic authentication to export content from a website. Simple alternative to curl in Windows.
# Uncomment to disable Certificate errors
# [Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$url = "http://example.com/data.json"
$user = "data-user"
$password = "password"
# Output file path into current directory.
$file= ($pwd).path + "\export.json"
Write-Host "Exporting data to: $file"
@mujahidk
mujahidk / base64coding.groovy
Created December 22, 2017 23:40
Base64 encoding and decoding in Groovy.
def text = "Going to convert this to Base64 encoding!"
// Encode
def encoded = text.bytes.encodeBase64().toString()
println encoded
// Decode
byte[] decoded = encoded.decodeBase64()
println new String(decoded)
@mujahidk
mujahidk / oracle-plsql-measure-time.sql
Created January 29, 2019 18:24
Oracle PL/SQL block to run a query multiple times and measure time.
SET TIMING ON
DECLARE
START_TIME PLS_INTEGER;
COUNT_ROW NUMBER;
BEGIN
FOR I IN 1..10 LOOP
START_TIME := DBMS_UTILITY.GET_TIME();
SELECT COUNT(*) INTO COUNT_ROW FROM (SELECT * FROM PERSON ORDER BY LASTNAME ASC) WHERE ROWNUM <= 50;
DBMS_OUTPUT.PUT_LINE('Selected ' || COUNT_ROW || ' in ' || (DBMS_UTILITY.GET_TIME() - START_TIME) || '/100 seconds');
@mujahidk
mujahidk / git-find-big-files-in-hist.sh
Created July 2, 2021 13:34 — forked from masbicudo/git-find-big-files-in-hist.sh
Script to find large files in git history
#!/bin/bash
# This code is based on the awesome answer by @torek from StackOverflow:
# https://stackoverflow.com/a/41626019/195417
# I have only made a shell for his code, added some options, added some colors
# and voilà!
#
# This script can be used to find large files inside a git repository
# and it's whole history. It will list files larger than a given threshold,
# and display these files in a colored human readable way.
#
@mujahidk
mujahidk / http-form-post-xml-resp.groovy
Last active May 23, 2021 17:59
Groovy Http Post and Xml response message
def fullUrl = "http://localhost:8080/emulator/"
def url = new URL(fullUrl)
def connection = url.openConnection()
connection.doOutput = true
connection.setRequestMethod("POST")
connection.setRequestProperty("Content-Type", 'application/x-www-form-urlencoded')
def data = "Text data"
def writer = new OutputStreamWriter(connection.outputStream)
@mujahidk
mujahidk / .vimrc
Last active May 27, 2020 13:51
VIM configuration
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'git://git.wincent.com/command-t.git'