Skip to content

Instantly share code, notes, and snippets.

View Arthelon's full-sized avatar
🐈
xmas vibes

Arthelon Arthelon

🐈
xmas vibes
View GitHub Profile
@iwasaki-kenta
iwasaki-kenta / channel.ts
Last active August 25, 2021 03:32
Go-like channels in TypeScript.
export class Deferred<T> {
promise: Promise<T>;
resolve: (value?: T | PromiseLike<T>) => void;
reject: (reason?: any) => void;
constructor() {
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
@MarcoWorms
MarcoWorms / mini-redux.js
Last active August 7, 2023 19:06
Redux in a nutshell
function createStore (reducers) {
var state = reducers()
const store = {
dispatch: (action) => {
state = reducers(state, action)
},
getState: () => {
return state
}
}
@alekseykulikov
alekseykulikov / index.md
Last active April 14, 2024 00:32
Principles we use to write CSS for modern browsers

Recently CSS has got a lot of negativity. But I would like to defend it and show, that with good naming convention CSS works pretty well.

My 3 developers team has just developed React.js application with 7668 lines of CSS (and just 2 !important). During one year of development we had 0 issues with CSS. No refactoring typos, no style leaks, no performance problems, possibly, it is the most stable part of our application.

Here are main principles we use to write CSS for modern (IE11+) browsers:

@hiway
hiway / pybble.py
Last active June 29, 2023 23:46
Python on Pebble. Yes. It works, with a bit of space to write a decent app and some heap memory to spare. AJAX works, as shown in code.
"""
pybble.py
Yup, you can run Python on your Pebble too! Go thank the good folks who
made Transcrypt, a dead-simple way to take your Python code and translate
it to *very* lean Javascript. In our case, instead of browser, we run it
on Pebble using their equally dead-simple Online IDE and Pebble.js library.
Here's a working example, it runs on a real Pebble Classic.
@subfuzion
subfuzion / mongoose-cheatsheet.md
Created February 26, 2014 19:03
mongoose cheatsheet

Definitely not comprehensive. This is meant to be a basic memory aid with links to get more details. I'll add to it over time.

Install

$ npm install mongoose --save

Connect

const mongoose = require('mongoose');
@ZacSweers
ZacSweers / crashcourse.md
Last active July 10, 2022 02:14
Python Reddit bot on Heroku

A crash course in setting up your Python Reddit bot on Heroku

You'll need to do the following:

  • You need to make your bot a python app. Do this by making another directory (can be the same name as the regular one) and put all your python code in that, and make an empty file called __init__.py in it as well. See how I structured mine if this isn't clear. In your base directory, create two files: "requirements.txt" and "runtime.txt". The requirements.txt file should be the output of pip freeze (you can run the command "pip freeze > requirements.txt"). If you're not using virtualenv, you'll need to go through after and delete all the lines with packages your code doesn't actually use. Check out mine to see what I mean. Runtime.txt just specifies with python version for heroku to use. Mine just has the line "python-2.7.4" in it. All of this will tell heroku to recognize your bot as a python app.

  • Make a heroku account and