Skip to content

Instantly share code, notes, and snippets.

View irfanandriansyah1997's full-sized avatar
🏠
Working from home

Irfan Andriansyah irfanandriansyah1997

🏠
Working from home
  • Indonesia
  • 02:55 (UTC +07:00)
View GitHub Profile
@irfanandriansyah1997
irfanandriansyah1997 / gist:659c0bea8e42dc5630163cfb9a82b88d
Last active March 30, 2020 12:30 — forked from EvanHahn/gist:2587465
Caesar shift in JavaScript
/*
JavaScript Caesar shift
by Evan Hahn (evanhahn.com)
* * * * * * * * * * * *
For small occasions (like month-anniversaries), I like to make little websites
for people that only "unlock" on the right day.
@irfanandriansyah1997
irfanandriansyah1997 / dev-server.js
Created March 28, 2020 13:41 — forked from jamsesso/dev-server.js
Webpack dev server with a better proxy (http-proxy-middleware)
var express = require('express');
var path = require('path');
var webpackConfig = require('./webpack.config');
var webpack = require('webpack');
var webpackDevMiddleware = require('webpack-dev-middleware');
var webpackHotMiddleware = require('webpack-hot-middleware');
var proxyMiddleware = require('http-proxy-middleware');
var devConfig = webpackConfig.devServer;
var app = express();
@irfanandriansyah1997
irfanandriansyah1997 / lazy-image.js
Created January 14, 2020 23:38 — forked from ianmcnally/lazy-image.js
Lazy image loading
//@flow
import React, { Component } from 'react'
import type { ElementRef } from 'react'
type Props = { src: string, alt: string }
type State = { source?: string }
export default class LazyImage extends Component<Props, State> {
state = {}
@irfanandriansyah1997
irfanandriansyah1997 / dependency-injection.py
Created June 11, 2019 13:58 — forked from blaix/dependency-injection.py
Dependency injection example in python
class MySqlDb(object):
def run(self, query):
# whatever...
# ----------------------------------------------------------------------
# Here, Foo can get bars, AND knows exactly what db implementation to use:
class Foo:
def __init__(self):
// Mixin like functionality
const textInput = props => `
color: ${props.error ? color.white : color.base};
background-color: ${props.error ? color.alert : color.white};
`;
export const Input = styled.input`
${textInput}
`;
@irfanandriansyah1997
irfanandriansyah1997 / C_v1.bnf
Last active April 28, 2019 04:39 — forked from arslancharyev31/C_v1.bnf
C .bnf grammar. Version 1.
{
tokens=[
space='regexp:\s+'
identifier='regexp:[a-zA-Z][a-zA-Z0-9_]*'
integer-constant='regexp:\d+'
character-constant='regexp:[a-zA-Z]'
floating-constant='regexp:[+-]?([0-9]*[.])?[0-9]+f'
enumeration-constant='regexp:[a-zA-Z][a-zA-Z0-9_]*' // Same as identifier
]
@irfanandriansyah1997
irfanandriansyah1997 / easing.js
Created February 18, 2019 02:44 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity
@irfanandriansyah1997
irfanandriansyah1997 / upstream.md
Created September 12, 2018 17:09 — forked from hackjutsu/upstream.md
[set upstream] What does '--set-upstream' do? #tags: git
git branch --set-upstream-to <remote-branch>
# example
git branch --set-upstream-to origin feature-branch

# show up which remote branch a local branch is tracking
git branch -vv

sets the default remote branch for the current local branch.

@irfanandriansyah1997
irfanandriansyah1997 / wget.sh
Created August 14, 2018 02:28 — forked from crittermike/wget.sh
Download an entire website with wget, along with assets.
wget \
--recursive \ # Download the whole site.
--no-clobber \ # Don't overwrite existing files.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
--restrict-file-names=windows \ # Modify filenames to work in Windows as well.
--domains yoursite.com \ # Do not follow links outside this domain.
--no-parent \ # Don't follow links outside the directory you pass in.
@irfanandriansyah1997
irfanandriansyah1997 / git_rebase.md
Created July 31, 2018 07:32 — forked from ravibhure/git_rebase.md
Git rebase from remote fork repo

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

git fetch upstream