Skip to content

Instantly share code, notes, and snippets.

View Adrian-Samuel's full-sized avatar
🎯
Focusing

Adrian Samuel Adrian-Samuel

🎯
Focusing
View GitHub Profile
@Adrian-Samuel
Adrian-Samuel / twilio_reponse_extractor.sh
Last active December 30, 2020 21:03
A script to extract all the responses to a certain number to a spreadsheet using the twilio cli
#! /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 December 29, 2020 21:15
javascript (app script) to provide live validation on length of sms message within a given cell
function onEdit({source, range}) {
const {
columnStart,
rowStart
} = range
const nextCellR1C1Notation = `R${rowStart}C${columnStart + 1}`
if (columnStart == 3) {
{% 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>
const getBaseDescription = async() =>{
const baseURL = window.location.origin
const [accountID, itemID] = window.location.href.match(/\d+/g)
const descriptionNode = document.querySelector('.description')
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) => {
package main
import (
"fmt"
)
//Option 1
func recursiveLoop(list []int, currentIndex int) {
if !(currentIndex == len(list)) {
fmt.Println(list[currentIndex])
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 {
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 April 1, 2020 22:32
Script to find bible all names in passages of text
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) => {
// 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()