Skip to content

Instantly share code, notes, and snippets.

@nikbabchenko
nikbabchenko / mapdispatch-to-props.js
Created March 31, 2019 13:22
MapDispatchToProps
/**
*
* bindActionCreators approach
*
**/
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators(courseActions, dispatch)
}
@nikbabchenko
nikbabchenko / config.js
Created June 13, 2019 15:35
GlobalStyles for Stencil.js
{
globalStyle: './src/global/default.scss',
plugins: [
sass({
includePaths: ['./node_modules'],
injectGlobalPaths: ['./src/global/_variables.scss'],
}),
],
}
@nikbabchenko
nikbabchenko / reducer.js
Created June 18, 2019 07:02
Create reducer
export const createReducer = (initialState, handlers)=>{
return function reducer(state = initialState, action) {
if (handlers.hasOwnProperty(action.type)) {
return handlers[action.type](state, action)
} else {
return state
}
}
};

A complete list of books, articles, blog posts, videos and neat pages that support Data Fundamentals (H), organised by Unit.

Formatting

If the resource is available online (legally) I have included a link to it. Each entry has symbols following it.

  • ⨕⨕⨕ indicates difficulty/depth, from ⨕ (easy to pick up intro, no background required) through ⨕⨕⨕⨕⨕ (graduate level textbook, maths heavy, expect equations)
  • ⭐ indicates a particularly recommended resource; 🌟 is a very strongly recommended resource and you should look at it.
@nikbabchenko
nikbabchenko / makeActionCreator.js
Created June 18, 2019 07:04
MakeActionCreator
export const makeActionCreator = (type, ...argNames) => {
return function(...args) {
let action = { type };
argNames.forEach((arg, index) => {
action[argNames[index]] = args[index];
});
return action
}
};
export function getRandomString() {
return Math.random()
.toString(36)
.substring(2);
}
@nikbabchenko
nikbabchenko / bash.sh
Created August 9, 2019 07:16
Remove node modules
Mac / Linux:
$ cd documents
$ find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
@nikbabchenko
nikbabchenko / kill-process-mac.sh
Created August 29, 2019 10:39
Kill Process Mac
Run:
lsof -i :3000 (where 3000 is your current port in use)
then check status of the reported PID :
ps ax | grep <PID>
finally, "begone with it":
kill -QUIT <PID>
@josemmo
josemmo / repair-mysql-data.ps1
Created August 28, 2020 18:48
Repair MySQL data directory (for XAMPP)
# Based on this answer: https://stackoverflow.com/a/61859561/1956278
# Backup old data
Rename-Item -Path "./data" -NewName "./data_old"
# Create new data directory
Copy-Item -Path "./backup" -Destination "./data" -Recurse
Remove-Item "./data/test" -Recurse
$dbPaths = Get-ChildItem -Path "./data_old" -Exclude ('mysql', 'performance_schema', 'phpmyadmin') -Recurse -Directory
Copy-Item -Path $dbPaths.FullName -Destination "./data" -Recurse
@nikbabchenko
nikbabchenko / socket.js
Created August 31, 2019 12:42
Socket.io
socket.emit('message', "this is a test"); //sending to sender-client only
socket.broadcast.emit('message', "this is a test"); //sending to all clients except sender
socket.broadcast.to('game').emit('message', 'nice game'); //sending to all clients in 'game' room(channel) except sender
socket.to('game').emit('message', 'enjoy the game'); //sending to sender client, only if they are in 'game' room(channel)
socket.broadcast.to(socketid).emit('message', 'for your eyes only'); //sending to individual socketid
io.emit('message', "this is a test"); //sending to all clients, include sender
io.in('game').emit('message', 'cool game'); //sending to all clients in 'game' room(channel), include sender
io.of('myNamespace').emit('message', 'gg'); //sending to all clients in namespace 'myNamespace', include sender
socket.emit(); //send to all connected clients
socket.broadcast.emit(); //send to all connected clients except the one that sent the message