Skip to content

Instantly share code, notes, and snippets.

const axios = require('axios');
const { GarminConnect } = require('garmin-connect');
const GCClient = new GarminConnect();
const getExistingActivities = async () => {
const existingActivityIds = []
const activities = await axios.get(`${process.env.HOST}/activities`)
activities.data.map((activity) => {
existingActivityIds.push(activity.activityId)
@mjurincic
mjurincic / tmux_iterm_scrollback.md
Created June 28, 2024 13:35 — forked from drofp/tmux_iterm_scrollback.md
Tmux iterm integration tips and best practices

Change scrollback limit for tmux buffer on iterm

Original stackoverflow post here

Solution

  • iTerm2 build 1.0.0.20130302 has an preference which enables it to capture scrollback even when a so-called hard status line is present:
  • maybe also check "Save lines to scrollback in alternate screen mode"
@mjurincic
mjurincic / get-form-validation-errors.ts
Created June 27, 2021 16:00 — forked from JohannesHoppe/get-form-validation-errors.ts
Get all validation errors for Angular FormGroup
import { FormGroup, ValidationErrors } from '@angular/forms';
export function getFormValidationErrors(form: FormGroup) {
const result = [];
Object.keys(form.controls).forEach(key => {
const controlErrors: ValidationErrors = form.get(key).errors;
if (controlErrors) {
Object.keys(controlErrors).forEach(keyError => {
@mjurincic
mjurincic / lambda-gmail-compose.md
Created May 4, 2021 08:22 — forked from AnalyzePlatypus/lambda-gmail-compose.md
Use serverless function to send low-volume emails without 3rd party mail services.

Sending email with serverless functions

You can deploy this function on any of the serverless platforms - AWS Lambda, Google Cloud Functions, Azure Functions, Netlify, Cloudflare Workers, etc.

  1. Create a new function and paste in the following code.
  2. You will need to add nodemailer to your package.json (npm i nodemailer), and follow your platform's instructions on bundling dependencies.
  3. Obtain Gmail API credentials for your account. You will need clientID, clientSecret, and refreshToken. Follow this YouTube tutorial
  4. Expose these credentials as the follwing environment variables:
GMAIL_EMAIL_ADDRESS
@mjurincic
mjurincic / cors.md
Created April 2, 2021 08:44 — forked from jesperorb/cors.md
Handle CORS Client-side

Handle CORS Client-side

Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources (e.g. fonts) on a web page to be requested from another domain outside the domain from which the first resource was served. This is set on the server-side and there is nothing you can do from the client-side to change that setting, that is up to the server/API. There are some ways to get around it tho.

Sources : MDN - HTTP Access Control | Wiki - CORS

CORS is set server-side by supplying each request with additional headers which allow requests to be requested outside of the own domain, for example to your localhost. This is primarily set by the header:

Access-Control-Allow-Origin
@mjurincic
mjurincic / findManyCursor.test.ts
Created April 21, 2020 12:34 — forked from ctrlplusb/findManyCursor.test.ts
Utility to provide Relay Cursor Connection Specification support to Prisma Framework
import { Country, Photon } from '@prisma/photon';
import { findManyCursor } from './findManyCursor';
const photon = new Photon();
let data: Country[];
const createCountry = async (id: string) => photon.countries.create({
data: {
id,
@mjurincic
mjurincic / findManyCursor.test.ts
Last active April 21, 2020 12:34 — forked from ctrlplusb/findManyCursor.test.ts
Utility to provide Relay Cursor Connection Specification support to Prisma Framework
import { Country, Photon } from '@prisma/photon';
import { findManyCursor } from './findManyCursor';
const photon = new Photon();
let data: Country[];
const createCountry = async (id: string) => photon.countries.create({
data: {
id,
<?
/////////////////////
// slack2html
// by @levelsio
/////////////////////
//
/////////////////////
// WHAT DOES THIS DO?
/////////////////////
//
@mjurincic
mjurincic / .htaccess
Created April 10, 2020 10:06 — forked from joshhartman/.htaccess
SSL Proxy Redirect to HTTPS (compatible with Network Solutions web hosting)
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
@mjurincic
mjurincic / sitemap.xml.tsx
Created March 18, 2020 11:48 — forked from henninghall/sitemap.xml.tsx
sitemap.xml in next.js which is easy to extend with dynamic routes
// place in pages/sitemap.xml.tsx
const fs = require('fs')
import { endpoint } from '../config'
const Sitemap = () => null
Sitemap.getInitialProps = async ({ res }) => {
if (!res) return {}
const folder = 'pages'
res.setHeader('content-type', 'application/xml')