Skip to content

Instantly share code, notes, and snippets.

View sajaddp's full-sized avatar

Sajad Dehshiri sajaddp

View GitHub Profile
@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",
@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
@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 = {
@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.

@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

@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) {
@kevinSuttle
kevinSuttle / meta-tags.md
Last active March 31, 2024 14:26 — forked from lancejpollard/meta-tags.md
List of Usable HTML Meta and Link Tags
@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
@fevangelou
fevangelou / my.cnf
Last active April 26, 2024 09:12
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.
#
@stephenhardy
stephenhardy / git-clearHistory
Created April 26, 2013 22:14
Steps to clear out the history of a git/github repository
-- Remove the history from
rm -rf .git
-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
-- push to the github remote repos ensuring you overwrite history
git remote add origin git@github.com:<YOUR ACCOUNT>/<YOUR REPOS>.git