Skip to content

Instantly share code, notes, and snippets.

Avatar

Zev Averbach zevaverbach

View GitHub Profile
@mystal
mystal / odds.rs
Created Dec 22, 2021
Print odd number arguments
View odds.rs
use std::env;
fn main() {
let odds: Vec<_> = env::args()
.skip(1)
.map(|s| s.parse::<i32>().unwrap())
.filter(|&n| n % 2 != 0)
.collect();
println!("odd numbers: {:?}", odds);
}
View serverless.yaml
service: my-service
provider:
name: aws
region: ${opt:region, 'eu-west-1'}
stage: ${opt:stage, 'development'}
plugins:
- serverless-s3-sync
@Jack-Works
Jack-Works / 2018.js
Last active Jan 22, 2023
cRAzY eSnEXt (*all* proposals mixed in)
View 2018.js
#! Aaaaaaaaaaa this is JS!!!
// https://github.com/tc39/proposal-hashbang
// This file is mixing all new syntaxes in the proposal in one file without considering syntax conflict or correct runtime semantics
// Enjoy!!!
// Created at Nov 23, 2018
for await(const x of (new A // https://github.com/tc39/proposal-pipeline-operator
|> do { // https://github.com/tc39/proposal-do-expressions
case(?) { // https://github.com/tc39/proposal-pattern-matching
when {val}: class {
@Rich-Harris
Rich-Harris / http-apis.md
Last active Nov 3, 2022
Next-gen Node HTTP APIs
View http-apis.md

I saw this poll on Twitter earlier and was surprised at the result, which at the time of writing overwhelmingly favours option 1:

Screen Shot 2020-09-10 at 10 19 22 AM

I've always been of the opinion that the (req, res, next) => {} API is the worst of all possible worlds, so one of two things is happening:

  • I'm an idiot with bad opinions (very possibly!)
  • People like familiarity
View flask-server-svelte.py
from flask import Flask, send_from_directory
import random
app = Flask(__name__)
# Path for our main Svelte page
@app.route("/")
def base():
return send_from_directory('client/public', 'index.html')
@jnothman
jnothman / fromisoformat.py
Created May 30, 2019
datetime.fromisoformat backported from Python 3.7
View fromisoformat.py
"""datetime.fromisoformat backported from Python 3.7
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
--------------------------------------------
1. This LICENSE AGREEMENT is between the Python Software Foundation
("PSF"), and the Individual or Organization ("Licensee") accessing and
otherwise using this software ("Python") in source or binary form and
its associated documentation.
@Rich-Harris
Rich-Harris / README.md
Last active Dec 20, 2019
Source bytes: React vs Ember Octane vs Svelte
View README.md

I'm procrastinating instead of working on a conference talk, so I decided to implement this component in Svelte to see which framework is most expressive:

Screen Shot 2019-03-30 at 16 42 16

Ember Octane

Here's the original, with the addition of an import for dataUriAsSrc (and updated per @chriskrycho's comment):

<img
View requestMultiplexer.js
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request));
});
/**
* Multiplex requests to a fixed list of destinations.
*
* It is intentional that we only support rewriting the incoming request URL to
* that of the destination. Everything else on the request is untouched.
*
@virolea
virolea / upload.js
Last active Jan 17, 2023
Tracking file upload progress using axios
View upload.js
upload(files) {
const config = {
onUploadProgress: function(progressEvent) {
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
console.log(percentCompleted)
}
}
let data = new FormData()
data.append('file', files[0])
@scarpent
scarpent / better-twitter
Last active Sep 13, 2021
Better Twitter: Greasemonkey/Tampermonkey script to hide stuff you don't want to see
View better-twitter
// ==UserScript==
// @name Better Twitter
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Remove unwanted stuff (promoted, other people's likes, ...)
// @author Scott Carpenter
// @match https://twitter.com/
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://gist.githubusercontent.com/scarpent/ba8e369f1187fa990b98d1f58b2c013d/raw/9c97aa67ff9c5d56be34a55ad6c18a314e5eb548/waitForKeyElements.js
// @grant none