Skip to content

Instantly share code, notes, and snippets.

View keithnorm's full-sized avatar

Keith Norman keithnorm

View GitHub Profile
@keithnorm
keithnorm / UICollectionView+ScrollViewAnimateable.swift
Created May 25, 2016 14:45
enable animating a scroll view's contentOffset property with custom easing
//
// UICollectionView+ScrollViewAnimateable.swift
// persimmon
//
// Created by Keith Norman on 5/24/16.
// Copyright © 2016 Good Eggs. All rights reserved.
//
/// Based on https://github.com/plancalculus/MOScrollView. This allows animating contentOffset with a timing function. It's not possible to animate contentOffset via a CAAnimation. It is possible to animate bounds but then scrollview delegate methods don't get called which may be an issue if the animation exposes new cells in a table view or collection view and you expect those cells to render when the scroll into view.
@keithnorm
keithnorm / kway-mergesort.c
Created March 28, 2014 16:06
k-way merge on 2D array of sorted arrays using bottom up mergesort
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void merge(int **a, int start, int end, int sz) {
int *a1 = a[start];
int *a2 = a[end];
int res[sz];
int i = 0;
int j = 0;
class TodoApp extends React.Component {
constructor({db}) {
super();
this.db = db;
this.state = {
todos: [],
text: '',
}
}
//on the client
import Zango from 'zangodb';
let db = new Zango.Db('todo_app', { todos: [] });
ReactDOM.render(
<TodoApp db={db}/>,
document.getElementById('app')
);
// on the server
import { renderToStaticMarkup } from 'react-dom/server';
import MongoClient from 'mongodb';
app.get('*', (req, res) => {
var url = 'mongodb://localhost:27017/todo-app';
MongoClient.connect(url, function(err, db) {
res.status(200).render('layout', {
locals: {
body: renderToStaticMarkup(<TodoApp db={db}/>),
<body>
<div id=’app’>
${body}
</div>
</body>
import { renderToStaticMarkup } from 'react-dom/server';
app.get('*', (req, res) => {
res.status(200).render('layout', {
locals: {
body: renderToStaticMarkup(<TodoApp/>),
}
});
});
import Zango from 'zangodb';
let db = new Zango.Db('todo_app', { todos: [] });
class TodoApp extends React.Component {
constructor() {
super();
this.state = {
todos: [],
0x4db7a13ae9df91f427508e5b2253be851c3cbd14
/**
* Copyright 2015 SmartThings
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License