Skip to content

Instantly share code, notes, and snippets.

function moveFieldsBetweenStructures({
sourceStructureId,
targetStructureId,
fieldIds
}) {
return (dispatch, getState) => {
const state = getState();
const fieldsToMove = selectStructureFieldsByIds(
sourceStructureId,

Search

// Find last instance on line of , .,+5s/,\(.*,\)\@!.*/)/

List Files

grep -E -l "(componentWillReceiveProps|componentWillMount|componentWillUpdate)" app/webapp/node_modules/**/*.js | wc -l

Show matches in color

grep -E --color "(componentWillReceiveProps|componentWillMount|componentWillUpdate)" app/webapp/node_modules/**/*.js

Clear all files with a certain match

truncate -s 0 $(grep -l "husky" ./*)

Useful Commands

Insert Text on line above found match

find app/webapp/src/js -type f -name "*.js" -prin
t0 | xargs -0 sed -i '' -e '/UNSAFE/i\
// eslint-disable-next-line camelcase'
@altaudio
altaudio / todos.js
Last active December 28, 2018 14:30
import React, { Component } from 'react'
import { Subscribe } from 'unstated'
import TodosContainer from '../../containers/todos'
class Todos extends Component {
constructor() {
super()
this.state = { newTodo: '' }
}
import { Container } from 'unstated'
class TodosContainer extends Container {
state = {
todos: []
}
addTodo(todo) {
this.setState({ todos: [ ...this.state.todos, todo ] })
}
@altaudio
altaudio / todos.js
Last active December 28, 2018 14:31
import React, { Component } from 'react'
class Todos extends Component {
constructor() {
super()
this.state = { newTodo: '' }
}
addTodoAndClearNewTodo() {
0x62F557F5A81879185A972DCFDfC9E61f5Ab03212
@altaudio
altaudio / newsBot.js
Created May 4, 2017 13:26
Send Hacker News Posts
bot.on('message', (payload, reply) => {
const message = payload.message.text
const senderId = payload.sender.id
const apiUrl = 'https://newsapi.org/v1/articles?source=hacker-news&sortBy=top&apiKey=52a36d98da214f98a9b9b9bfaba502a7'
if (message === 'news' || message === 'News') {
request
.get(apiUrl)
.end((error, result) => {
const articles = result.body.articles
@altaudio
altaudio / getStarted.js
Created May 4, 2017 13:25
Get Started Postback Handler
const users = {}
bot.on(‘postback’, (payload) => {
if (payload.postback.payload === ‘GET_STARTED_PAYLOAD’) {
const senderId = payload.sender.id
bot.getProfile(senderId, (error, profile) => {
if (error) {
console.log(error)
}