- Getting started with React & Typescript
#!/usr/bin/env bash | |
i=1 | |
successes=0 | |
failures=0 | |
totalTests=10 | |
SUCCESS_CHECKMARK=$(printf '\342\234\224\n' | iconv -f UTF-8) | |
CROSS_MARK=$(printf '\342\235\214\n' | iconv -f UTF-8) | |
OUTPUT_FILE="jestOutput.txt" | |
until [ $i -gt $totalTests ]; do |
// EXAMPLE 1 | |
// Let's say you want to create a function that returns different types based on argument passed. Contrived example: | |
function returnNumberOrString(returnString: boolean) { | |
if (returnString) { | |
return "42" as string // cast to string to avoid literal type | |
} | |
return 42 as number // cast to number to avoid literal type | |
} |
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 |
import { Action } from 'redux'; | |
import { AsyncAction, AsyncFulfilledAction } from './redux-thunk-promise'; | |
import { ApiResult } from 'api/...'; | |
export const FETCH = '.../FETCH'; | |
export const FETCH_PENDING = '.../FETCH_PENDING'; | |
export const FETCH_FULFILLED = '.../FETCH_FULFILLED'; | |
export const FETCH_REJECTED = '.../FETCH_REJECTED'; | |
export type FetchAction = AsyncAction<typeof FETCH, ApiResult>; |
/* | |
* 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 😨 |
# Official framework image. Look for the different tagged releases at: | |
# https://hub.docker.com/r/library/node/tags/ | |
image: node:6 | |
before_script: | |
- npm install | |
# This folder is cached between builds | |
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache | |
cache: |
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
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.
- Download and install Git for Windows* with:
- [✘] Use Git from the Windows Command Prompt
- [✘] Checkout as-is, commit Unix-style line endings
A multi-level groupBy for arrays inspired by D3's nest operator.
Nesting allows elements in an array to be grouped into a hierarchical tree
structure; think of it like the GROUP BY
operator in SQL, except you can have
multiple levels of grouping, and the resulting output is a tree rather than a
flat table. The levels in the tree are specified by key functions.
See this fiddle for live demo.