Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
# Converts Day One exported notes to `enex` for Evernote importing
# Not complete
# It only exports:
# - title (assumed as the first line of the content starting with `# `)
# - content (rest of the content)
# - tags
# - created
# - updated
@lmuntaner
lmuntaner / AuthorizedRoute.ts
Created March 18, 2018 07:13
AuthorizedRoute Component
class AuthorizedRoute extends Component<StateProps & DispatchProps & RouteProps, {}> {
public componentWillMount() {
if (!this.props.token) {
this.props.dispatchLogin();
}
}
public render() {
const { component: RouteComponent, render, token, ...rest } = this.props;
@lmuntaner
lmuntaner / actionCreatorAPI.js
Last active January 24, 2018 06:32
Snippets for: How we connect Redux to our Services API article
const getFiles = () => ({
type: API,
path: '/files',
onSuccess: addFiles,
});
@lmuntaner
lmuntaner / calculator.js
Created June 19, 2017 12:51
Calculator
// Calculator
const operations = {
'+': (...nums) => nums.reduce((acc, num) => acc + num),
'*': (...nums) => nums.reduce((acc, num) => acc * num),
}
const calculatorCreator = (additionalOperations = {}) => {
const calculator = (...elements) => {
const operator = elements[elements.length-1];
@lmuntaner
lmuntaner / redux-request-middleware.js
Created April 27, 2017 12:30
Redux Middleware for making requests
const createRequestMiddleware = baseUrl => ({ dispatch }) => next => action => {
if (action.type !== 'api') {
return next(action)
}
const url = `${baseUrl}${action.url}`;
return fetch(url)
.then(res => res.json())
.then(data => action.success(dispatch, data))
}
@lmuntaner
lmuntaner / Loop33 Classes Tests
Created April 5, 2016 05:26
Mini Coding Test For Loop33
describe('class creation', () => {
it('is as simple as `class XXX {}`', function() {
class TestClass {};
const instance = new TestClass();
assert.equal(typeof instance, 'object');
});
it('class is block scoped', () => {
@lmuntaner
lmuntaner / gist:0fa1b902b7cda69ab435
Created July 13, 2015 15:07
Distance between two coordenates
function distance(lat1, lon1, lat2, lon2, unit) {
var radlat1 = Math.PI * lat1/180
var radlat2 = Math.PI * lat2/180
var radlon1 = Math.PI * lon1/180
var radlon2 = Math.PI * lon2/180
var theta = lon1-lon2
var radtheta = Math.PI * theta/180
var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta);
dist = Math.acos(dist)
dist = dist * 180/Math.PI
<html>
<body>
<a href="javascript:;">javascript:;</a>
<p class="texts">text</p>
<p class="texts">text</p>
<p class="texts">text</p>
<p class="texts">text</p>
<p class="texts">text</p>
<p class="texts">text</p>
@lmuntaner
lmuntaner / gist:13d31b13eb2692218054
Created July 13, 2015 13:47
Fade Everything Out
<html>
<body>
<button id="hide">HIDE!</button>
<div class="container">
<p>
Bacon ipsum dolor amet landjaeger ham meatball pork chop, pig alcatra corned beef sirloin capicola boudin shankle turducken ham hock leberkas. Shank ham hock jowl pastrami, brisket pork loin meatloaf kevin boudin porchetta swine. Beef shoulder jerky, brisket shank tail rump hamburger doner salami biltong short loin. Chuck swine beef ribs tenderloin corned beef prosciutto salami ham, pastrami pork. Ground round t-bone pork belly meatloaf brisket prosciutto.
Tenderloin doner meatloaf, short ribs salami pastrami ball tip meatball brisket tail pork loin. Tenderloin kevin prosciutto, hamburger boudin venison filet mignon ham salami andouille. Bacon chicken cow strip steak kevin beef. Drumstick capicola beef ribs, cupim fatback shank chuck filet mignon landjaeger tenderloin turducken tri-tip spare ribs kevin venison. Leberkas fatback shankle shank alcatra pancetta andouille ham hock meatloaf.
Tenderloin boudin corned be
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>
<div class="container" style="margin-top: 50px;">
<button class="btn btn-primary do-something">Do Something</button>
</div>