Skip to content

Instantly share code, notes, and snippets.

View fotoflo's full-sized avatar

Alex Miller fotoflo

View GitHub Profile
import React, { useState, createContext, useEffect, useCallback } from "react";
export const GapiClientContext = createContext();
const GAPI_CONFIG = {
apiKey: process.env.NEXT_PUBLIC_FIREBASE_CONFIG_apiKey,
clientId: process.env.GOOGLE_ID,
scope: "https://www.googleapis.com/auth/gmail.send",
discoveryDocs: ["https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest"],
fetch_basic_profile: true,
@fotoflo
fotoflo / download-from-csv.js
Created March 11, 2021 02:42
simple node script to download files from a csv
// to run
// ./download-from-csv.js csvfile.csv
// will download anything in the csv file under the col:
const colName = 'URL'
const fileDir = 'output_files' // to this subdirectory of the current dir
const csv = require('csvtojson')
const fs = require('fs')
const path = require('path')
const https = require('https')
@fotoflo
fotoflo / shopify-admin-areas.liquid
Created March 10, 2021 23:05
Shopify Admin areas. Link directly to a product or collection from it's public page
{% if customer and customer.tags contains 'admin' %}
<div class="adminArea">
<h2>Admin only</h2>
<p class="adminCTA"><a href="/admin/collections/{{collection.id}}" target="_blank">Edit Collection</a></p>
</div>
{% endif %}
{% if customer and customer.tags contains 'admin' %}
<div class="adminArea">
<h2>Admin only</h2>
import React from 'react';
import { connect } from 'react-redux'
import moment from 'moment'
import {
Container, Content, Text, Button, DatePicker, Title
} from 'native-base';
class Example extends React.Component {
import React from 'react';
import { connect } from 'react-redux'
import moment from 'moment'
import {
Container, Content, Text, Button, DatePicker, Title
} from 'native-base';
class Example extends React.Component {
@fotoflo
fotoflo / slimfaq_integrated_tooltip.jsx
Last active December 1, 2016 14:20
Slimfaq Integrated Tooltip
/**
* @author Alex Miller <alex@refuel4.com>
* Angular Faq service
* Dependancies: Angular.js, lodash, angular ui bootstrap
*/
class faqService {
constructor($http) {
this.$http = $http;
this.faqList = {
@fotoflo
fotoflo / MailChimp List of Images.HTML
Created November 24, 2016 02:14
Create a centered List of images in a table for MailChimp Emails
<div class="mcnTextContent">
<table border="0" cellpadding="20" cellspacing="0" width="600" id="emailContainer">
<tr>
<td align="center" valign="top">
{{#if images}}
{{#each images}}
<img style="max-width: 360px; margin: 0 auto;" src="{{this}}"/>
<br/>
{{/each}}
{{/if}}
@fotoflo
fotoflo / set_ngrok_env.js
Last active October 29, 2016 07:09
Ngrok is a great tool which creates introspectible tunnels, however its sometimes a pain to tell your app the name of its tunnel, so here we set it via javascript
var request = require('request-promise');
request('http://127.0.0.1:4040/api/tunnels')
.then( function(res){
var tunnels = JSON.parse(res).tunnels;
for(var i in tunnels){
console.log( 'setting NGROK_HOST_'+i+'=' + tunnels[i].public_url);
process.env['NGROK_HOST_'+i] = tunnels[i].public_url;
}
});
Service:
UserService.getUser = function(){
return $http( { method: 'GET', url: '/users/me', cache : true } )
.success(function(results, status){
if( (status!= 200) || (typeof(results) == "undefined") ){
alert('logged out!');
location.href = "/index.html";
}
});
//
// Track.js - tracking scripts by alex miller
//
//
config = {};
config.track = true;// set to true in production, false in dev env
config.dump = true;// set to false in production env, true in dev
config.mixpanel = true; // <%= TRACKS_CONFIG['mixpanel'] %>; // set to true in production env, false in dev
config.googleAnaltyics = true;