Skip to content

Instantly share code, notes, and snippets.

@eYinka
eYinka / tailwind-radial-progress-bar.txt
Last active November 7, 2024 08:54
Tailwind CSS Radial Progress Bar
// Inspired by Tailwind Daisy UI progress bar: https://daisyui.com/components/radial-progress/
// This is a custom-made progress circular/radial progress bar with centered percentage text.
// Tested with Tailwind 3.x. Should work with lower versions of Tailwind CSS as well.
STEP 1: Add the following custom CSS:
.progress-ring__circle {
transition: stroke-dashoffset 0.35s;
transform: rotate(-90deg);
transform-origin: 50% 50%;
@limistah
limistah / App.js
Last active September 5, 2021 16:39
ReactJS InplaceEdit component and consumption
import InplaceEdit from "./InplaceEdit"
class App extends React.Component {
render() {
return (
<InplaceEdit
isUpdatingId={true || false}
id={idForTheField || ""}
updateKey={keyToReturnAnObjectWith || ""}
onUpdate={functionToCallForTheUpdate || (() => {})}
@bradtraversy
bradtraversy / eslint_prettier_airbnb.md
Created July 19, 2019 17:54
ESLint, Prettier & Airbnb Setup

VSCode - ESLint, Prettier & Airbnb Setup

1. Install ESLint & Prettier extensions for VSCode

Optional - Set format on save and any global prettier options

2. Install Packages

npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier eslint-plugin-node eslint-config-node
@1Marc
1Marc / config.js
Created September 12, 2018 01:41
My VS Code Config
// For: @musaid
// https://twitter.com/musaid/status/1039688749205020672
// Ligatures built into Operator Mono as "Operator Mono Lig" with https://github.com/kiliman/operator-mono-lig
// VS Code Extensions: vscode-icons, indent-rainbow, Rainbow Brackets, Git Lense and Prettier (require config file with requireConfig)
// VS Code Theme: Night Owl -- custom colors for a bit higher contrast
{
"editor.tabSize": 2,
"editor.insertSpaces": true,
"window.zoomLevel": 1,
"editor.fontSize": 18,
@leebyron
leebyron / PriorityQueue.js
Last active January 28, 2019 05:08
PriorityQueue.js uses a binary heap to ensure the highest priority item is always available to dequeue, and sorts on enqueue. A dynamically resizing Array can be used to model the binary heap, for a simpler and more efficient implementation.
/**
* For compare function return:
* - Less than zero: item1 has higher priority than item2.
* - Zero: same.
* - Greater than zero: item1 has lower priority than item2.
*/
export type CompareFunction<T> = (item1: T, item2: T) => number;
export class PriorityQueue<T> {
_items: Array<T>;
@pcattori
pcattori / gist:2bb645d587e45c9fdbcabf5cef7a7106
Last active February 20, 2022 00:01
relay-style cursor-based pagination capable of filtering/sorting for SQL
import { Base64 } from 'js-base64'
import { Op } from 'sequelize'
import { fromGlobalId } from 'graphql-relay'
// https://github.com/graphql/graphql-relay-js/issues/94#issuecomment-232410564
const effectiveOrder = ({ last }, orderBy) => {
/* adds `id ASC` to end of `ORDER BY` if `id` is not already in the `ORDER BY` clause
flips `ASC` to `DESC` (and vice-versa) if pagination arg `last` is defined
*/
@laurenfazah
laurenfazah / express_postgress_knex.md
Last active November 26, 2022 13:19
Cheat Sheet: Setting up Express with Postgres via Knex

Express & Postgres via Knex

Note: <example> is meant to denote text replaced by you (including brackets).

Setup

// global dependencies
npm install -g knex
const http = require('http');
const memwatch = require('memwatch-next');
const heapdump = require('heapdump');
var server = http.createServer((req, res) => {
for (var i=0; i<1000; i++) {
server.on('request', function leakyfunc() {});
}
res.end('Hello World\n');
@Unitech
Unitech / app-koa.js
Last active January 20, 2022 11:24
Node.js Load Balancers Benchmark: HAProxy vs Nginx vs PM2
const Koa = require('koa');
const app = new Koa();
app.use(ctx => {
ctx.body = 'Hello World';
});
var listener = app.listen(process.env.PORT || 3000, () => {
console.log(`Listening on port ${listener.address().port}`);
});
@Unitech
Unitech / nginx.conf
Last active April 14, 2020 17:48
NGINX/PM2
worker_processes auto;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;