Skip to content

Instantly share code, notes, and snippets.

View oshliaer's full-sized avatar
😼
Cat face with wry smile

Alex Ivanov oshliaer

😼
Cat face with wry smile
View GitHub Profile
@zcaceres
zcaceres / Revealing-Module-Pattern.md
Last active September 2, 2026 16:30
Using the Revealing Module Pattern in Javascript

The Revealing Module Pattern in Javascript

Zach Caceres

Javascript does not have the typical 'private' and 'public' specifiers of more traditional object oriented languages like C# or Java. However, you can achieve the same effect through the clever application of Javascript's function-level scoping. The Revealing Module pattern is a design pattern for Javascript applications that elegantly solves this problem.

The central principle of the Revealing Module pattern is that all functionality and variables should be hidden unless deliberately exposed.

Let's imagine we have a music application where a musicPlayer.js file handles much of our user's experience. We need to access some methods, but shouldn't be able to mess with other methods or variables.

Using Function Scope to Create Public and Private Methods

@oshliaer
oshliaer / .how_to_concatenate_ranges_in_google_spreadsheets.md
Last active July 14, 2024 09:54
How to concatenate ranges in Google spreadsheets

How to concatenate ranges in Google spreadsheets

Unsplash

Sometimes it is necessary to concat ranges in Google Spreadsheet. Eg, Data 1 and Data 2

Sheet Data 1

Name Date Sum
Ethan 3/4/2017 31
@LindaLawton
LindaLawton / GoogleAuthenticationCurl.sh
Last active April 16, 2026 23:15
Curl bash script for getting a Google Oauth2 Access token
# Tutorial https://www.daimto.com/how-to-get-a-google-access-token-with-curl/
# YouTube video https://youtu.be/hBC_tVJIx5w
# Client id from Google Developer console
# Client Secret from Google Developer console
# Scope this is a space seprated list of the scopes of access you are requesting.
# Authorization link. Place this in a browser and copy the code that is returned after you accept the scopes.
https://accounts.google.com/o/oauth2/auth?client_id=[Application Client Id]&redirect_uri=http://127.0.0.1&scope=[Scopes]&response_type=code
# Exchange Authorization code for an access token and a refresh token.
@baweaver
baweaver / ruby_books.md
Last active July 31, 2026 15:07
A list of books for learning and expanding on your Ruby knowledge.

Ruby Book List

Learning Ruby

You're taking your first steps into Ruby

A good introduction to programming in general. Easy on newer programmers.

@mihow
mihow / load_dotenv.sh
Last active August 21, 2026 12:45
Load environment variables from dotenv / .env file in Bash
# The initial version
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
# My favorite from the comments. Thanks @richarddewit & others!
set -a && source .env && set +a
@rudimusmaximus
rudimusmaximus / queryASpreadsheet.gs
Last active February 9, 2025 15:40
Follow up to Totally UnScripted Episode 3: SQL like queries in Google Apps Script
/**
* quickly test our function
*/
function test(){
var result = queryASpreadsheet('1sPevvtTMSd9LUptX8qdsw4VJf07nOal_1qn9JLwO4fQ',
'Example Data',
'A1:C',
'SELECT A,B,C WHERE B < 7');
var rows = result.length;//7
@oshliaer
oshliaer / .functional_separation_principle.ru.md
Last active September 11, 2024 13:27
Принцип разделения функциональности (в табличных процессорах)

Принцип разделения функциональности (в табличных процессорах)

Unsplash

ПРФ (в электронных таблицах) - предложение не использовать смешение функций табличных процессоров (ТП). Если разделить функции ТП на хранение, обработку и представление, то можно значительно упростить использование и расширить функционал рабочей модели, которую обслуживает ТП. Самый простой способ достижения этого - использовать правило: "одна функция - один лист". Например, для Таблицы Гугл, которая получает данные из Формы, функцию хранения выполняет лист, привязанный к Форме. Если необходимо как-то модифицировать данные, то необходимо использовать второй лист, для обработки. Если требуется распечатать или вывести на экран в читаемом виде текущие данные, то необходимо использовать третий лист - представление.

Следствие #1

Следствием применения принципа является рекомендация не использовать в одном файле (структурной единице р

@Valtervieira
Valtervieira / emailfetcher.js
Created October 18, 2016 17:16
Gmail-Sheets
https://developers.google.com/apps-script/reference/gmail/gmail-message
https://ctrlq.org/code/20053-save-gmail-to-google-spreadsheet
var SEARCH_QUERY = "label:inbox";
// Credit: https://gist.github.com/oshliaer/70e04a67f1f5fd96a708
function getEmails_(q) {
var emails = [];
var threads = GmailApp.search(q);
@tzmartin
tzmartin / embedded-file-viewer.md
Last active August 24, 2026 14:13
Embedded File Viewer: Google Drive, OneDrive

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')

http://view.officeapps.live.com/op/view.aspx?src=[OFFICE_FILE_URL]

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>
</iframe>

OneDrive Embed Links

@erickoledadevrel
erickoledadevrel / UnmergedRanges.gs
Last active September 11, 2025 10:33
[Apps Script] Getting the unmerged ranges within a range
/**
* Gets all the unmerged ranges within a range.
* @param {SpreadsheetApp.Range} range The range to evaluate.
* @returns {SpreadsheetApp.Range[]} The unmerged ranges.
*/
function getUnmergedRanges(range) {
if (!range.isPartOfMerge()) {
return [range];
}
var mergedRanges = range.getMergedRanges();