Skip to content

Instantly share code, notes, and snippets.

@cmcewen
cmcewen / article_card.json
Last active August 29, 2015 14:07
Article Card Sample JSON
{
"card_type" : "article",
"web_url" : "http://techcrunch.com/2014/09/25/the-oatmeal-launches-another-crowdfunding-campaign-to-build-the-tesla-museum-one-brick-at-a-time/",
"article" : {
"title" : "The Oatmeal Launches Another Crowdfunding Campaign To Build The Tesla Museum, One Brick At A Time",
"abstract_content" : "The Oatmeal (aka Matthew Inman, aka 'that artist who makes web comics that take over your Facebook feed every few weeks') is at it again. He raised enough money to buy Nikola Tesla's old New York laboratory to build a museum for the late inventor.",
"html_content" : "<div> <img src='http://tctechcrunch2011.files.wordpress.com/2014/09/tesla.png?w=680&amp;h=347' /> <p>The Oatmeal (aka Matthew Inman, aka &quot;that artist who makes web comics that take over your Facebook feed every few weeks&quot;) is at it again.</p> <p>He <a href='http://techcrunch.com/2012/08/24/the-oatmeal-helps-new-tesla-museum-raise-one-million-smackers/'>raised enough money to buy Nikola Tesla's old New York laborat
@cmcewen
cmcewen / review_card.json
Last active August 29, 2015 14:07
Review Card Sample JSON
{
"card_type" : "review",
"web_url" : "https://www.engadget.com/2014/03/27/office-for-ipad-review/",
"review" : {
"title" : "Office for iPad review: three beautiful apps, each with strong competition",
"product_name" : "Microsoft Office for iPad",
"html_content" : "<div id='body' score='43.75'> <div class='copy post-body' score='53.75'> <div> <a href='http://www.engadget.com/2014/03/27/office-for-ipad-review/'><img alt='SONY DSC' src='http://o.aolcdn.com/hss/storage/adam/4ec18c028251856eba74554230e89123/DSC00115.jpg' /></a> </div> <p>After loads of leaks -- and some <a href='http://www.engadget.com/2012/02/21/microsoft-says-office-for-ipad-story-is-based-on-inaccurate-rum/'>serious denial</a> from Microsoft -- the company has finally <a href='http://www.engadget.com/2014/03/27/office-for-ipad/'>released</a> a version of Office for iPad. It's not surprising, in a way, given that Microsoft already has <a href='http://www.engadget.com/2013/06/14/microsoft-office-mobile-for-iphone-hands-on/'>Office Mobi
@cmcewen
cmcewen / video_card.json
Created October 20, 2014 15:28
Sample Video Card JSON
{
"card_type" : "video",
"web_url" : "https://www.youtube.com/watch?v=lM6rliphNdw",
"video" : {
"title" : "How North Korea got this way",
"embedded_url" : "https://www.youtube.com/embed/lM6rliphNdw",
"embedded_url_width" : 420,
"embedded_url_height" : 315,
"publication_date" : 20140723,
"description" : "Vox's Max Fisher explains the historical events that produced the bizarre, tragic North Korea we know today.",
@cmcewen
cmcewen / product_card.json
Created October 20, 2014 15:30
Sample Product Card JSON
{
"card_type": "product",
"web_url": "http://www.examplestore.com/listing/36226783/green-leather-shoes",
"offers": [
{
"price": {
"price": 7.99,
"currency": "USD"
},
"original_price": {
@cmcewen
cmcewen / product_search_card.json
Created October 20, 2014 15:30
Sample Product Search Card JSON
{
"card_type": "product_search",
"total_results": 2,
"products": [
{
"name": "Green leather shoes",
"product_card_url": "http://www.examplestore.com/product_cards/36226783/",
"price": {
"price": 7.99,
"currency": "USD"
@cmcewen
cmcewen / group_stories.py
Created January 31, 2015 20:57
Snapchat group stories hack
#!/usr/bin/env python
#using the awesome pysnap library: https://github.com/martinp/pysnap
from __future__ import print_function
import os.path
import sys
from getpass import getpass
from zipfile import is_zipfile, ZipFile
@cmcewen
cmcewen / upload.js
Created December 29, 2015 15:38
Upload image from React Native to Cloudinary
var CryptoJS = require('crypto-js');
function uploadImage(uri) {
let timestamp = (Date.now() / 1000 | 0).toString();
let api_key = 'your api key'
let api_secret = 'your api secret'
let cloud = 'your cloud name'
let hash_string = 'timestamp=' + timestamp + api_secret
let signature = CryptoJS.SHA1(hash_string).toString();
let upload_url = 'https://api.cloudinary.com/v1_1/' + cloud + '/image/upload'
#!/usr/bin/env node
const Express = require('express');
const webpack = require('webpack');
const userConfig = require('./user-config');
const path = require('path');
const root = path.resolve(__dirname, '../../..');
const sourceDir = path.resolve(root, './src');
const config = require('./merge-configs')(userConfig(root, sourceDir));
#!/usr/bin/env node
const express = require('../lib/server.js').default;
const renderer = require('../lib/server/renderer').default;
const start = require('../lib/start').default;
const userConfig = require('./user-config');
const path = require('path');
const root = path.resolve(__dirname, '../../..');
const sourceDir = path.resolve(root, './src');
➜ universal-redux-starter git:(master) npm run dev
> universal-redux-starter@0.0.1 dev /Users/cmcewen/Code/universal-redux-starter
> concurrent --kill-others "npm run watch-client" "npm run dev-server"
[1]
[1] > universal-redux-starter@0.0.1 dev-server /Users/cmcewen/Code/universal-redux-starter
[1] > NODE_PATH=./src universal-redux-server
[1]
[0]