Skip to content

Instantly share code, notes, and snippets.

View rishabh-ink's full-sized avatar

Rishabh rishabh-ink

View GitHub Profile
@rishabh-ink
rishabh-ink / dabblet.css
Created May 7, 2013 07:32
CSS border-left-color example
/**
* CSS border-left-color example
* http://docs.webplatform.org/wiki/css/properties/border-left-color
*/
body {
margin: 0 auto;
width: 80%;
}
@rishabh-ink
rishabh-ink / git-aliases
Created September 23, 2013 17:28
Some git aliases used in my terminal.
# Git aliases
alias gs="git status"
alias ga="git add"
alias gc="git commit -m "
alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
alias gp="git push --all origin"
// ----
// Sass (v3.4.7)
// Compass (v1.0.1)
// ----
/* Alias */
$config__tile: (
"active": (
"background-color": #4C9CEA,
@rishabh-ink
rishabh-ink / dependencies.txt
Created July 15, 2017 15:40
openSUSE Leap 42.2 - Kvantum dependencies
gcc
libQt5Svg5
libqt5-qtsvg-devel
libqt5-qtx11extras-devel
libX11-devel
libQt5Widgets-devel
libQt5PlatformHeaders-devel
@rishabh-ink
rishabh-ink / ExampleComponent.js
Last active June 3, 2018 23:33
Mocking fetch in Jest
import React, { Component } from 'react';
class ExampleComponent extends Component {
componentDidMount() {
const fetchedData = this.fetchDataFromServer();
// ... do something with fetchedData e.g. set the data
}
async fetchDataFromServer() {
@rishabh-ink
rishabh-ink / ExampleComponent.test.js
Last active February 8, 2023 02:20
Mocking and testing fetch with Jest
import { shallow } from 'enzyme';
import ExampleComponent from './ExampleComponent';
describe('ExampleComponent', () => {
it('fetches data from server when server returns a successful response', done => { // 1
const mockSuccessResponse = {};
const mockJsonPromise = Promise.resolve(mockSuccessResponse); // 2
const mockFetchPromise = Promise.resolve({ // 3
json: () => mockJsonPromise,
@rishabh-ink
rishabh-ink / perf_hooks.js
Created July 30, 2018 23:57
Libdefs for Node’s experimental (as of v10.7.x) core module, perf_hooks
// @flow
/**
* Libdefs for Node’s experimental (as of v10.7.x) core module, perf_hooks.
*
* TODO Work in progress. Add libdefs for other functions in this module.
*
* @see https://nodejs.org/api/perf_hooks.html
*/
declare module 'perf_hooks' {
@rishabh-ink
rishabh-ink / ExamplePythonCLIProgram.py
Last active March 6, 2019 05:38
A boilerplate example of a Python CLI program
# -*- coding: utf-8 -*-
import argparse
import logging
import sys
def main(argv=None):
argparser = argparse.ArgumentParser(
description='A boilerplate greeting program!',
)
@rishabh-ink
rishabh-ink / levitation.py
Last active March 23, 2019 22:45
Of pytest and lru_cache in Python
from functools import lru_cache
from spells import cast_spell
@lru_cache(maxsize=2)
def levitate(target):
"""
Levitates `target` with the "Wingardium Leviosa" spell.
:param str target: Object that you would like to levitate
from unittest import mock
import pytest
@pytest.mark.parametrize(
'ordinary_object',
[
'quill',
'cushion',