Skip to content

Instantly share code, notes, and snippets.

View mort3za's full-sized avatar
🦭

Morteza mort3za

🦭
View GitHub Profile
@mort3za
mort3za / gitlab-bookmarklets.md
Last active March 9, 2023 11:53
Some Gitlab bookmarklets. Use https://www.gibney.org/bookmarklet_editor to convert code to JS and edit it.

Cancel all jobs in column test-run, except those entered in prompt box:

javascript:(function()%7Bconst%20jobs%20%3D%20prompt('Enter%20jobs%2C%20comma%20separated').split('%2C')%3B%0Aconst%20contains%20%3D%20jobs.map(i%3D%3E%60%3Acontains(%22%24%7Bi%7D%22)%60).join()%3B%0A%24(%60%5Bdata-testid%3D%22stage-column%22%5D%3Acontains(%22test-run%22)%20.ci-job-component%3Anot(%24%7Bcontains%7D)%20.cancel%60).trigger('click')%7D)()
@mort3za
mort3za / ssh-key-login.sh
Created December 28, 2022 20:16
How to login to a Linux server with a second ssh key
# generate your new ssh key (e.g. id_rsa_second)
ssh-keygen
# add the public key to server manually (from your host panel) or by:
ssh-copy-id -i ~/.ssh/id_rsa_second.pub root@server_ip_address_here
vim ~/.ssh/config
# enter this code:
Host server_ip_address_here
AddKeysToAgent yes
@mort3za
mort3za / relative-time.ts
Created April 2, 2022 18:02
Relative time with automatic period detection
// example: const mydate = getRelativeTime('Sat Apr 02 2022 14:00:00 GMT');
// console.log(getRelativeTime(mydate);
// output: 4 hr. ago
// (while current time is 18:00)
export const getRelativeTime = (date: string): string => {
const unix = new Date(date).getTime();
type Periods = [string, number][];
const second = 1000;
var suitcase = '25618645791'
@mort3za
mort3za / number-format.twig
Last active October 26, 2021 14:50
Human readable number format in Twig. Example: human_readable(22111, 1) ===> 22.1K
{% macro human_readable(input, fraction) %}
{% spaceless %}
{% set kilo = 1000 %}
{% set mega = kilo * 1000 %}
{% set giga = mega * 1000 %}
{% set tera = giga * 1000 %}
{% if input < kilo %}
{{ input ~ ' B' }}
{% elseif input < mega %}
@mort3za
mort3za / browserstack-local.txt
Created March 17, 2021 21:59
How to use BrowserStack to see local development page (localhost)?
1. Download the BrowserStack binary from here:
https://www.browserstack.com/docs/live/local-testing
And setup it with your API key.
2. Map bs-local.com to 127.0.0.1 in your hosts file.
3. Build your web application with production environment (If you have a speedy internet connection, you may want to run it with development env)
4. Run your local server (localhost:3000 or similar) and test bs-local.com:3000 works too.
{"components":[{"type":"Spacer","id":5,"order":5,"section":1,"container":{"noPadding":true,"type":"limited","className":"primary"},"model":{"sizes":{"smAndDown":40,"mdAndUp":80}}},{"type":"Title","id":10,"order":10,"section":1,"container":{"noPadding":true,"type":"limited","className":"primary em-high"},"model":{"className":"typography-h1","tagName":"h1","body":"Saya"}},{"type":"Spacer","id":15,"order":15,"section":1,"container":{"noPadding":true,"type":"limited","className":"primary"},"model":{"sizes":{"smAndDown":40,"mdAndUp":80}}},{"type":"Markdown","id":30,"order":30,"section":1,"container":{"noPadding":true,"className":"primary em-high body-1 pb-20","type":"limited"},"model":{"animation":"fade-up","body":"1 This is a *markdown* text"}},{"type":"Image","id":40,"order":40,"section":1,"container":{"noPadding":true,"type":"full","className":"primary"},"model":{"animation":"fade-up","image":{"src":"https://res.cloudinary.com/whynotearth/image/upload/v1583765719/Saya/home-hero_xzzuff.png","alt":"a beautiful la
item 1 $5
item 2 $5
@mort3za
mort3za / colors.scss
Last active January 13, 2020 07:18
Customize Vuetify (version 2.2.3) sass variables and change theme colors
// src/styles/colors.scss
// Copy contents of /node_modules/vuetify/src/styles/settings/_colors.scss and modify it's contents here