Skip to content

Instantly share code, notes, and snippets.

View sayjeyhi's full-sized avatar
:electron:
Building things

Jafar Rezaei sayjeyhi

:electron:
Building things
View GitHub Profile
@BlakeGardner
BlakeGardner / install nano.sh
Last active May 14, 2024 06:45
Syntax highlighting in nano on Mac OS
# Last updated May, 2024 for Apple silicon Macs
# Install Homebrew if you don't already have it: https://brew.sh
# install nano from homebrew
brew install nano nanorc
# update your nanorc file
echo 'include "'"$(brew --cellar nano)"'/*/share/nano/*.nanorc"' >> ~/.nanorc
# close and re-open your terminal and you'll have syntax highlighting
@eddmann
eddmann / SecureSessionHandler.php
Created April 9, 2014 12:18
Secure session handler implementation.
<?php
class SecureSessionHandler extends SessionHandler {
protected $key, $name, $cookie;
public function __construct($key, $name = 'MY_SESSION', $cookie = [])
{
$this->key = $key;
$this->name = $name;
@acauamontiel
acauamontiel / mixins.styl
Last active May 5, 2018 12:28
Useful mixins for Stylus
/*
* Clearfix
*/
clearfix()
&:before,
&:after
content ' '
display table
&:after
@zhiguangwang
zhiguangwang / README.md
Last active June 2, 2024 07:50
Installing and running shadowsocks on Ubuntu Server

Installing and running shadowsocks on Ubuntu Server

16.10 yakkety and above

  1. Install the the shadowsocks-libev package from apt repository.

     sudo apt update
     sudo apt install shadowsocks-libev
    
  2. Save ss.json as /etc/shadowsocks-libev/config.json.

@edysegura
edysegura / array-reduce.js
Created June 9, 2016 12:53
[JS] Using reduce to calculate average
var scores = [1, 4, 6, 8];
var result = scores.reduce((total, score) => total + score) / scores.length;
console.log(result); // 4.75
@MoienTajik
MoienTajik / iranian-phone-numbers-regex.md
Last active June 10, 2024 22:59
Regex For Iranian Mobile Phone Numbers

Regex For Iranian Phone Numbers

This regex supports all kinds of Iranian mobile phone numbers :

^(\+98|0)?9\d{9}$


Regex Visualized

@gaearon
gaearon / uselayouteffect-ssr.md
Last active May 16, 2024 14:13
useLayoutEffect and server rendering

If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.

You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.

Option 1: Convert to useEffect

If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.

function MyComponent() {
@sayjeyhi
sayjeyhi / RaceSaga.js
Last active November 4, 2019 13:51
Advancerd Saga samples
import { race, cancel, take, fork, all, put, select } from 'redux-saga/effects';
export function* fetchDataForPage() {
const userId = yield select(getUserId);
try {
if (!userId) {
throw new Error('No user - aborting');
}
kill -9 $(lsof -i:PORT -t) 2> /dev/null