Skip to content

Instantly share code, notes, and snippets.

@oguzgelal
oguzgelal / toptal-p5-sample1.java
Last active November 14, 2015 13:12
Processing code when converted into Java
public class ExampleFrame extends Frame {
public ExampleFrame() {
super("Embedded PApplet");
setLayout(new BorderLayout());
PApplet embed = new Embedded();
add(embed, BorderLayout.CENTER);
embed.init();
@oguzgelal
oguzgelal / toptal-p5-sample1.pde
Last active November 14, 2015 13:12
Simple Processing code block
public void setup() {
// setup codes goes here
}
public void draw() {
// draw codes goes here
}
public void setup() {
// Size of our sketch will be 800x600,
// and use the P2D rendering engine.
size(800, 600, P2D);
// We could have used this function instead of size()
// fullScreen(P2D);
// The background color of our sketch will be black
// by default, unless specified otherwise
int x = 0;
void setup(){
}
void draw(){
x += 1;
print(x+" ");
}
void setup(){
}
void draw(){
int x = 0;
x += 1;
print(x+" ");
}
// 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(){
void setup() {
size(500, 500);
}
void draw() {
if (mousePressed) {
// Codes here will be executed as long as the mouse
// button is pressed
[
{ "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" }
]
{
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',
submitted() {
broadcast('login_submitted', {
email: this.state.email,
password: this.state.password
})
}
<form onSubmit={this.submitted}>
...
{ this.props.loading.login && <div>Loading...</div> }