Skip to content

Instantly share code, notes, and snippets.

View alipandidan's full-sized avatar

Ali Pandidan alipandidan

View GitHub Profile
@alipandidan
alipandidan / ytm-desktop.sh
Last active June 11, 2023 20:19
Create Youtube Music Desktop using Nativefier
#!/bin/bash
npx nativefier --single-instance \
--disable-context-menu \
--disable-dev-tools \
--honest \
--icon icon.png \
https://music.youtube.com \
./dist/
@alipandidan
alipandidan / MinimalAPIs.md
Created September 14, 2021 09:06 — forked from davidfowl/MinimalAPIs.md
Minimal APIs at a glance
@alipandidan
alipandidan / jenkins_list_groups.groovy
Created November 9, 2020 05:24
Jenkins list groups on all items
// It's 6:00 and I haven't slep, I'll clean it later
// import nectar.plugins.rbac.groups.*
// import com.cloudbees.hudson.plugins.folder.*
// import com.cloudbees.jenkins.plugins.foldersplus.*
// import com.cloudbees.hudson.plugins.folder.properties.FolderProxyGroupContainer
// import nectar.plugins.rbac.groups.JobProxyGroupContainer
// for (item in Jenkins.instance.getAllItems()) {
@alipandidan
alipandidan / ansible_map_join.yml
Last active September 14, 2021 09:08
Ansible map and join
joined_groups: "{{ list|default([])|map(attribute='id')|join(',') }}"
@alipandidan
alipandidan / update_commit_author.sh
Created October 13, 2020 12:12
Update git commit author info
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="<OLD_EMAIL>"
CORRECT_NAME="<NEW_NAME>"
CORRECT_EMAIL="<NEW_EMAIL>"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
@alipandidan
alipandidan / git_hook_telegram_notification.sh
Created October 8, 2020 23:02
Telegram notification git hook
COMMITS=$(git --no-pager log origin/master..HEAD --format="- [%h] %B")
API_URL="https://api.telegram.org/bot${BOT_TOKEN}/sendMessage?chat_id=${CHAT_ID}"
curl --silent -o /dev/null \
--header "Content-Type: application/json" \
--request POST \
--data "{\"text\": \"${COMMITS}\"}" \
$API_URL
@alipandidan
alipandidan / keepawake.ps1
Created May 23, 2020 14:24 — forked from jamesfreeman959/keepawake.ps1
A very simple PowerShell script to keep a Windows PC awake and make lync think the user is active on the keyboard
# Useful references:
#
# https://superuser.com/questions/992511/emulate-a-keyboard-button-via-the-command-line
# https://ss64.com/vb/sendkeys.html
# https://social.technet.microsoft.com/Forums/windowsserver/en-US/96b339e2-e9da-4802-a66d-be619aeb21ac/execute-function-one-time-in-every-10-mins-in-windows-powershell?forum=winserverpowershell
# https://learn-powershell.net/2013/02/08/powershell-and-events-object-events/
#
# Future enhancements - use events rather than an infinite loop
while (1) {
$wsh = New-Object -ComObject WScript.Shell
@alipandidan
alipandidan / ci_jobs.groovy
Created May 16, 2020 20:47 — forked from tknerr/ci_jobs.groovy
Example JobDSL for a multibranchPipelineJob which keeps only the last 10 builds
// define the bitbucket project + repos we want to build
def bitbucket_project = 'myproj'
def bitbucket_repos = ['myrepo1', 'myrepo2']
// create a pipeline job for each of the repos and for each feature branch.
for (bitbucket_repo in bitbucket_repos)
{
multibranchPipelineJob("${bitbucket_repo}-ci") {
// configure the branch / PR sources
branchSources {
@alipandidan
alipandidan / abort_previous_build.groovy
Last active May 5, 2020 16:29
Abort previous Jenkins build
import hudson.model.Result
import hudson.model.Run
import jenkins.model.CauseOfInterruption.UserInterruption
def call() {
// https://stackoverflow.com/a/49901413/4763512
Run previousBuild = currentBuild.rawBuild.getPreviousBuildInProgress()
while (previousBuild != null) {
if (previousBuild.isInProgress()) {
def executor = previousBuild.getExecutor()
@alipandidan
alipandidan / auto_tags.py
Created December 6, 2019 08:58 — forked from rkrzr/auto_tags.py
Automatically generate ansible tags of the same name for each role in a playbook
"""
This module implements an Ansible plugin that is triggered at the start of a playbook.
The plugin dynamically generates a tag for each role. Each tag has the same name as its role.
The advantage of this is that it saves you some boilerplate, because you don't have to wrap
all tasks of a role in an additional block and assign a tag to that.
Additionally, it works automatically when you add new roles to your playbook.
Usage is exactly the same as without this plugin: