Skip to content

Instantly share code, notes, and snippets.

View waliurjs's full-sized avatar

Waliur Rahman waliurjs

View GitHub Profile
@waliurjs
waliurjs / gist:d04760f957efe2445790386ba9d3885c
Last active November 8, 2022 08:41
How to change local commit message (not yet pushed)
`git rebase -i HEAD~3` (here 3 means just bring up last 3 commits. Can be any number.)
Find the commit that you are interested in.
Press `i` to activate INSERT MODE in the editor.
Move the cursor to the begining of the commit you are interested in.
Change the first word from "pick" to r. (r for reword)
Ex:
pick 68dab9a7 chore(button): Datepicker fix
to
r 68dab9a7 chore(button): Datepicker fix
@waliurjs
waliurjs / how to update jest snapshots.txt
Last active June 6, 2022 09:40
Jest snapshot update using interactive mode
## Update uncommitted changed testcases only: (replace 'jest' with 'yarn test' where applicable)
) jest --watch
) Press w when you have failing testcases
## update specific test file
) jest -u ./__tests__/link.test.js (include parent folders when running from inside of a 'workspace'. Same slash for Windows too.)
OR,
) jest --updateSnapshot ./__tests__/link.test.js
## Pick & choose failing testcases and update snapshots
@waliurjs
waliurjs / TabBar.js
Created September 9, 2019 08:30
React Navigation Custom tabBarComponent
import React from 'react';
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
import { MaterialIcons } from '@expo/vector-icons';
import styleConst from './../constants/Style';
export default class extends React.Component {
constructor(props) {
super(props);
}
@waliurjs
waliurjs / responsive-image.html
Created February 4, 2019 07:53
Responsive image example
<picture>
<source media="(min-width: [browser_width]px)" srcset="/home/google-play-badge-lg.png">
<source media="(min-width: [browser_width]px)" srcset="/home/google-play-badge-md.png">
<img class="playstore-link" src="/home/google-play-badge-xs.png">
</picture>
const defaultReducer = Reducer(Actions);
const reducerCreate = () => {
return (state, action) => {
// console.log('reducer: ACTION:', action);
return defaultReducer(state, action);
};
};
export const RootNavigator = () => {
@waliurjs
waliurjs / components-shrink.js
Last active September 23, 2017 05:46
Rerendering little bitch
export default class extends React.Component {
constructor(props){
super(props);
}
componentDidMount(){
console.log('They... mounted me. :( ');
}
render (){
// Redux-Saga
import axios from 'axios'
function* watchSaga(){
yield takeEvery('fetch_user', fetchUser) // waiting for action (fetch_user)
}
function* fetchUser(action){
try {
@waliurjs
waliurjs / objects-delegation-mutation.js
Created January 31, 2017 11:17 — forked from gor181/objects-delegation-mutation.js
Delegation, object mutation and how to avoid it. Javascript.
//Some of the examples use spread syntax available via Babel in ES7 proposal.
//Live at: https://jsbin.com/zawavekepo/edit?js,console
//Arrays, slicing and avoiding mutations
const numArray = [10, 20, 30, 40, 50, 60];
const removeAtIndex = (arr, x) => {
return [
...arr.slice(0, x),
...arr.slice(x + 1)
];
@waliurjs
waliurjs / Header.js
Last active October 27, 2016 10:49
icomoon webpack problem
import React, { Component } from 'react';
// import { IndexLink } from 'react-router';
import { LinkContainer } from 'react-router-bootstrap';
import classNames from 'classnames';
export default class Header extends Component {
render() {
const logo2x = require('../../../static/logo/projectname@2x.png');
const css = require('./Header.scss');

TodoMVC React