Skip to content

Instantly share code, notes, and snippets.

View katoozi's full-sized avatar
🏡
Working from home

mohammad katoozi katoozi

🏡
Working from home
  • Tehran, Iran
View GitHub Profile
@katoozi
katoozi / api.ts
Last active June 21, 2020 08:16
react native api module with axios
import axios, { AxiosInstance, ResponseType, Method, AxiosResponse, AxiosRequestConfig } from 'axios';
import { storeData, getData } from '../helpers';
export const STORAGE_TOKEN_KEY_NAME = 'token';
const PROTOCOL = 'https://'; // protocols: 'http', 'https'
const BASE_URL = 'example.com/'; // include just domain or sub domain and domain name.
const LEVEL_ONE_ENDPOINT = 'api/v1/'; // first level uri. include versioning etc.
const TOKEN_PRIFIX = 'token '; // do not remove the space. samples: token, Bearer, etc.
@katoozi
katoozi / arrays.ts
Created June 21, 2020 08:11
react native hook and context helpers
/**
createArraySubsets generate array subsets.
@param {Array} array - source array.
@param {number} subsets - number of subsets. default is 2
@returns array with number of given subsets.
@example
createArraySubsets([1,2,3,4,5,6,7,8], 2); // output: [[1,2],[3,4],[5,6],[7,8]]
createArraySubsets([1,2,3,4], 3); // output: [[1,2,3], [4]]
createArraySubsets([1,2,3,4,5,6,7,8], 4); // output: [[1,2,3,4], [5,6,7,8]]
*/
@katoozi
katoozi / crontab
Last active August 21, 2020 15:21
postgresql daily backup at 1:00 AM
0 1 * * * /backups/backup.sh >/dev/null 2>&1
@fracasula
fracasula / encrypt_decrypt.go
Last active June 25, 2024 07:13
A simple example with Golang that uses AES-128 to encrypt and decrypt messages.
package mycrypto
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"io"
"time"
)
@katoozi
katoozi / auto_lock.sh
Last active February 3, 2024 01:26
my i3 config files
#!/bin/sh -e
# Take a screenshot
#scrot /tmp/screen_locked.png
# Pixellate it 10x
#mogrify -scale 10% -scale 1000% /tmp/screen_locked.png
# Lock screen displaying this image.
i3lock -i /usr/share/backgrounds/warty-final-ubuntu.png
@Nikkely
Nikkely / docker-compose.yml
Created May 13, 2019 09:12
redis replication on docker-compose
version: '3'
services:
redis:
image: redis:5.0.0
container_name: master
ports:
- "6379:6379"
networks:
- redis-replication
@katoozi
katoozi / google-search.sh
Created April 13, 2019 06:36
my google search script for dmenu
#!/bin/sh
browser=${BROWSER:-google-chrome-stable}
pgrep -x dmenu && exit
choice=$(echo "" | dmenu -i -p "Search Google:") || exit 1
if [ "$choice" = "" ]; then
$browser "https://google.com"
else
@katoozi
katoozi / i3-audio.conf
Last active May 27, 2019 07:39
my i3 script for increase, decrease and mute sound
# add this three line to i3 config file
bindsym XF86AudioRaiseVolume exec --no-startup-id ~/.i3/sound_script.sh incr #increase sound volume
bindsym XF86AudioLowerVolume exec --no-startup-id ~/.i3/sound_script.sh decr #decrease sound volume
bindsym XF86AudioMute exec --no-startup-id ~/.i3/sound_script.sh # mute sound
@mariocesar
mariocesar / api.js
Created September 26, 2017 04:21
Axios single configured instance
import axios from "axios";
const singleton = Symbol();
const singletonEnforcer = Symbol();
function readCookie(name) {
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
return (match ? decodeURIComponent(match[3]) : null);
}
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active June 29, 2024 15:54
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux