Skip to content

Instantly share code, notes, and snippets.

View jsmithdev's full-sized avatar
🏗️
building things

Jamie Smith jsmithdev

🏗️
building things
View GitHub Profile
const fs = require('fs')
,converter = require('json-2-csv')
,request = require('request')
//REPLACE WITH WANTED URL
,url = 'https:// [YOUR CREDS @ YOUR STORE] .myshopify.com/admin/products.json'
;
request(url, (error, response, body) => {
if(response.statusCode === 200){
const startTime = new Date().getTime()
const fs = require('fs')
,util = require('util')
,converter = require('json-2-csv')
,request = require('request')
,shopifyAPI = require('shopify-node-api')
,setTimeoutPromise = util.promisify(setTimeout)
;
@jsmithdev
jsmithdev / GenSalesForceCsvViaExternalSite.html
Created October 15, 2017 22:37
Example of creating csv from SalesForce Data all via an external site without SF libs (or any aside from jQuery)
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="generator" content="Read Example">
<meta name="application-name" content="Read Example">
<title>SmithsIO.com</title>
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
//page
function Buyer_Prospect__c(u, rec){
this.Id = rec
this.Responsible_Broker__c = u
}
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.BuyerProspectList_ext.getUsers}',
(res, err) => {
if(err.status){
@jsmithdev
jsmithdev / Ourrss-Export.json
Created December 4, 2017 03:42
Example file that is exported from Ourrss Desktop.
{
"0": "http://feeds.gimletmedia.com/hearreplyall",
"1": "http://rss.earwolf.com/improv4humans",
"2": "http://feeds.wnyc.org/radiolab",
"3": "https://feed.pippa.io/public/shows/harmontown",
"4": "http://rss.earwolf.com/never-not-funny",
"5": "http://feeds.99percentinvisible.org/99percentinvisible",
"6": "http://houndtall.nerdistind.libsynpro.com/rss",
"7": "http://rss.earwolf.com/how-did-this-get-made",
"8": "http://rss.earwolf.com/spontaneanation-with-paul-f-tompkins",
// APEX CONTROLLER CODE
public class QuickPix {
public String parentId {get;set;}
public String sessionId {get;set;}
public QuickPix(){
parentId = ApexPages.currentPage().getParameters().get('id');
sessionId = UserInfo.getSessionId();
}
@jsmithdev
jsmithdev / ReduceImageBeforeAttach.page
Last active January 9, 2018 17:54
Example of reducing an image size client side before uploading -- in this case to SalesForce
<!-- Example of controller
public class QuickPix {
public String parentId {get;set;}
public String sessionId {get;set;}
public QuickPix(){
parentId = ApexPages.currentPage().getParameters().get('id');//Use param as attachments parent uid;
sessionId = UserInfo.getSessionId();
}
@jsmithdev
jsmithdev / SLDS-Toast.js
Last active May 15, 2018 03:16
Easily relay messages to users using SLDS's Toast supporting success, warning, info & error.
// #REVISION FOR SF1 / MOBILE / SHRUNK SIZE
// <div class="toaster"></div> --Add to where you want to display toast, like top of a VF page or <table>
// Then to use call: mkToast('Hey there!', 'success') anywhere in JS
const clearToast = () => document.querySelector('.toaster').innerHTML = ''
const mkToast = (msg, type) => {
// toast type may be success || warning || info || error
const cont = document.createElement('div')
const toaster = document.querySelector('.toaster')
@jsmithdev
jsmithdev / SalesForceAddressToGeolocation.cls
Created January 17, 2018 17:17
Apex class for SalesForce that takes an Address and get's Geolocation from Google Maps API.
public class Location {
@InvocableMethod
public static void getLatLong(List<Id> Ids){
//Get opp
Opportunity opp = [
SELECT Id, jamiesmith__Location__Latitude__s, jamiesmith__Location__Longitude__s, jamiesmith__Street__c, jamiesmith__City__c, jamiesmith__State__c
FROM Opportunity
WHERE Id IN :Ids