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
// VS Code w/ Quokka.js
const https = require('https'),
key = 'XXXX';
const endpoint = `https://maps.googleapis.com/maps/api/geocode/json?key=${key}&address=15 hernandez ave palm coast fl&sensor=false`
//https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY
https.get(endpoint, (resp) => {
let data = '';
// A chunk of data has been recieved.
@jsmithdev
jsmithdev / SalesForceFileUpload.js
Created February 28, 2018 07:55
SalesForce File (that replaces Attachments) Upload via JS example.
/*
Uses API, should have similar before js runs;
<script>const __sfdcSessionId = '{!sessionId}'</script>
<script src="/soap/ajax/42.0/connection.js" type="text/javascript"></script>
*/
const addAttachment = (parentId, filename, file) => {
const reader = new FileReader()
if(file == undefined){
@jsmithdev
jsmithdev / fiddle.html
Created March 11, 2018 05:00 — forked from anonymous/fiddle.html
Modern WebRTC remote call w/chat (source: https://jsfiddle.net/jamiesmith/Lcpk143y/)
<video id="video1" height="120" width="160" autoplay muted></video>
<video id="video2" height="120" width="160" autoplay></video>
<br>
<button id="button" onclick="createOffer()">Offer:</button>
<textarea id="offer" placeholder="Paste offer here"></textarea>
<br>
@jsmithdev
jsmithdev / package.xml
Last active March 28, 2018 14:58
VS Code + SalesForce : can use this as default to pull only what you need. Put under src dir and from command palette > ForceCode Menu > Retrieve Package/Metadata > Retrieve by package.xml to use.
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>ApexClass</name>
</types>
<types>
<members>*</members>
<name>ApexComponent</name>
</types>
<style>
.help {
font-size: 0.7rem;
/* border-radius: 25rem; */
background: #555;
color: #bae7fc;
border: 1pt solid #bae7fc;
width: 1em;
height: 1em;
padding-left: .25rem;
@jsmithdev
jsmithdev / Simple Node Gulpfile.js
Last active December 13, 2018 01:18 — forked from webdesserts/Gulpfile.js
Revised for Gulp v4: Automatically reload your node.js app on file change with Gulp (https://github.com/wearefractal/gulp).
// jshint esversion: 6, asi: true, laxcomma: true
const gulp = require('gulp')
, spawn = require('child_process').spawn
, killer = node => node ? node.kill() : null
, config = {
init: ['index.js'],
watch: ['*.js']
}
;
@jsmithdev
jsmithdev / mobile print console to screen.html
Created September 1, 2018 05:13
Prints console log to screen when remote device can't work for debugging mobile quickly
<!-- console will print in div -->
<div id="_prtScn"></div>
<script>
const _isMobile = () => {
let check = false;
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|h
@jsmithdev
jsmithdev / CustomDatePicker.page
Created November 14, 2018 22:46
Salesforce: Override datepicker, implement Pikaday
<!-- Static Resource: https://drive.google.com/file/d/1yZMzQMYkNa40JyRTOoQvMMLZg_bL-1F9/view?usp=sharing -->
<apex:page controller="Example">
<link rel="stylesheet" href="{!URLFOR($Resource.FormsResource, '/pikaday/css/pikaday.css')}" />
<apex:inputField styleClass="datepicks" value="{!Opp.StartDate}" />
<script src="{!URLFOR($Resource.FormsResource, 'currency.js')}" ></script>
@jsmithdev
jsmithdev / WebComponent.js
Last active June 9, 2022 04:49
Web Component boilerplate for a native web-component (v1 spec)
/*
* Use tag to import via es6 module (html import deprecated in v1 spec :/ )
* <script type="module" src="../components/web-component/web-component.js"></script>
*/
'use strict()'
const template = document.createElement('template')
template.innerHTML = /*html*/`
<style>
.card {
@jsmithdev
jsmithdev / Search.cmp
Last active November 28, 2018 15:18
Lightning Component: Search on enter
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global">
<lightning:card >
<span onkeypress="{!c.keyCheck}">
<lightning:input aura:id="searchbox" label="" name="searchbox"
placeholder="Search a thing" value="" />
</span>
</lightning:card>
</aura:component