Skip to content

Instantly share code, notes, and snippets.

@adamjohnson
adamjohnson / liquid_comment.sublime-snippet
Last active Jan 29, 2021
A collection of Liquid Snippets for CleanSlate CMS + Sublime Text 3.
View liquid_comment.sublime-snippet
<snippet>
<!-- Snippet to insert a Liquid comment for CleanSlate. -->
<content><![CDATA[
{% comment %}
${1:}
{% endcomment %}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>lqcomment</tabTrigger>
<description>Liquid Comment</description>
@adamjohnson
adamjohnson / google-apps-script-google-sheets-json-api.js
Created Jan 6, 2021
The code to get Google Apps Script to create a JSON API from a Google Spreadsheet (code from video: https://www.youtube.com/watch?v=3OakodfKjrU + comments).
View google-apps-script-google-sheets-json-api.js
// Script from: https://www.youtube.com/watch?v=3OakodfKjrU
function doGet (request) {
var query = request.parameter.q; // If you want to search for specific data, append ?q=my-string-to-search-for
var parameters = 2; // The number of columns in your spreadsheet.
var sheetname = 'Sheet1'; // TODO: Change this to the name of the sheet you want to target.
var doc = SpreadsheetApp.openById(PropertiesService.getScriptProperties().getProperty('key')); // NOTE: 'key' must be the same up here as it is down below in setup();
var sheet = doc.getSheetByName(sheetname);
var lastrow = sheet.getLastRow();
var rows = []; // The array we're going to push our data to.
@adamjohnson
adamjohnson / dot-join-with-newline-as-argument.js
Created Nov 30, 2020
Using the newline character with the .join() method in JavaScript to combine a string.
View dot-join-with-newline-as-argument.js
let myString = [
'<div class="container">',
'<h2>This is inserted via JS:</h2>',
'<p>',
'The .join() method can accept newline as an argument.',
'Much better than +!',
'</p>',
'</div>'
].join('\n'); // <-- 🎉
@adamjohnson
adamjohnson / profile_index.json
Created May 18, 2020
Use CleanSlateCMS to output JSON for a profile index template.
View profile_index.json
[<r:children:each limit='{$limit}' labels='{$labels}'>
{
"id": <r:page:id />,
"page_published_at": "<r:date_format format='httpdate' value='{page:published_at}' />",
"page_url": "<r:page:url />",
"page_name": "<r:page:name />",
"page_alternate_name": "<r:page:alternate_name />",
"profile_name": "<r:page:content name='wvu-profile__name' />",
"profile_job_title": "<r:page:content name='wvu-profile__job-title' />",
"profile_email": "<r:escape_xml><r:page:content name='wvu-profile__email' /></r:escape_xml>",
@adamjohnson
adamjohnson / google-calendar.html
Last active Mar 4, 2021
Pull events from a public Google Calendar using the Google Calendar API. Based off of: https://stackoverflow.com/a/56496854/908059
View google-calendar.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Google Calendar API</title>
</head>
<body>
<h1>Events:</h1>
<div id="js-gcal-event">
<!-- SVG loader By Sam Herbert (@sherb). http://goo.gl/7AJzbL -->
@adamjohnson
adamjohnson / sublime-keyboard-shortcuts.md
Last active May 12, 2020
Sublime Text keyboard shortcuts I should remember
View sublime-keyboard-shortcuts.md

Sublime Text keyboard shortcuts

These are some Sublime Text keyboard shortcuts that I can't seem to remember. I am writing them down in hopes I will use them and commit them to memory.

  1. Find the matching bracket: CTRL + M. Finds: (), {}, [].
  2. Select entire contents of parentheses, brackets, or braces: CTRL+SHIFT+M.
  3. Jump to specific line number: CTRL + P then :xx eg: :50 to go to line 50.
  4. Copy/Cut & Paste entire lines without highlighting: Same keys, paste inserts line above your cursor.
  5. Add a new line from the middle of some text & place cursor on the new line: CTRL/CMD + ENTER.
@adamjohnson
adamjohnson / no-jquery-native-apis.md
Last active Apr 7, 2021
A list of "You might not need jQuery" / helpful native API's & methods.
View no-jquery-native-apis.md

A well designed vanilla JS resource:

https://codetogo.io/

☝️ Can search via method name or the task you want to accomplish.


A great list of commonly used native JS methods and API's:

@adamjohnson
adamjohnson / rcomment.sublime-snippet
Created Sep 6, 2018
Sublime Text snippet to insert a Radius comment for CleanSlate.
View rcomment.sublime-snippet
<snippet>
<!-- Snippet to insert a radius comment for CleanSlate. -->
<content><![CDATA[
<r:comment>
<!-- ${1: } -->
</r:comment>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>rcomment</tabTrigger>
<description>Insert an r:comment tag for CleanSlate</description>
@adamjohnson
adamjohnson / bracket.sublime-snippet
Created Nov 28, 2017
CSS Bracket Expander Sublime Text Snippet
View bracket.sublime-snippet
<snippet>
<!-- Type `bracket` and hit tab to open a bracket with a closing comment. -->
<!-- Type the class for the element you are styling and it is placed at the top and in the comment after the closing bracket -->
<!-- Hit tab a second time to put your cursor into a beautifuly tabbed spot within the bracket -->
<!-- https://webdevstudios.com/2016/08/16/snippets-saved-life-how-sublime-text-3-snippets-changed-everything/ -->
<content><![CDATA[
.${1:example} {
${2:Type a class then hit tab!}
} //.${1:example}
]]></content>
@adamjohnson
adamjohnson / sublime-packages.md
Last active Dec 11, 2020
My Sublime Text Packages
View sublime-packages.md

My Sublime Text 3 Packages

As of 12/11/2020

  • Align Tab
  • All Autocomplete
  • Better CoffeeScript
  • Bootstrap 4x Autocomplete
  • BracketHighlighter
  • Default File Type