Skip to content

Instantly share code, notes, and snippets.

@megamaddu
megamaddu / .obsidian.vimrc
Last active September 29, 2023 21:48
.obsidian.vimrc
" Have j and k navigate visual lines rather than logical ones
nmap j gj
nmap k gk
vmap j gj
vmap k gk
exmap 0 goLineLeftSmart
exmap $ goLineRight
" I like using H and L for beginning/end of line
nmap H ^
@megamaddu
megamaddu / Ref.js
Created May 31, 2018 18:33
react-basic Ref component
"use strict";
var React = require("react");
var ReactDOM = require("react-dom");
exports.makeRef = function(toMaybe) {
var Ref = function(props) {
this.DOMNode = null;
return this;
};

Keybase proof

I hereby claim:

  • I am spicydonuts on github.
  • I am spicydonuts (https://keybase.io/spicydonuts) on keybase.
  • I have a public key ASDB7aF8V6QL-8_f2qdmR1L58WYnWWJDOdvVBHep9kgmLgo

To claim this, I am signing this object:

@megamaddu
megamaddu / Client.purs
Created August 12, 2017 16:43
PS Client file
module Client
( Url
, LoggerConfig
, Logger
, Action
, ActionType
, Queue
, ClientEffects
, defaultLoggerConfig
, createLogger
@megamaddu
megamaddu / cookies_normal_.test.ts
Last active June 2, 2017 16:18
Comparing your usual unit tests to snapshot tests. The output on failure is the same. If I'd been lazier on the normal version and only checked a couple properties the snapshot test would be much more thorough by comparison. You can see why it becomes more beneficial as the data size grows (like a React element tree or an API response).
import * as sinon from 'sinon'
import { setCookie, clearCookie } from './cookies'
describe('cookies', () => {
it('setCookie (defaults)', () => {
const spy = sinon.spy()
const ctx = { cookies: { set: spy } }
setCookie(ctx as any, 'test', 'val')
expect(spy.callCount).toBe(1)
expect(spy.firstCall.args).toEqual([
@megamaddu
megamaddu / scroll-manager.js
Last active May 9, 2021 14:17
Scroll Manager for React Router v4
import React from 'react'
import { func, node, number, object, shape, string } from 'prop-types'
import { withRouter } from 'react-router'
import debounceFn from 'lodash/debounce'
class ScrollManager extends React.Component {
static propTypes = {
children: node.isRequired,
history: shape({
action: string.isRequired,
@megamaddu
megamaddu / cloudSettings
Last active January 26, 2018 18:05
Visual Studio Code Sync Settings Gist
{"lastUpload":"2018-01-26T18:05:10.909Z","extensionVersion":"v2.8.7"}
import React, { PropTypes } from 'react'
import { createStore } from 'redux'
import { Provider, connect } from 'react-redux'
import Router from 'react-router/BrowserRouter'
import Match from 'react-router/Match'
import Link from 'react-router/Link'
import { compose, getContext } from 'recompose';
const store = createStore((s = {}, a) => s)
import React from 'react'
import { createStore } from 'redux'
import { Provider, connect } from 'react-redux'
import Router from 'react-router/BrowserRouter'
import Match from 'react-router/Match'
import Link from 'react-router/Link'
const store = createStore((s = {}, a) => s)
const BasicExample = () => (
module = angular.module 'inputHelpers', []
if not Bacon?
console.log 'window.Bacon not found, skipping input validator initialization'
return
module.constant 'bacon', Bacon
_masks =
ssn: 'ddd-dd-dddd'