Skip to content

Instantly share code, notes, and snippets.

View adrianmcli's full-sized avatar
:shipit:
What's happening?

Adrian Li adrianmcli

:shipit:
What's happening?
View GitHub Profile
@adrianmcli
adrianmcli / layout.js
Created January 21, 2015 23:18
Apply Foundation topbar listener when a Meteor template is loaded
Template.layout.rendered = function(){
$(document).foundation('topbar', 'reflow'); // apply listener
}

Keybase proof

I hereby claim:

  • I am adrianmc on github.
  • I am adrianmcli (https://keybase.io/adrianmcli) on keybase.
  • I have a public key ASBfyo8kunHt6ETIM0v8Gb6kjZETpAmPl-wmyqbMf68slgo

To claim this, I am signing this object:

scrollHandler = () => {
// Get the element
const ele = $(this._container);
// Compare these two metrics to get the distance scrolled from the bottom
const metricA = ele[0].scrollHeight - ele.scrollTop();
const metricB = ele.outerHeight();
const distanceFromBottom = metricA - metricB;
console.log(`distanceFromBottom: ${distanceFromBottom}`);
componentWillReceiveProps() {
// before the new props come in, save the current scroll position
const ele = $(this._container);
const distanceFromBottom = ele[0].scrollHeight - ele.scrollTop() - ele.outerHeight();
this.setState({
distanceFromBottom,
});
}
import React from 'react';
import Avatar from 'material-ui/lib/avatar';
import CloseIcon from 'material-ui/lib/svg-icons/navigation/cancel';
export default class Chip extends React.Component {
constructor(props) {
super(props);
this.state = {
const hasFocus = editorState.getSelection().getHasFocus();
if (hasFocus) {
// make an array of blocks we need to request locks for
// 1. which locks do we currently have?
const currentLocks = this.locks.map(lock => lock.blockKey);
// 2. which locks does the user want? (getSelectedBlocks)
const desiredLocks = getSelectedBlocks().map(block => block.getKey());
// 3. Make a list of all elements in the desiredLocks not contained in currentLocks
const requestLocks = R.difference(desiredLocks, currentLocks);
// 4. Make a list of all elements in currentLocks not contained in desiredLocks
// ### Note ###
//
// R.difference(currentKeys, newKeys) returns an
// array of keys that I have, but the server does
// not have.
//
// Note also that the injectChanges function does not have any changes
componentWillReceiveProps(nextProps) {
this.locks = nextProps.locks;
@adrianmcli
adrianmcli / fetchYTduration.js
Created April 14, 2016 05:27
A function that returns the duration of a YouTube video from the YouTube API V3.
function fetchDuration(videoId, apiKey) {
const baseURL = 'https://www.googleapis.com/youtube/v3/videos?';
const url = `${baseURL}id=${videoId}&key=${apiKey}&part=snippet,contentDetails`;
$.ajax({
async: false,
type: 'GET',
url: url,
success: function(data) {
const item = data.items[0];
const result = item ? item.contentDetails.duration : null;
import React from 'react';
import PureRenderMixin from 'react-addons-pure-render-mixin';
import {convertFromRaw, ContentState} from 'draft-js';
import {stateToHTML} from 'draft-js-export-html';
import linkifyIt from 'linkify-it';
import tlds from 'tlds';
const linkify = linkifyIt();
linkify.tlds(tlds);
@adrianmcli
adrianmcli / DAN_MARTEL.md
Created May 28, 2016 06:14
Brief research on the career of Dan Martell.

Dan Martell

A New Brunswick native, Canadian Dan Martell discovered a book on Java programming while he was in rehab at the age of 18. According to him, this was his life’s turning point. Not long after that, he started a vacation rental (or cottage booking) site called Maritime Vacations.

Unfortunately, this didn’t work out for him because he eventually got pushed out by a larger, less niche, cottage-booking site. He was focused on the small region of Cummins in Eastern Canada and as a result, his growth was limited. This is an example of how nicheing down can hurt you.

Sometime after that, he started a web hosting company called NBHost. The biggest lesson he learned was “don’t start a web hosting company”. There’s just way too much to worry about, servers, uptime, etc.

Eventually, he would acquire a role as a Senior Web Developer in a large tech consulting firm in the year 2000. It’s not clear how the timeline of his two previous ventures coincide with his work history, but nevertheless, he worked the