Skip to content

Instantly share code, notes, and snippets.

View itsdonnix's full-sized avatar

Don Alfons itsdonnix

View GitHub Profile
@itsdonnix
itsdonnix / php.tmLanguage.json
Created January 2, 2025 06:37
VSCode PHP TextMate grammar with Annotation Highlighting
{
"information_for_contributors": [
"This file has been converted from https://github.com/KapitanOczywisty/language-php/blob/master/grammars/php.cson",
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/KapitanOczywisty/language-php/commit/5e8f000cb5a20f44f7a7a89d07ad0774031c53f3",
"scopeName": "source.php",
"patterns": [
{ "include": "#attribute" },
@itsdonnix
itsdonnix / check_php_syntax
Created November 21, 2024 09:27
Check PHP syntax
#!/bin/bash
# Usage: check_php_syntax [directory1] [directory2] ... [directoryN]
#
# This script checks the syntax of all PHP files within the provided directories.
# If no directories are specified, it checks the current directory by default.
#
# Example usage:
# check_php_syntax # Check PHP files in the current directory
# check_php_syntax /path/to/dir1 # Check PHP files in a single directory
@itsdonnix
itsdonnix / start-tmux-automatically-on-zsh.zsh
Created October 31, 2024 07:15
Start tmux automatically on zsh
# Let's kick things off by checking if we're already in a tmux session
if [[ ! -n $TMUX ]]; then
# Gather the mystical details of existing tmux sessions
session_details="$(tmux list-sessions)"
# Uncomment this block to create a new session if no sessions exist
# if [[ -z "$session_details" ]]; then
# tmux new-session # Bring a new session into existence!
# fi
@itsdonnix
itsdonnix / bash-to-zsh-hist.py
Created October 29, 2024 02:43 — forked from muendelezaji/bash-to-zsh-hist.py
Convert Bash history to Zsh history
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This is how I used it:
# $ cat ~/.bash_history | python bash-to-zsh-hist.py >> ~/.zsh_history
import sys
import time
@itsdonnix
itsdonnix / transfer_git_repository.sh
Created April 2, 2024 08:54
Transfer Git Repository
#!/bin/bash
# ====== USAGE ======
#
# ./tranfer_git_repository.sh <old_git_url> <target_git_url>
#
# Example:
# ./transfer_git_repository.sh https://<access_token>@git.example.com/Organization1/repo-name https://<access_token>@git.example.com/Organization2/repo-name
# Script arguments
@itsdonnix
itsdonnix / generateUUID.java
Last active July 31, 2023 11:13
Generate UUID in Java
public class Main {
/**
* Generates a random UUID (Universally Unique Identifier) in the format:
* xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx, where 'x' represents a random
* hexadecimal digit
* and 'y' represents a random hexadecimal digit with the 13th character set to
* '4' (version 4 UUID).
*
* @return The generated UUID as a string.
*/
@itsdonnix
itsdonnix / ttf-ms-tahoma-installer.sh
Created May 8, 2023 06:03 — forked from maxwelleite/ttf-ms-tahoma-installer.sh
Script to install the original Microsoft Tahoma font on Ubuntu distros
#!/bin/bash
# Author: Maxwel Leite
# Website: http://needforbits.wordpress.com/
# Description: Script to install the original Microsoft Tahoma Regular and MS Tahoma Bold (both version 2.60) on Ubuntu distros.
# Dependencies: wget and cabextract
# Tested: Ubuntu Saucy/Trusty/Xenial/Bionic
output_dir="/usr/share/fonts/truetype/msttcorefonts/"
tmp_dir="/tmp/ttf-ms-tahoma-installer"
@itsdonnix
itsdonnix / javascript_snippets.md
Created February 21, 2023 07:52
Javascript Snippets

Javascript Snippets

String Manipulation

  • Remove multiline string into one-line
    function stringToOneLine(str) {
      return String(str).replace(/[\t\r\n ]+/g, ' ').trim()
    }
@itsdonnix
itsdonnix / myscript
Created December 16, 2022 04:35 — forked from neatshell/myscript
simple bash template that handles mandatory and optional arguments
#!/bin/bash
script="myscript"
#Declare the number of mandatory args
margs=2
# Common functions - BEGIN
function example {
echo -e "example: $script -m0 VAL -m1 VAL -o1 -o2 VAL"
}
@itsdonnix
itsdonnix / git_cheatsheet.md
Last active November 24, 2022 09:23
Git Cheatsheet

Git Cheatsheet

Fetch all origin branches as local branches

git branch -r | grep -v '\->' | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git pull origin --all

Push all branches to all remotes: