Skip to content

Instantly share code, notes, and snippets.

View Thecarisma's full-sized avatar
👽

A Thecarisma

👽
View GitHub Profile
@Thecarisma
Thecarisma / install_sonar_scanner.sh
Last active August 22, 2023 13:08
Script to setup sonar-scanner on a Linux computer
#!/bin/sh
SONAR_QUBE_HOST="$1"
if [[ "$SONAR_QUBE_HOST" == "" ]];
then
SONAR_QUBE_HOST=http://34.89.91.40:9000
fi
# download and install sonar-scanner
apt-get update
@Thecarisma
Thecarisma / $.sh
Last active January 10, 2021 13:20
Bash - Shebang, Hebang and Webang Command + Subshell
#!/bin/bash
FIRST_COMMAND=
OTHER_COMMANDS=
BANG_LINE=
main()
{
for arg in "$@"
do
@Thecarisma
Thecarisma / $.ps1
Last active December 14, 2023 20:54
Powershell - Shebang, Hebang and Webang Command + Subshell
Param(
# the commands to execute or the file to execute
[Parameter(Mandatory=$false, ValueFromRemainingArguments = $true)]
[string[]]$Commands
)
Function Main {
If ($Commands) {
Evalute-Line $Commands
@Thecarisma
Thecarisma / monitorpod.bat
Last active December 12, 2022 15:31
A batch script to monitor a kubernetes pod status, it shows windows toast notification when the pod status changes. Change the NAME to your pod name.
@echo off
setlocal enabledelayedexpansion
REM Listen for kubenetes pod status changes,
REM change the value of NAME to your pod name or unique
REM part of the name, if more than one pod has the unique
REM part there will be conflict in the log
REM or you can set the pod name from commandline
REM
REM $ monitorpod podname apodnamespace anotherpodname apodpartname
@Thecarisma
Thecarisma / sendwintoast.ps1
Created January 31, 2020 11:23
A Powershell script to send Windows Toast notification. Usage: sendwintoast.ps1 "Your Title" "Your Message" Info
Param([string]$Title,[string]$Message,[string]$MessageType)
Add-Type -AssemblyName System.Windows.Forms
$global:balloon = New-Object System.Windows.Forms.NotifyIcon
Get-Member -InputObject $Global:balloon 2>&1 | Out-Null
[void](Register-ObjectEvent -InputObject $balloon -EventName MouseDoubleClick -SourceIdentifier IconClicked -Action {
$global:balloon.dispose()
})
$path = (Get-Process -id $pid).Path
$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path)
[System.Windows.Forms.ToolTipIcon] | Get-Member -Static -Type Property 2>&1 | Out-Null
@Thecarisma
Thecarisma / async-script-loader.js
Last active December 31, 2019 21:37
Load a remote javascript file in the browser synchronously. Wait till loading complete with callback.
//Example: log 'Hello World' after language-colors.css load completed
/**
loadScript("https://quickutils.github.io/language-colors/language-colors.css", function() {
console.log('Hello World');
});
**/
function loadScript(url, callback) {
var head = document.body;
var script = document.createElement('script');
@Thecarisma
Thecarisma / device-enabler.bat
Created December 28, 2019 22:05
Use brute-force method to enable a device when disabled by device control programs (e.g anti-virus). This simple script can be used to activate a disk drive even if a device control program is up.
@echo off
REM download the microsoft devcon app https://docs.microsoft.com/en-us/windows-hardware/drivers/devtest/devcon
REM Download x64 if your arch is x64 same for x32
REM change this 'USBSTOR\DISK&VEN_WD&PROD_ELEMENTS_25A2&REV_1021\57584131413438324C384543&0' to your device instace path
REM Run as Administrator
:exec
devcon enable @"USBSTOR\DISK&VEN_WD&PROD_ELEMENTS_25A2&REV_1021\57584131413438324C384543&0"
goto:exec
@Thecarisma
Thecarisma / playground.rs
Created December 15, 2019 21:47 — forked from rust-play/playground.rs
Code shared from the Rust Playground
pub fn reverse_string(s: &mut Vec<char>) {
if s.len() <= 1 {
return;
}
let mut i = 0;
let mut j = s.len() - 1;
while i != j && i < j {
s.swap(i, j);
i += 1;
j -= 1;
@Thecarisma
Thecarisma / ptarget.h
Created July 10, 2018 20:47 — forked from ByteProject/ptarget.h
header for compiler and OS detection (portable C)
/*
* ptarget.h
*
* Coded by Stefan Vogt, revised Feb 18, 2011.
* Released under the FreeBSD license.
* http://www.byteproject.net
*
* header for compiler and OS detection
*
*/