Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Adrian Samuel Adrian-Samuel

🎯
Focusing
View GitHub Profile
@Adrian-Samuel
Adrian-Samuel / twilio_reponse_extractor.sh
Last active Dec 30, 2020
A script to extract all the responses to a certain number to a spreadsheet using the twilio cli
View twilio_reponse_extractor.sh
#! /bin/bash
read -p "Please enter in the full number " assignedNumber
smsExportFile="$assignedNumber"_Responses_$(date +'%Y-%m-%d')".csv"
twilio api:core:messages:list --to=$number --properties=body,from,dateSent -o=tsv > $smsExportFile
# no need to custom parse the JSON
@Adrian-Samuel
Adrian-Samuel / smsLengthValidator.js
Last active Dec 29, 2020
javascript (app script) to provide live validation on length of sms message within a given cell
View smsLengthValidator.js
function onEdit({source, range}) {
const {
columnStart,
rowStart
} = range
const nextCellR1C1Notation = `R${rowStart}C${columnStart + 1}`
if (columnStart == 3) {
View displayCustomerNumber.twig
{% set contactNumber = "" %}
{% for contact in Sale.Customer.Contact.Phones.ContactPhone %}
{% if contact.number != "" and contactNumber == "" %}
{% set contactNumber = contact.number %}
{% endif %}
{% endfor %}
<span> Customer Number: {{contactNumber}} </span>
View matrixAttributeBaseName.js
const getBaseDescription = async() =>{
const baseURL = window.location.origin
const [accountID, itemID] = window.location.href.match(/\d+/g)
const descriptionNode = document.querySelector('.description')
View birthdayScript.js
function birthdayMessage() {
const sheet = SpreadsheetApp.openById("someID");
const [headers, ...birthdays] = sheet.getDataRange().getValues();
// removing rows without dates
const cleanedList = birthdays.filter(([,date]) => date != "")
const todaysBirthdays = cleanedList.reduce((matchedBirthdays, currentBirthday) => {
View recursiveLoop.go
package main
import (
"fmt"
)
//Option 1
func recursiveLoop(list []int, currentIndex int) {
if !(currentIndex == len(list)) {
fmt.Println(list[currentIndex])
View getImageURLsfromDrive.js
function getImages() {
const sheet = SpreadsheetApp.openById(ID);
const db = DriveApp.getFolderById(ID)
const dbFiles = db.getFiles();
while (dbFiles.hasNext()) {
const file = dbFiles.next()
const driveURL = file.getUrl()
const {
View randomNumberWithExlcusionList.js
function getRandomNumber(min, max, blockList) {
const randomNumber = Math.floor(Math.random() * (max - min + 1)) + min;
if (blockList.includes(randomNumber)) return getRandomNumber(min, max, blockList)
return randomNumber
}
// Example on how to use
@Adrian-Samuel
Adrian-Samuel / BibleNameFinder.js
Last active Apr 1, 2020
Script to find bible all names in passages of text
View BibleNameFinder.js
const getMatchingBibleBooks = async (passage) => {
const bibleSite = "https://www.biblegateway.com/passage/bbl/?version=NKJV&locale=en"
if (window.location.href != bibleSite) window.location.href = bibleSite
const getPage = await fetch(bibleSite)
const getJSONPage = await getPage.json()
const bibleBooks = getJSONPage.testaments.reduce((bookNames, currentTestament) => {
View csv2json.gs
// Function to insert into script for a google sheet to convert the rows into a JSON API
// Step 1: Add the records to the spreadsheet
// Step 2: Add the script, authorise script and then publish to web
// Step 3: Use generate URL to get an API response
// Documentation for this process can be found here: https://developers.google.com/apps-script/guides/web
function getSheetData() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet()
var sheetData = sheet.getDataRange().getValues()