Skip to content

Instantly share code, notes, and snippets.

{
"id": "news",
"title": "LATEST NEWS",
"icon_url": "https://s3.amazonaws.com/s3.dashbook.co/dash_icons/news_large_icon.png",
"summary": "Description of news dash.",
"credits": "Google News",
"settings_type": "SELECT",
"settings_options": [
{
"key": "top",
{
"cities":[
{
"picture":"http://media-cdn.tripadvisor.com/media/photo-s/03/9b/2f/df/montreal.jpg",
"name":"Montreal",
"nickname":"The City Of Saints",
"province":"Quebec"
},
{
"picture":"http://images.hellobc.com/mgen/tbccw/production/TBCCWDisplay.ms?img=/getmedia/4149a8de-fc5d-4e54-b659-5282486fa973/2-200291313-001-Vancouver-skyline.jpg.aspx&tl=1&sID=1&c=public,max-age=172802,post-check=7200,pre-check=43200&bid=4_5",
{
"id": "city-card",
"title": "City",
"icon_url": "http://relevant.ai/city.png",
"summary": "Card's summary for the library.",
"credits": "The Web",
"settings_type": "NONE",
"_LOAD": {
"json_info":{
"_URL":"https://gist.githubusercontent.com/wircho/d6c606350f8a6dca29ee/raw/b7872ecebfcc868ff825c88fe1c5e06d13ad618c/cities"
{
"id": "cities-card",
"title": "Cities",
"icon_url": "http://relevant.ai/cities.png",
"summary": "Card's summary for the library.",
"credits": "The Web",
"settings_type": "NONE",
"_LOAD": {
"json_info":{
"_URL":"https://gist.githubusercontent.com/wircho/d6c606350f8a6dca29ee/raw/b7872ecebfcc868ff825c88fe1c5e06d13ad618c/cities"
{
"id": "cities-card",
"title": "Cities",
"icon_url": "http://relevant.ai/cities.png",
"summary": "Card's summary for the library.",
"credits": "The Web",
"settings_type": "NONE",
"_LOAD": {
"json_info":{
"_URL":"https://gist.githubusercontent.com/wircho/d6c606350f8a6dca29ee/raw/b7872ecebfcc868ff825c88fe1c5e06d13ad618c/cities"
@wircho
wircho / every_2_seconds
Created June 4, 2015 14:27
REL ( https://github.com/relevant-ai/RelevantCardsDocumentation ): How to load a web service, or any variable, only if more than 2 seconds have passed since last time it was loaded.
{
"_MAIN":{
"info":{
"time":{"_DATE":{"_FORMAT_OUT":"<<timestamp>>"}},
"var":"This is the variable. Here you put your API call, your _URL, whatever you need to call no less than 2 seconds in between every call."
},
"get_var":{
"_FUNCTION":{
"_IF":{"_MATH":[{"_DATE":{"_FORMAT_OUT":"<<timestamp>>"}},"-",{"_PATH":["info","time"]},">2"]},
"_THEN":{"_REFETCH":["info"],"_RETURN":{"_PATH":["info","var"]}},
{
"_LOAD":{
"yql":{
"_FUNCTION":{"_URL":{"_CONCAT":[
"https://query.yahooapis.com/v1/public/yql?q=",
{"_URL_ENCODE":"{$0}"},
"&format=json&diagnostics=true&callback="
]}}
},
"some_variable":{"_APPLY":{"yql":"SELECT * FROM html WHERE url='google.com'"}}
{
"title": "Watch Cities",
"icon_url": "http://relevant.ai/cities.png",
"summary": "Card's summary for the library.",
"credits": "The Web",
"settings_type": "NONE",
"_LOAD": {
"json_info":{
"_URL":"https://gist.githubusercontent.com/wircho/d6c606350f8a6dca29ee/raw/b7872ecebfcc868ff825c88fe1c5e06d13ad618c/cities"
},
{"mapping":{"actionLink":null,"bannerImage":null,"bannerTitle":null,"bannerCaption":null,"profileImage":null,"profileCaption":null},"title":"Colors","type":"stream","template":"Temp_1","endpoint":"https://www.reddit.com/hot.json","createdAt":"2015-10-01T18:41:14.900Z","source":"meta {\n title = \"Color Samples\"\n}\n\nload {\n card in\n\n let info = [\n [\"name\":\"Red\", \"color\":\"red\", \"rgb-values\":[231,76,60]],\n [\"name\":\"Green\", \"color\":\"green\", \"rgb-values\":[112,173,75]],\n [\"name\":\"Blue\", \"color\":\"blue\", \"rgb-values\":[41,128,185]]\n ]\n\n return info.loop {\n item in\n\n return [\n [ // First template of each slide\n \"banner\":[\n \"color\":item[\"color\"]\n ]\n ],\n [ // Second template of each slide\n \"description\":[\n \"title\":item[\"name\"],\n \"body\":\"RGB: (\" + \",\".join(item[\"rgb-values\"]) + \")\"\n ]\n ],\n [ // Third template of each slide\n \"footer\":[\n
@wircho
wircho / SafeMatrix.swift
Last active August 3, 2016 18:31
A type-safe wrapper for existing matrix types.
/*
* SafeMatrix.swift
*/
// MARK: Convenience types and functions
public typealias MatrixDimensions = (rows:UInt,columns:UInt)
public typealias MatrixIndex = (i:UInt,j:UInt)
public func ==(lhs:MatrixDimensions,rhs:MatrixDimensions) -> Bool {
return lhs.rows == rhs.rows && lhs.columns == rhs.columns