Skip to content

Instantly share code, notes, and snippets.

View apieceofbart's full-sized avatar

Bartek apieceofbart

View GitHub Profile
@apieceofbart
apieceofbart / react-base-table.d.ts
Created July 20, 2020 19:15 — forked from pocesar/react-base-table.d.ts
react base table typescript typings
declare module 'react-base-table' {
import React from 'react'
export interface ColumnProps<T> {
key: string
className?: string | ((obj: CallbackObject<T>) => string)
/** Class name for the column header, could be a callback to return the class name The callback is of the shape of ({ columns, column, columnIndex, headerIndex }) => string */
headerClassName?: string | ((obj: CallbackObject<T>) => string)
/** Custom style for the column cell, including the header cells */
style?: React.CSSProperties
@apieceofbart
apieceofbart / sessions.md
Created June 8, 2020 13:30 — forked from joepie91/sessions.md
Introduction to sessions

While a lot of Node.js guides recommend using JWT as an alternative to session cookies (sometimes even mistakenly calling it "more secure than cookies"), this is a terrible idea. JWTs are absolutely not a secure way to deal with user authentication/sessions, and this article goes into more detail about that.

Secure user authentication requires the use of session cookies.

Cookies are small key/value pairs that are usually sent by a server, and stored on the client (often a browser). The client then sends this key/value pair back with every request, in a HTTP header. This way, unique clients can be identified between requests, and client-side settings can be stored and used by the server.

Session cookies are cookies containing a unique session ID that is generated by the server. This session ID is used by the server to identify the client whenever it makes a request, and to associate session data with that request.

*S

@apieceofbart
apieceofbart / prepare-commit-msg.sh
Created November 5, 2019 11:40 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with a branch name
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
@apieceofbart
apieceofbart / axios-catch-error.js
Created September 17, 2019 13:23 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@apieceofbart
apieceofbart / example.action-types.ts
Created September 9, 2019 14:04 — forked from Vovan-VE/example.action-types.ts
TypeScript: redux-thunk & redux-promise-middleware together
import { AsyncAction, AsyncFulfilledAction } from '.../redux-thunk-promise';
export const FETCH = '.../FETCH';
export const FETCH_PENDING = '.../FETCH_PENDING';
export const FETCH_FULFILLED = '.../FETCH_FULFILLED';
export const FETCH_REJECTED = '.../FETCH_REJECTED';
export interface FetchAction extends AsyncAction<ApiResult> {
type: typeof FETCH;
}
@apieceofbart
apieceofbart / remove-node-modules.md
Last active July 4, 2024 16:06 — forked from lmcneel/remove-node-modules.md
How to remove node_modules after they have been added to a repo

How to remove node_modules

  1. Create a .gitignore file in the git repository if it does not contain one

  2. Open up the .gitignore and add the following line to the file

node_modules

  1. Remove the node_modules folder from the git repository
@apieceofbart
apieceofbart / async-component.spec.js
Created December 15, 2017 12:32 — forked from mrparkers/async-component.spec.js
Unit testing an async React component using Mocha, Chai, and Enzyme
import AsyncComponent from './path/to/component';
import request from 'your-request-library';
import React from 'react';
import {shallow} from 'enzyme';
import Chance from 'chance';
import chai, {expect} from 'chai';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
@apieceofbart
apieceofbart / es7-async-await.js
Created June 23, 2017 09:28 — forked from msmfsd/es7-async-await.js
Javascript fetch JSON with ES7 Async Await
// Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch
// async function
async function fetchAsync () {
// await response of fetch call
let response = await fetch('https://api.github.com');
// only proceed once promise is resolved
let data = await response.json();
// only proceed once second promise is resolved
@apieceofbart
apieceofbart / typescript-react-quickstart.md
Created June 10, 2017 15:15 — forked from benedyktdryl/typescript-react-quickstart.md
Quick notes for people starting with React & Typescript
@apieceofbart
apieceofbart / -README.md
Created April 22, 2017 10:19 — forked from jirutka/-README.md
How to use terminal on Windows and don’t go crazy…

How to use terminal on Windows without going crazy…

Windows is really horrible system for developers and especially for devops. It doesn’t even have a usable terminal and shell, so working with command line is really pain in the ass. If you really don’t want to switch to any usable system (OS X, Linux, BSD…), then this guide should help you to setup somewhat reasonable environment – usable terminal, proper shell, ssh client, git and Sublime Text as a default editor for shell.

Install stuff

  1. Download and install Git for Windows* with:
    • [✘] Use Git from the Windows Command Prompt
  • [✘] Checkout as-is, commit Unix-style line endings