Skip to content

Instantly share code, notes, and snippets.

View mberneti's full-sized avatar
🎯
Focusing

mohammadreza berneti mberneti

🎯
Focusing
View GitHub Profile

var

var happyDays = function(day){
  if(day === 'sunny') {
    var a = 'apples'; //a is function-scoped 
  }
  
  console.log(a); // apples
}
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active May 12, 2025 17:35
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@kent119
kent119 / nginx_reverse_for_notebook
Last active July 18, 2020 00:14
Config Nginx as a reverse proxy for Jupyter notebook on VPS
# /etc/nginx/sites-enabled/some.domain
# Change the server name {some.domain}
# Change the {host.of.notebook} and {port} in the following locations
server {
listen 80;
# Change the server name {some.domain}
server_name some.domain;
location / {
# Change the {host.of.notebook} and {port}
proxy_pass http://host.of.notebook:port;
@hackjutsu
hackjutsu / example.js
Last active November 16, 2022 14:16
[Highlight.js + line number] This snippet adds line number support to Highlight.js. Besides, special css trick is applied to stop the line numbers from being selected and copied. #tags: highlight, lepton
import HighlightJS from 'highlight.js'
createHighlightedCodeBlock (content, language) {
let lineNumber = 0
const highlightedContent = HighlightJS.highlightAuto(content, [language]).value
/* Highlight.js wraps comment blocks inside <span class="hljs-comment"></span>.
However, when the multi-line comment block is broken down into diffirent
table rows, only the first row, which is appended by the <span> tag, is
highlighted. The following code fixes it by appending <span> to each line
@radiovisual
radiovisual / .eslintrc
Last active October 30, 2021 11:55
React Native AirBnB ESLint Config
{
"parser": "babel-eslint",
"plugins": [
"react",
"react-native"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"modules": true
function resolvePromise(promise, iterator) {
promise.then(
(response) => {
let result = iterator.next(response);
if (!result.done) {
sync(result.value, iterator);
}
},
error => {
let result = iterator.next(error);
@daliborgogic
daliborgogic / delay.js
Created December 16, 2016 15:26
Node.js Async/Await delay
'use strict'
const timeout = ms => new Promise(res => setTimeout(res, ms))
function convinceMe (convince) {
let unixTime = Math.round(+new Date() / 1000)
console.log(`Delay ${convince} at ${unixTime}`)
}
async function delay () {
@hasangilak
hasangilak / master-and-slave.js
Created October 30, 2016 07:27
I want one master action to complete its job asynchronously and at the end of its job free its slaves so I wrote this tiny library.
let master = () => {
return new Promise( (resolve, reject) => {
setTimeout(() => { resolve('ok'); }, 3000);
});
}
let slaves = [
{
start: () => {
console.log("loading")
@nicolas-briemant
nicolas-briemant / rules.md
Last active December 23, 2020 04:44
how to structure a redux application

how to structure a redux application

A well-thought structure is helpful for the maintainability of the code.
It also helps to avoid some common anti-patterns.
A redux application is not necessary a big thing, it can also be a component that is complex enough to require redux.

There are the only 2 rules to comply with, so it is not painful to always have them in mind while developing.

use a modular organisation

@singhshivam
singhshivam / Immutable JS Examples
Last active April 10, 2025 14:48
Immutable JS Examples
List()
var list = Immutable.List([1,2,3])
// [1, 2, 3]
List.isList()
Immutable.List.isList(list)
// true
List.of()
var list = Immutable.List.of(1,2,3);