Skip to content

Instantly share code, notes, and snippets.

@shobhitsharma
shobhitsharma / bigONotation.js
Created Jul 20, 2021 — forked from jhwheeler/bigONotation.js
Big O Notation Exercises
View bigONotation.js
// 1. Even or odd
function isEven(value){
if (value % 2 == 0){
return true;
}
else
return false;
}
@shobhitsharma
shobhitsharma / mixins.scss
Created Jul 12, 2020
IE 11 - CSS Grid - SASS mixins
View mixins.scss
// Ensure CSS grid works with IE 11 spec.
// https://css-tricks.com/browser-compatibility-css-grid-layouts-simple-sass-mixins/
// sass-lint:disable no-vendor-prefixes, no-duplicate-properties
@mixin display-grid {
display: -ms-grid;
display: grid;
}
// $columns values should be delimited by a space
@mixin grid-template-columns($columns...) {
@shobhitsharma
shobhitsharma / SassMeister-input.scss
Created Jun 1, 2020 — forked from pascalduez/SassMeister-input.scss
Some Sass string functions: capitalize, ucwords, camelize, ...
View SassMeister-input.scss
// ----
// Sass (v3.3.4)
// Compass (v1.0.0.alpha.18)
// ----
// Capitalize string
// --------------------------------------------------------------------------------
// @param [string] $string
// --------------------------------------------------------------------------------
// @return [string]
View Typography.tsx
import { css, cx } from "linaria";
import React, { ReactHTML } from "react";
import { neutral } from "../../theme/colors/colors";
/** Props for Typography. */
export interface TypographyProps {
/** The children to apply the formatting to. */
children?: React.ReactNode;
View storybook-docs-typescript-walkthrough.md

Storybook Docs w/ CRA & TypeScript

This is a quick-and-dirty walkthrough to set up a fresh project with Storybook Docs, Create React App, and TypeScript. If you're looking for a tutorial, please see Design Systems for Developers, which goes into much more depth but does not use Typescript.

The purpose of this walkthrough is a streamlined Typescript / Docs setup that works out of the box, since there are countless permutations and variables which can influence docs features, such as source code display, docgen, and props tables.

Step 1: Initialize CRA w/ TS

npx create-react-app cra-ts --template typescript
@shobhitsharma
shobhitsharma / web-servers.md
Created Jan 18, 2020 — forked from willurd/web-servers.md
Big list of http static server one-liners
View web-servers.md

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@shobhitsharma
shobhitsharma / assertions.go
Created Jul 23, 2019
Golang Custom Assertions
View assertions.go
package test_utils
import (
"fmt"
"reflect"
"strings"
)
// Assertion represents a fact stated about a source object. It contains the source object and function to call
type Assertion struct {
View localIdent.js
function getLocalIdent(context, localIdentName, localName, options) {
const fileName = context.resourcePath
? context.resourcePath.replace(/^.*[\\\/]/, "").replace(".style.scss", "")
: uuid();
return `hua-${fileName}__${localName}`;
}
function uuid() {
var firstPart = (Math.random() * 46656) | 0;
var secondPart = (Math.random() * 46656) | 0;
View Configuration file for Webpack 4 + Webpack Hot Module Replacement + BrowserSync + React 16.js
//App structure:
// app_folder/
// webpack.config.js
// /server/
// server.js
// /src/
// index.js
// How to run: from root folder run command: "node server/server"