Skip to content

Instantly share code, notes, and snippets.

View k1ch's full-sized avatar

Keyvan Chamani k1ch

View GitHub Profile
@k1ch
k1ch / css-units-best-practices.md
Created September 13, 2022 17:59 — forked from basham/css-units-best-practices.md
CSS Units Best Practices

CSS units

Recommendations of unit types per media type:

Media Recommended Occasional use Infrequent use Not recommended
Screen em, rem, % px ch, ex, vw, vh, vmin, vmax cm, mm, in, pt, pc
Print em, rem, % cm, mm, in, pt, pc ch, ex px, vw, vh, vmin, vmax

Relative units

Relative units

@k1ch
k1ch / mongodb_cheat_sheet.md
Created April 8, 2020 23:17 — forked from bradtraversy/mongodb_cheat_sheet.md
MongoDB Cheat Sheet

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

@k1ch
k1ch / nodejs-tcp-example.js
Created February 27, 2020 01:46 — forked from tedmiston/nodejs-tcp-example.js
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@k1ch
k1ch / max_plus_one.sql
Created June 19, 2018 16:20
PostgreSQL function: gets MAX of a column and returns plus one
CREATE OR REPLACE FUNCTION max_plus_one(tableName text, columnName text) RETURNS bigint AS
$func$
DECLARE
answer bigint;
BEGIN
EXECUTE format('(SELECT(SELECT max(%I) from public.%I)+1)',columnName,tableName) INTO answer;
RETURN (SELECT COALESCE(answer, 1));
END;
$func$
LANGUAGE PLPGSQL
@k1ch
k1ch / profile.route.spec.ts
Last active February 27, 2018 00:04
unit test: express, routes, sinon, chai, supertest, typescript
import { expect, assert } from 'chai';
import * as sinon from 'sinon';
import * as _ from 'lodash';
import * as express from 'express';
import * as supertest from 'supertest';
import * as bodyParser from 'body-parser';
import * as config from 'config';
import { Guard } from '../../lib/guard';
import { ProfileRoute } from './profile.route';