This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule JSONMapBuilder do | |
| def to_map(list) when is_list(list) and length(list) > 0 do | |
| case list |> List.first do | |
| {_, _} -> | |
| Enum.reduce(list, %{}, fn(tuple, acc) -> | |
| {key, value} = tuple | |
| Map.put(acc, binary_to_atom(key), to_map(value)) | |
| end) | |
| _ -> | |
| list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| OldHttpRequest = Turbolinks.HttpRequest | |
| class Turbolinks.CachedHttpRequest extends Turbolinks.HttpRequest | |
| constructor: (_, location, referrer) -> | |
| super(this, location, referrer) | |
| requestCompletedWithResponse: (response, redirectedToLocation) -> | |
| @response = response | |
| @redirect = redirectedToLocation | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function convertHexToRgba(originalHex, opacity) { | |
| const hex = originalHex.replace('#', '') | |
| const r = parseInt(hex.substring(0, 2), 16) | |
| const g = parseInt(hex.substring(2, 4), 16) | |
| const b = parseInt(hex.substring(4, 6), 16) | |
| const rgba = `rgba(${r}, ${g}, ${b}, ${opacity})` | |
| return rgba | |
| } | |
| export function convertHexToRgb(originalHex) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import AsyncComponent from './AsyncComponent' | |
| // call this.getAsyncComponent(path) to get a default export. | |
| // call this.getAsyncComponent(path, specifier) to get a non-default export. | |
| class App extends AsyncComponent { | |
| render() { | |
| let view; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function setTextColor(color) { | |
| const rgb = convertHexToRgb(color) | |
| const gamma = 2.2 | |
| const luminosity = | |
| 0.2126 * Math.pow(splitRgb(rgb).r, gamma) + | |
| 0.7152 * Math.pow(splitRgb(rgb).g, gamma) + | |
| 0.0722 * Math.pow(splitRgb(rgb).b, gamma) | |
| if (luminosity < 0.6) return '#FFFFFF' | |
| return '#282828' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // meteor algorithm to check if this is a meteor serving http request or not | |
| function IsAppUrl(req) { | |
| var url = req.url; | |
| if(url === '/favicon.ico' || url === '/robots.txt') { | |
| return false; | |
| } | |
| // NOTE: app.manifest is not a web standard like favicon.ico and | |
| // robots.txt. It is a file name we have chosen to use for HTML5 | |
| // appcache URLs. It is included here to prevent using an appcache |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function actionTypeBuilder(prefix) { | |
| return { | |
| type: actionType => `${prefix}/${actionType}`, | |
| loading: actionType => `${actionType}/loading`, | |
| ready: actionType => `${actionType}/ready`, | |
| stopped: actionType => `${actionType}/stopped`, | |
| changed: actionType => `${actionType}/changed`, | |
| error: actionType => `${actionType}/error`, | |
| success: actionType => `${actionType}/success` | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function actionTypeBuilder(prefix) { | |
| return { | |
| type: actionType => `${prefix}/${actionType}`, | |
| loading: actionType => `${actionType}/loading`, | |
| ready: actionType => `${actionType}/ready`, | |
| stopped: actionType => `${actionType}/stopped`, | |
| changed: actionType => `${actionType}/changed`, | |
| error: actionType => `${actionType}/error`, | |
| success: actionType => `${actionType}/success` | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const createAdSet = async (fbCampaignId, campaign) => { | |
| try { | |
| const data = { | |
| [AdSet.Fields.campaign_id]: fbCampaignId, | |
| [AdSet.Fields.name]: `${campaign.name} Ad Set`, | |
| [AdSet.Fields.optimization_goal]: 'BRAND_AWARENESS', | |
| [AdSet.Fields.billing_event]: 'IMPRESSIONS', | |
| [AdSet.Fields.is_autobid]: true, | |
| // [AdSet.Fields.bid_amount]: 2, // TODO: Write a conversion method to calculate budget based on end date of campaign. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe Simulator do | |
| let(:table) { Table.new(5, 5) } | |
| let(:simulator) { described_class.new(table) } | |
| it "places the robot onto a valid position" do | |
| simulator.place(0, 0, "NORTH") | |
| expect(simulator.robot).to be_a(Robot) | |
| end | |
| it "places the robot onto a invalid position" do |
OlderNewer