Skip to content

Instantly share code, notes, and snippets.

View behnammodi's full-sized avatar
:octocat:
...

Behnam behnammodi

:octocat:
...
View GitHub Profile
@behnammodi
behnammodi / actions.js
Last active August 6, 2019 10:04
Redux structure
export default {
ACTIONS_INC: state => ({
...state,
count: state.count + 1
}),
ACTIONS_DEC: state => ({ ...state, count: state.count - 1 })
};
@behnammodi
behnammodi / react-redux-sample.js
Last active May 12, 2019 11:16
React Redux Sample
import React from "react";
import { createStore } from "redux";
import { connect, Provider } from "react-redux";
const ACTIONS_INC = "ACTIONS_INC";
const ACTIONS_DEC = "ACTIONS_DEC";
function counter(state = { count: 0 }, { type }) {
const actions = {
[ACTIONS_INC]: () => ({ count: state.count + 1 }),
@Gioni06
Gioni06 / darkmode.js
Last active November 30, 2022 00:11
Enable Dark mode with css variables and js
function activateDarkMode() {
const rootElement = document.querySelector(':root')
const darkTheme = {
'--background-color': '#1e1e1e',
'--primary-color': '#157efb',
'--font-color': '#dedede',
'--subtle-primary-color': '#151513',
'--block-background-color': '#323232',
'--menu-item-color': '#dedede',
'--menu-item-hover-color': '#157efb',
@jamescoxhead
jamescoxhead / applicationHost.config.xml
Created February 8, 2016 10:49
IIS URL Compression for SVG and fonts (under C:\Windows\System32\inetsrv\config)
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
@SleepWalker
SleepWalker / swipe.js
Created September 30, 2015 04:59
A simple swipe detection on vanilla js
var touchstartX = 0;
var touchstartY = 0;
var touchendX = 0;
var touchendY = 0;
var gesuredZone = document.getElementById('gesuredZone');
gesuredZone.addEventListener('touchstart', function(event) {
touchstartX = event.screenX;
touchstartY = event.screenY;
@joseluisq
joseluisq / terminal-git-branch-name.md
Last active June 10, 2024 15:03
Add Git Branch Name to Terminal Prompt (Linux/Mac)

Add Git Branch Name to Terminal Prompt (Linux/Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@acdlite
acdlite / flux.js
Last active October 7, 2021 17:19
A Redux-like Flux implementation in <75 lines of code
/**
* Basic proof of concept.
* - Hot reloadable
* - Stateless stores
* - Stores and action creators interoperable with Redux.
*/
import React, { Component } from 'react';
export default function dispatch(store, atom, action) {
@DWboutin
DWboutin / web.config
Created January 14, 2014 21:41
web.config GZIP compression Add the configuration shown below in the in web.config file. This configuration setup enable gzip compression on static and on dynamic content.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
<dynamicTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/javascript" enabled="true"/>
<add mimeType="*/*" enabled="false"/>
@flesch
flesch / basic-auth.js
Last active July 27, 2022 12:39
HTTP Basic Authentication with Express, without express.basicAuth.
var express = require("express");
var app = express();
app.get("/restricted", function(req, res, next){
// Grab the "Authorization" header.
var auth = req.get("authorization");
// On the first request, the "Authorization" header won't exist, so we'll set a Response
// header that prompts the browser to ask for a username and password.