Skip to content

Instantly share code, notes, and snippets.

@lilpolymath
lilpolymath / LRUCache.md
Created April 12, 2022 14:30
Implementing a given cache size behaving as an LRU cache with an expiry time and auto cache burst

Question

Implement Promise based memoization with a given cache size behaving as an LRU cache with an expiry time and auto cache burst.

Answer

First, what we have to do is breakdown the terms in the problem statement to understand what is going on and what we are asked to do.

  1. Promise based memoization: Memoization is one of the ways we can improve the performance of functions by eliminating redundant calls. Memoization is a technique where we store the results of a function call in a cache and return the result from the cache if the function is called again with the same arguments.
@hopearmstrong
hopearmstrong / Animation property.csv
Last active April 8, 2019 08:55
Animation property
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 2 columns, instead of 1. in line 7.
Value,Description
animation-name,This is the name of the keyframe you want to bind to the selector. Keep an eye on this one when you read the keyframes section below.
animation-duration,The length of animation in seconds or milliseconds. Note: Always specify the animation-duration property. Otherwise the duration is 0 and will never be played.
animation-timing-function,"The speed curve of the animation. Eg: linear, ease, ease-in, ease-out, ease-in-out, step-start, step-end, steps(int,start|end), cubic-bezier(n,n,n,n), initial, inherit"
animation-delay,"Defined in seconds (s) or milliseconds (ms), it’s the length of a delay before the animation will start. Note: If given a negative value, it will start playing as if it had been playing for a given amount of time."
animation-iteration-count,The number of times an animation should be played. Eg: any numerical number
animation-direction,"Play the animation in reverse or alternate cycles. Eg: normal, reverse, alternate, alternate-reverse, initial, inherit"
animati
@mykeels
mykeels / README.md
Last active February 19, 2018 09:06
Regex for Find & Replace in JavaScript Webpack Code Splitting

Regex for Find & Replace to convert

import MyComponent from './my-component'

to

const MyComponent = () => import(/* webpackChunkName: "chunk" */ './my-component')
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active May 19, 2024 13:30
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@mykeels
mykeels / HttpResponseCodes.cs
Last active March 17, 2017 08:30
Http Response Status Codes in JSON, JavaScript, CSharp, (feel free to add yours), etc.
public enum STATUS_CODES {
OK = 200,
CREATED = 201,
ACCEPTED = 202,
NON_AUTHORITATIVE_INFORMATION = 203,
NO_CONTENT = 204,
RESET_CONTENT = 205,
PARTIAL_CONTENT = 206,
MULTIPLE_CHOICE = 300,
MOVED_PERMANENTLY = 301,
@fathermerry
fathermerry / nibss.json
Created January 9, 2017 23:25
NIBSS Data Formatted
{
"active_accounts": [
{
"date": "2015-01-01T08:00:00Z",
"number": 47200000
},
{
"date": "2015-02-01T08:00:00Z",
"number": 47930000
},
@mixin for-phone-only {
@media (max-width: 599px) { @content; }
}
@mixin for-tablet-portrait-up {
@media (min-width: 600px) { @content; }
}
@mixin for-tablet-landscape-up {
@media (min-width: 900px) { @content; }
}
@mixin for-desktop-up {
@levibostian
levibostian / post.md
Last active April 15, 2020 20:31
webpack, Tachyons, pug, Vue.js web app.

Today, single page web apps are driving many websites that we use each and every day. Instead of having your browser request a new web page for each and every action you perform on a web page, single page web apps may load all in one request to smoothly and quickly transition with every action you perform.

When building single page web apps, you may decide to retrieve all of the HTML, CSS and Javascript with one single page load or dynamically load these resources as the user moves about your site. Either way, it can be a pain to bundle all of these assets together for the end user to download from your web server. This is where webpack comes into play.

webpack does all of the heavy lifting bundling all of your HTML, CSS and Javascript together. If you write your site all from scratch or depend on dependencies from npm, webpack takes care of packaging it all together for you. It has the ability to take your single page web app, cut out all of the code you don't need, then packa

#Here are the resources I have made for people:
##Overview
[A Comparison of Web Animation Technologies](https://css-tricks.com/comparison-animation-technologies/)
##For Designers
[Practical Techniques for Designing Animations](http://www.smashingmagazine.com/2015/06/08/practical-techniques-on-designing-animation/)
[High Performance SVGs](https://css-tricks.com/high-performance-svgs/)
[Designing Complex SVG Animations](http://slides.com/sdrasner/cssdevconf#/)
@acdlite
acdlite / app.js
Last active January 20, 2023 08:23
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {