Skip to content

Instantly share code, notes, and snippets.

View init.coffee
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
View declaration.js
{
on: ..., // string or string[]
when: ..., // function or function[] or any
reducer: ..., // function or function[]
reducerElse: ..., // function or function[]
reaction: ..., // function or function[]
reactionElse: ..., // function or function[]
}
View login.duck.js
{
on: 'login_submitted',
when: ({ event }) => isValid(event.email, event.password),
reaction: ({ event }) => broadcast('on_request', {
type: 'login',
path: '/api/login',
params: { ...event }
}),
reactionElse: () => alert('Invalid parameters'),
},
View request.duck.js
{
on: 'on_request',
reducer: ({ state, event }) => ({ ...state, loading: { [event.type]: true } }),
reaction: ({ event }) => api(event.path, event.params)
.then(res) => broadcast('request_success', res)
.catch(err) => broadcast('request_fail', err)
.finally() => broadcast('request_resolved', event)
},
{
on: 'request_resolved',
View login.js
submitted() {
broadcast('login_submitted', {
email: this.state.email,
password: this.state.password
})
}
<form onSubmit={this.submitted}>
...
{ this.props.loading.login && <div>Loading...</div> }
View Default%20%28OSX%29.sublime-keymap
[
{ "keys": ["super+t"], "command": "reindent", "args": {"single_line": false}},
{ "keys": ["tab"], "command": "expand_abbreviation_by_tab", "context":
[
{ "operand": "source.js", "operator": "equal", "match_all": true, "key": "selector" },
{ "match_all": true, "key": "selection_empty" },
{ "operator": "equal", "operand": false, "match_all": true, "key": "has_next_field" },
{ "operand": false, "operator": "equal", "match_all": true, "key": "auto_complete_visible" },
{ "match_all": true, "key": "is_abbreviation" }
]
View toptal-p5-example.pde
int rectWidth = 100;
int rectHeight = 40;
float rectR, rectG, rectB;
float rectSpeedX, rectSpeedY;
float rectX, rectY;
void setup() {
size(500, 500);
changeColor();
rectSpeedX = random(1, 10);
View toptal-p5-interactions.pde
void setup() {
size(500, 500);
}
void draw() {
if (mousePressed) {
// Codes here will be executed as long as the mouse
// button is pressed
View toptal-p5-example.pde
/*
* We define coordinate variables first. We define them
* here because we want them to be global.
*/
int x1, y1;
int x2, y2;
int x3, y3;
int x4, y4;
/*
View toptal-p5-animate1.pde
// initialize x and y as 0
int x=0;
int y=0;
void setup(){
size(800,600);
background(255); // set background color to white
}
void draw(){