Skip to content

Instantly share code, notes, and snippets.

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);
@oguzgelal
oguzgelal / index.js
Created July 13, 2021 19:54
Code used to analyse StateOfJS2020 data
const participants = require("./data.json");
const isAware = (experience) => experience !== "never_heard";
const isInterested = (experience) =>
experience === "interested" || experience === "would_use";
const numParticipantsMoreThan = (dictNumTechToNumParticipants, num) => Object
.keys(dictNumTechToNumParticipants)
.filter(n => n > num)
.reduce((acc, n) => acc + dictNumTechToNumParticipants[n], 0)
/*
* 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;
/*
# 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 ->
{
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'),
},
{
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[]
}
submitted() {
broadcast('login_submitted', {
email: this.state.email,
password: this.state.password
})
}
<form onSubmit={this.submitted}>
...
{ this.props.loading.login && <div>Loading...</div> }
{
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',
[
{ "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" }
]
void setup() {
size(500, 500);
}
void draw() {
if (mousePressed) {
// Codes here will be executed as long as the mouse
// button is pressed