Skip to content

Instantly share code, notes, and snippets.

@elierotenberg
elierotenberg / BLOG.md
Last active August 16, 2023 12:01
Idiomatic Data Fetching using React Hooks

Idiomatic Data Fetching using React Hooks

This post has been written in collaboration with @klervicn

Virtually all web apps and websites need to pull data from a server, usually through a JSON-returning API. When it comes to integrating data fetching in React component, the "impedence mismatch" between the React components, which are declarative and synchronous, and the HTTP requests, which are imperative and asynchronous, is often problematic.

Many apps use third-party libraries such as Redux or Apollo Client to abstract it away. This requires extra dependencies, and couple your app with a specific library to perform data fetching. In most cases, what we want is a direct way to integrate plain HTTP requests (e.g. using native fetch) for usage in React components.

Here we will discuss how we can use React Hooks to do this in an elegant, scalable manner.

@kod3r
kod3r / webS
Created October 6, 2019 01:44 — forked from zacjszewczyk/webS
A syllable dictionary I built with Python. See https://zacs.site/blog/building-a-syllable-dictionary-with-python.html for the full writeup.
This file has been truncated, but you can view the full file.
# A syllable dictionary I built with Python. See https://zacs.site/blog/building-a-syllable-dictionary-with-python.html for the full writeup.
#
# This work is licensed under a Creative Commons Attribution 4.0 International License
# See https://zacs.site/disclaimers.html for more information.
# © 2012-2019 Zachary Szewczyk.
a,1
a,1
aa,1
@zacjszewczyk
zacjszewczyk / webS
Created October 4, 2019 23:15
A syllable dictionary I built with Python. See https://zacs.site/blog/building-a-syllable-dictionary-with-python.html for the full writeup.
This file has been truncated, but you can view the full file.
# A syllable dictionary I built with Python. See https://zacs.site/blog/building-a-syllable-dictionary-with-python.html for the full writeup.
#
# This work is licensed under a Creative Commons Attribution 4.0 International License
# See https://zacs.site/disclaimers.html for more information.
# © 2012-2019 Zachary Szewczyk.
a,1
a,1
aa,1
javascript:!function(){var e,t,n;try{var o=document.querySelectorAll("div[data-name='Active Items'] div[data-asin]"),r=[["ProductID","Price","Quantity","Description","Link"].join(",")];o.forEach(function(e){var t=e.getAttribute("data-price"),n=e.getAttribute("data-quantity"),o=e.getAttribute("data-asin"),c=e.querySelector(".sc-product-link").href,a='"'+e.querySelector(".sc-product-title").textContent.replace(/"/g,'""').trim()+'"';r.push([o,t,n,a,c].join(","))}),e=r.join("\n"),t=document.createElement("textarea"),n=document.getSelection(),t.textContent=e,document.body.appendChild(t),n.removeAllRanges(),t.select(),document.execCommand("copy"),n.removeAllRanges(),document.body.removeChild(t)}catch(e){return void alert("Copy failed: "+e)}alert("Copy Successful, csv in in your clipboard")}();
@nadavrot
nadavrot / Matrix.md
Last active April 2, 2024 06:45
Efficient matrix multiplication

High-Performance Matrix Multiplication

This is a short post that explains how to write a high-performance matrix multiplication program on modern processors. In this tutorial I will use a single core of the Skylake-client CPU with AVX2, but the principles in this post also apply to other processors with different instruction sets (such as AVX512).

Intro

Matrix multiplication is a mathematical operation that defines the product of

@adambene
adambene / merge-two-arrays.js
Last active March 7, 2018 19:27
Merge two arrays in JavaScript
// merge two arrays a and b
const merge = (a, b) => a.reduce(
(acc, curr, i) => [
...acc, // copy all previous elements
curr, // current element of a
b[i] // current element of b
],
[] // initial value
);
@fosterdill
fosterdill / optimize_images.sh
Last active October 17, 2017 16:57
Find png files that don't have transparency and convert to jpg, also recompress all jpg files for the web
#!/bin/sh
echo You should have the project tracked by version control in case something goes wrong.
printf 'Press any key to continue...'
read -r
path=${1:-.}
echo Optimizing images in "$path"
if [ -z "$(command -v jpeg-recompress)" ] || [ -z "$(command -v ladon)" ] || [ -z "$(command -v mogrify)" ]; then
@giacomoran
giacomoran / dlib_opencv_android.md
Last active January 22, 2020 18:01
How to create an Android Studio project with OpenCV and dlib.
@matcap
matcap / KillerDaemon.cpp
Created May 30, 2017 13:25
A simple process killer for Windows.
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <chrono>
#include <iomanip>
#include <map>
#include <Windows.h>
#include <TlHelp32.h>
using namespace std;
@aparrish
aparrish / understanding-word-vectors.ipynb
Last active April 12, 2024 09:39
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.