Skip to content

Instantly share code, notes, and snippets.

View karol-majewski's full-sized avatar

Karol Majewski karol-majewski

View GitHub Profile
@adamwiggins
adamwiggins / adams-heroku-values.md
Last active November 27, 2024 17:06
My Heroku values

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@samwize
samwize / mocha-guide-to-testing.js
Created February 8, 2014 05:53
Explain Mocha's testing framework - describe(), it() and before()/etc hooks
// # Mocha Guide to Testing
// Objective is to explain describe(), it(), and before()/etc hooks
// 1. `describe()` is merely for grouping, which you can nest as deep
// 2. `it()` is a test case
// 3. `before()`, `beforeEach()`, `after()`, `afterEach()` are hooks to run
// before/after first/each it() or describe().
//
// Which means, `before()` is run before first it()/describe()
@feeela
feeela / recursivePromiseWithDelay.js
Last active December 4, 2023 16:20
Recursive JS promises with delay
#!/usr/bin/nodejs
var Promise = require( 'promise' );
/**
*
* @param {Array} list
* @param {int} delay
*/
function recursivePromiseWithDelay( list, delay ) {

Hi Zach :D

Modals are funny beasts, usually they are a design cop-out, but that's okay, designers have to make trade-offs too, give 'em a break.

First things first, I'm not sure there is such thing as a "simple" modal that is production ready. Certainly there have been times in my career I tossed out other people's "overly complex solutions" because I simply didn't understand the scope of the problem, and I have always loved it when people who have a branch of experience that I don't take the time

@bcherny
bcherny / compile-time-time-check-ideas.md
Created September 13, 2016 16:41
Compile time complexity and running time checks

Complexity

As a decorator:

interface Record {}

@Complexity("n")
function getRecord(userId: number): Record {
 return db.getRecords().findWhere({userId}) // Error! Expected O(n) complexity, found O(log(n)) complexity
@wojteklu
wojteklu / clean_code.md
Last active April 12, 2025 23:57
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@kevinSuttle
kevinSuttle / webpack.banner.js
Created October 12, 2016 16:50
Webpack auto-injecting banner into each file
const pkg = require('./package.json');
const moment = require('moment');
const localTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
const timeStamp = moment().format('LLLL');
const banner = `
Generated on ${timeStamp} - ${localTimeZone}
Description: ${pkg.description}
Package: ${pkg.name}
Version: v${pkg.version}
Contributors: ${pkg.contributors.map(function(contributor){ return contributor})}
@shershen08
shershen08 / typescript-strategy-and-factory-patterns.ts
Last active October 19, 2022 17:08
Strategy and factory patterns in TypeScript
// see article with examples in JAVA here: https://dzone.com/articles/design-patterns-the-strategy-and-factory-patterns
// example for educational purposes shownig close and mature syntax of modern TypeScript
enum AccountTypes {CURRENT, SAVINGS, HIGH_ROLLER_MONEY_MARKET, STANDARD_MONEY_MARKET}
////////////////////////////////////////
/// the interface that is used by the strategy
////////////////////////////////////////
interface InterestCalculationStrategy {
@branneman
branneman / app.js
Last active January 2, 2018 02:23
[FP playground] Generate diceware passwords with NodeJS. See also: https://www.rempe.us/diceware/
const map = fn => list => list.map(fn);
const filter = fn => list => list.filter(fn);
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));
const tail = list => list.slice(1);
const fill = val => num => new Array(num).fill(val);
const getFileContents = file => require('fs').readFileSync(file, { encoding: 'utf8' });
const split = char => str => str.split(char);
const join = char => list => list.join(char);
@javilobo8
javilobo8 / download-file.js
Last active March 17, 2025 14:25
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);