Skip to content

Instantly share code, notes, and snippets.

@vm
vm / keybase.md
Last active August 29, 2015 14:11

Keybase proof

I hereby claim:

  • I am vm on github.
  • I am vignesh (https://keybase.io/vignesh) on keybase.
  • I have a public key whose fingerprint is C3C9 96A7 21E5 3F81 89AC FFA8 3D1A 96A8 153B 1576

To claim this, I am signing this object:

@vm
vm / message.rs
Last active December 2, 2015 04:23
extern crate chrono;
use std::fmt;
use chrono::*;
enum Source {
Facebook(String),
SMS(usize),
Email(String)
class Counter extends React.Component {
constructor(props) {
super(props)
this.state = {
counter: 0
}
}
}
class CounterWithState extends React.Component {
@vm
vm / curryOp.js
Last active February 26, 2016 19:27
import { curry } from 'ramda'
const filter = curry((fn, xs) => {
ys = []
for (let x of xs) { if (fn(x)) ys.push(y) }
return ys
})
const xs = [1, 4, 3, 2]
def accumulate_with_remainder(xs):
"""implements accumulate while also returning the remainder
>>> accumulate_with_remainder([1,2,3])
[
([], [1,2,3]),
([1], [2,3]),
([1,2], [3]),
([1,2,3], [])
]
from functools import partial
from inspect import signature
def curry(func, _arglen=None):
"""creates a curried version of the given function
>>> add = lambda a, b: a + b
>>> assert add(1, 2) == curry(add)(1)(2)
True
import signal
def timeout(seconds):
def wraps(fn):
def inner(*args, **kwargs):
def handler(signum, frame):
raise TimeoutError
signal.signal(signal.SIGALRM, handler)
signal.alarm(seconds)
@vm
vm / App-inline.js
Last active October 14, 2016 01:44
import React, { Component } from 'react'
const Timeline = ({ children }) => (
<div style={{ display: 'flex', alignItems: 'center', flexDirection: 'column' }}>
{children.map(child => <div style={{ width: '16rem', padding: '1.4rem' }}>{child}</div>)}
</div>
)
const PostHeader = ({ authoredAt, author }) => (
<div style={{ backgroundColor: '#e8fdf5', paddingTop: '1rem', paddingBottom: '1rem',fontSize: '875rem' }}>
import csv
import xml.etree.ElementTree as ET
STAGING = True
domain = 'uniswap-staging.org' if STAGING else 'uniswap.org'
tree = ET.parse('sitemap-0.xml')
urlset = tree.getroot()