Skip to content

Instantly share code, notes, and snippets.

View sajaddp's full-sized avatar

Sajad Dehshiri sajaddp

View GitHub Profile
@AzadGh95
AzadGh95 / import-sql-file-to-docker-mysql.sh
Created September 7, 2021 10:48
Import SQL file to docker MySQL
docker exec -i site_mysql_1 mysql -u root -p secret --init-command="set autocommit=0" dbname < ~/sample.sql
@ebihimself
ebihimself / README.MD
Last active March 15, 2023 08:04
Carbon month name localization with Laravel

Carbon months localization with Laravel translation files

Localization

Translate your desired month in the app.php translation file under its localization directory.

Methods

parseDate() method is responsible to format and translate the month name. In case you need to edit the input format or the returned format this method needs to be modified to meet your need.

getCurrentLocalizaedDate() method is just a test method to show the output.

@jonasgroendahl
jonasgroendahl / useWebSockets.tsx
Created October 29, 2020 21:48
useWebSockets()
import {useEffect, useRef, useState} from 'react';
import io from 'socket.io-client';
type Props = {
userId: number;
enabled: boolean;
onConnected?: () => void;
};
type Message = {
@berkorbay
berkorbay / github_desktop_ubuntu.md
Last active April 14, 2024 14:07
To install Github Desktop for Ubuntu

IMPORTANT

See the following links for further updates to Github Desktop for Ubuntu. These are official instructions. (also mentioned by fetwar on Nov 3, 2023)

For the sake of "maintaining the tradition" here is the updated version.

@astoilkov
astoilkov / readme.md
Last active March 13, 2024 10:19
Async Operations with useReducer Hook

Async Operations with useReducer Hook

9 March, 2019

We were discussing with @erusev what we can do with async operation when using useReducer() in our application. Our app is simple and we don't want to use a state management library. All our requirements are satisfied with using one root useReducer(). The problem we are facing and don't know how to solve is async operations.

In a discussion with Dan Abramov he recommends Solution 3 but points out that things are fresh with hooks and there could be better ways of handling the problem.

Problem

@Tamal
Tamal / git-ssh-error-fix.sh
Last active April 16, 2024 13:32
Solution for 'ssh: connect to host github.com port 22: Connection timed out' error
$ git clone git@github.com:xxxxx/xxxx.git my-awesome-proj
Cloning into 'my-awesome-proj'...
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
$ # This should also timeout
$ ssh -T git@github.com
ssh: connect to host github.com port 22: Connection timed out
$ # but this might work
@endel
endel / generateUserAgent.ts
Created September 13, 2018 23:41
Fake User Agent Generator
export function* generateUserAgent() {
let webkitVersion = 10;
let chromeVersion = 1000;
const so = [
'Windows NT 6.1; WOW64',
'Windows NT 6.2; Win64; x64',
"Windows NT 5.1; Win64; x64",,
'Macintosh; Intel Mac OS X 10_12_6',
"X11; Linux x86_64",
@fevangelou
fevangelou / my.cnf
Last active April 18, 2024 20:25
Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers)
# === Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers) ===
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# ~ Updated December 2021 ~
#
#
# The settings provided below are a starting point for a 8-16 GB RAM server with 4-8 CPU cores.
# If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage.
#
@ghinda
ghinda / object-to-form-data.js
Last active March 30, 2024 18:51
JavaScript Object to FormData, with support for nested objects, arrays and File objects. Includes Angular.js usage.
// takes a {} object and returns a FormData object
var objectToFormData = function(obj, form, namespace) {
var fd = form || new FormData();
var formKey;
for(var property in obj) {
if(obj.hasOwnProperty(property)) {
if(namespace) {
@gitaarik
gitaarik / git_submodules.md
Last active April 19, 2024 10:22
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of usecases of submodules:

  • Separate big codebases into multiple repositories.