Skip to content

Instantly share code, notes, and snippets.

View kijart's full-sized avatar
🎯
Focusing

LuisMi kijart

🎯
Focusing
View GitHub Profile
@kijart
kijart / package-version-extract.sh
Created June 21, 2021 15:14
package.json version extract
# shell script
APP_VERSION=$(grep -m1 version package.json | awk -F: '{ print $2 }' | sed 's/[", ]//g')
# shell script (jq)
APP_VERSION=$(jq -r ".version" package.json)
# node
APP_VERSION=$(node -p "require('./package.json').version")
@kijart
kijart / gist:bb2c10e7f46102ba202f8ddbb1fa190e
Created November 17, 2020 09:54
JavaScript deep merge
// Ref: https://stackoverflow.com/a/34749873
/**
* Simple object check.
* @param item
* @returns {boolean}
*/
export function isObject(item) {
return (item && typeof item === 'object' && !Array.isArray(item));
}
@kijart
kijart / gitlab-variables-dl
Created May 4, 2020 13:04
A small script to download a file of variables from GitLab CI (use this code on a bookmark URL)
javascript: (() => {
const download = (filename, data) => {
let element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(data));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
@kijart
kijart / trakt-backup.sh
Last active May 10, 2024 23:19 — forked from darekkay/trakt-backup.php
Trakt.tv backup bash script
#!/usr/bin/env bash
# Trakt backup script (note that user profile must be public)
# Trakt API documentation: http://docs.trakt.apiary.io
# Trakt client API key: http://docs.trakt.apiary.io/#introduction/create-an-app
set -e
# custom variables
API_KEY="CLIENT_API_KEY"
#!/bin/bash
# usage $0 database.sqlite3
cat <( sqlite3 "$1" .dump | grep "^ROLLBACK" -v ) <( echo "COMMIT;" ) | sqlite3 "fix_$1"
@kijart
kijart / env.ini
Created March 27, 2020 08:50
GitHub organization cloner (API v3)
[GITHUB]
MAX_PAGES = 7
ORG_NAME = org-name
PASSWORD = password
USERNAME = username
@kijart
kijart / git-remove-submodule.md
Last active November 21, 2019 14:27
How effectively delete a git submodule

To remove a submodule you need to:

  1. Delete the relevant section from the .gitmodules file.
  2. Stage the .gitmodules changes git add .gitmodules
  3. Delete the relevant section from .git/config.
  4. Run git rm --cached path_to_submodule (no trailing slash).
  5. Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  6. Commit git commit -m "Remove SUBMODULE-NAME submodule"
  7. Delete the now untracked submodule files rm -rf path_to_submodule
@kijart
kijart / rename-git-tag.md
Created September 10, 2019 08:17
Rename git tag

How to rename a GIT tag in the remote repo? Some times we would have added a tag, pushed it to remote and then realized that we’d named it wrong. Ex. VER_7_2_0 instead of VER_7_1_2.

Here is quick tip to rename a git tag in the remote repo.

Step 1: Create a new tag on the same commit point of old tag and push it, git tag new_tag old_tag

function hex2binDownload(hex, fileName) {
const binary = hex.match(/[A-F0-9]{2}/g).map((value) => parseInt(value, 16));
const byteArray = new Uint8Array(binary);
let a = window.document.createElement('a');
a.href = window.URL.createObjectURL(new Blob([byteArray], { type: 'application/octet-stream' }));
a.download = fileName;
document.body.appendChild(a)
a.click();
document.body.removeChild(a)
@kijart
kijart / media-queries.css
Created March 14, 2019 12:46
CSS media queries for desktop, tablet and mobile
/*
* Device: Desktops
* Screen: 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
/* CSS */
}
/*
* Device: Laptops, Desktops