Skip to content

Instantly share code, notes, and snippets.

View kulakowka's full-sized avatar

Anton Kulakov kulakowka

  • Tbilisi, Georgia
View GitHub Profile
@kulakowka
kulakowka / Service-Objects-in-JavaScript.js
Last active February 6, 2017 08:41
Service Objects in JavaScript.js
import WelcomeEmailMailer from './WelcomeEmailMailer'
import SlackNotifier from './SlackNotifier'
class NewRegistrationService {
initialize (params) {
this.user = params.user // Mongooose model: User
this.organization = params.organization // Mongooose model: Organisation
}
perform () {
return this.organizationCreate()
{
"name": "react-apollo-starter-kit",
"private": true,
"description": "Scaphold.io's Starter Kit React and Apollo",
"repository": "scaphold-io/react-apollo-starter-kit",
"version": "0.1.0",
"scripts": {
"start": "babel-node ./src/server.js",
"start-prod": "node ./lib/server.js",
"build": "cp src/index.html lib/ && babel src --out-dir lib --sourceRoot src",
export const setEntities = (entityType, entities) => ({
type: 'SET_ENTITIES',
payload: { entities },
meta: { entityType }
})
export const removeEntities = (entityType, ids) => ({
type: 'REMOVE_ENTITIES',
meta: { ids, entityType }
})
export const setEntity = (entityType, entity) => ({
@kulakowka
kulakowka / maxRetries.js
Created July 3, 2017 08:06
make N retries to API call before catch error
// demo
var _requestsCount = 6
const fetchF = url => {
// _requestsCount--
console.log('fake request %d', _requestsCount)
if (_requestsCount--) return Promise.reject(new Error('ololo'))
return Promise.resolve('data')
}
@kulakowka
kulakowka / RegExp.js
Last active July 3, 2017 08:08
Magic by @n4kz
'AAAABBHHJOPPPP'
.replace(/(\w)\1+/g, (match) => match[0] + (match.length));
// => "A4B2H2JOP4"
// This is an example of how to fetch external data in response to updated props,
// If you are using an async mechanism that does not support cancellation (e.g. a Promise).
class ExampleComponent extends React.Component {
_currentId = null;
state = {
externalData: null
};

Automatically Prepend a Jira Issue ID to Git Commit Messages

Use a git hook to match a Jira issue ID from the current branch, and prepend it to every commit message

Assuming the current branch contains a Jira issue ID, you can use a git hook script to prepend it to every commit message.

  1. Create an empty commit-msg git hook file, and make it executable. From your project's root directory:

     install -b -m 755 /dev/null .git/hooks/commit-msg
    
  2. Save the following script to the newly-created .git/hooks/commit-msg file:

{
"Ansi 5 Color" : {
"Red Component" : 0.98751437664031982,
"Color Space" : "Calibrated",
"Blue Component" : 0.70531737804412842,
"Alpha Component" : 1,
"Green Component" : 0.29879066348075867
},
"Tags" : [
@kulakowka
kulakowka / devtools.js
Created August 13, 2018 00:33
react debug component
var devtools = /./;
devtools.toString = function() {
this.opened = true;
};
console.log("%c", devtools);
// devtools.opened will become true if/when the console is opened
export default props => {
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "cmd+0",
"command": "workbench.action.openLastEditorInGroup"
},
{
"key": "cmd+1",
"command": "workbench.action.openEditorAtIndex1"
},