Skip to content

Instantly share code, notes, and snippets.

View majidalaeinia's full-sized avatar
🎯
Focusing

Majid Alaeinia majidalaeinia

🎯
Focusing
View GitHub Profile
@daalvand
daalvand / backup.sh
Last active July 31, 2023 09:18
Backup Docker Images
#!/bin/bash
images_dir="$(dirname "$(readlink -f "$0")")/images"
mkdir -p $images_dir
#This awk command removes duplicates based on the last field ({{.ID}}) of the input lines by utilizing an associative array seen. It prints only the first occurrence of each unique ID
images=$(docker images --format "{{.Repository}}:{{.Tag}}-{{.ID}}" --filter "dangling=false" | awk -F'-' '!seen[$NF]++')
for image in $images; do
@MicahParks
MicahParks / go get private GitLab with group and subgroup (Golang modules).md
Last active January 12, 2024 05:43
go get private GitLab with group and subgroup (Golang modules)

Problem

The go command line tool needs to be able to fetch dependencies from your private GitLab, but authenticaiton is required.

This assumes your private GitLab is hosted at privategitlab.company.com.

Environment variables

The following environment variables are recommended:

export GO111MODULE=on
export GOPRIVATE=privategitlab.company.com
#!/bin/bash
# A simple convertor for change the text from selection and replace all persian charachter with
# English charachter in clipboard.
# Just assign it to a key binding, with anything you like (i3 for example).
# I wrote this for http://linuxvaman.ir/
# Publishe under WTFPL
# fzerorubigd <fzero@rubi.gd> 2 Dec 2015
change_string() {
@gaearon
gaearon / modern_js.md
Last active April 18, 2024 15:01
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@dutymess
dutymess / Yasna.xml
Created April 25, 2018 13:45
PHPStrom Code Style Settings (not violating PSR1&2)
<code_scheme name="Yasna">
<option name="OTHER_INDENT_OPTIONS">
<value>
<option name="INDENT_SIZE" value="4" />
<option name="CONTINUATION_INDENT_SIZE" value="8" />
<option name="TAB_SIZE" value="4" />
<option name="USE_TAB_CHARACTER" value="true" />
<option name="SMART_TABS" value="true" />
<option name="LABEL_INDENT_SIZE" value="0" />
<option name="LABEL_INDENT_ABSOLUTE" value="false" />
@crgimenes
crgimenes / stringToReaderCloser.go
Last active April 11, 2024 15:41
string to io.ReadCloser
package main
import (
"bytes"
"fmt"
"io"
"os"
"strings"
)
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Subscriptions - freek@spatie.be</title>
</head>
<body>
<outline text="PHP" title="PHP">
<outline htmlUrl="http://frederickvanbrabant.com" title="frederickvanbrabant.com" xmlUrl="http://frederickvanbrabant.com/feed.xml" type="rss" text="frederickvanbrabant.com"/>
<outline htmlUrl="http://mattallan.org" title="mattallan.org" xmlUrl="http://mattallan.org/feed.xml" type="rss" text="mattallan.org"/>
<outline title="asked.io" xmlUrl="https://asked.io/rss" type="rss" text="asked.io"/>
@knadh
knadh / zsh-elapsed-time.md
Last active May 15, 2024 19:22
Elapsed and execution time for commands in ZSH

Elapsed and execution time display for commands in ZSH

Append this to your ~/.zshrc file.

function preexec() {
 timer=$(($(date +%s%0N)/1000000))
@LeCoupa
LeCoupa / redis_cheatsheet.bash
Last active March 18, 2024 09:08
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.