Skip to content

Instantly share code, notes, and snippets.

View mb8z's full-sized avatar
🎯
Focusing

mb8z mb8z

🎯
Focusing
  • Freelance
  • Warsaw, Poland
View GitHub Profile
import _ from 'lodash';
export default {
getItem: (key, defaultValue) => {
if (typeof localStorage === 'undefined') return null;
const value = localStorage.getItem(key);
return _.isNil(value) ? defaultValue : JSON.parse(value);
},
setItem: (key, data) => {
if (typeof localStorage === 'undefined') return null;
@mb8z
mb8z / setFavorites.py
Last active December 6, 2020 01:19
Python script for adding folders to favorites on macOS (.sfl and .sfl2 compatible)
# Example usage:
# NOTE: Please mind the trailing slashes at the end of the path names!!!
# Supports multiple files per attribute (pass them after a space - see `--add` example below:
# Examples:
# Adding: `python setFavorites.py --add file:///Users/your_username/your/path/ file:///Users/your_username/your/another_path/`
# Removing: `python setFavorites.py --remove file:///Users/your_username/your/path/`
#!/usr/bin/python
import os
import Services from 'tripetto-services';
import { Export } from 'tripetto-runner-foundation';
import { run } from 'tripetto-runner-autoscroll';
const token = 'my-token-here';
const config = Services.init({ token });
// Picking params as spreaing the `config` does not work properly
const params = _.pick(config, ['definition', 'styles', 'l10n', 'locales', 'translations', 'attachments']);
const element = document.getElementById('my-tripetto-form');
run({
const automagically = require('automagically');
const testEmails = async () => {
const data = await automagically.emails.send({
to: '[email protected]',
from: '[email protected]',
body: 'Hello, world!',
});
console.log(data);
};
@mb8z
mb8z / am-emails-text-one-recipient.js
Last active March 3, 2021 17:24
Sending an email to one recipient
const { Emails } = require('automagically');
const send = async () => {
const email = Emails.send({
from: { email: '[email protected]', name: 'AwesomeApp' },
to: [{ email: '[email protected]', name: 'John Doe' }],
subject: 'Welcome',
text: 'Hey there, this is a test email!',
});
};
@mb8z
mb8z / am-emails-text-one-recipient-bccs-ccs.js
Last active March 3, 2021 17:24
Sending an email to one recipient with bccs and ccs
const { Emails } = require('automagically');
const send = async () => {
const email = Emails.send({
from: { email: '[email protected]', name: 'AwesomeApp' },
to: [{ email: '[email protected]', name: 'John Doe' }],
bcc: [{ email: '[email protected]', name: 'Kylo Ren' }],
cc: [{ email: '[email protected]', name: 'Leia' }],
subject: 'Welcome',
text: 'Hey there, this is a test email!',
@mb8z
mb8z / am-emails-text-multiple-recipients.js
Last active March 3, 2021 17:24
Sending an email to multiple recipients
const { Emails } = require('automagically');
const send = async () => {
const email = Emails.send({
from: { email: '[email protected]', name: 'AwesomeApp' },
to: [
{ email: '[email protected]', name: 'John Doe' },
{ email: '[email protected]', name: 'Foo Bar' },
],
subject: 'Welcome',
@mb8z
mb8z / am-emails-text-multiple-recipients-variables.js
Created March 3, 2021 17:24
Sending an email to multiple recipients with variables
const { Emails } = require('automagically');
const send = async () => {
const email = Emails.send({
from: { email: '[email protected]', name: 'AwesomeApp' },
to: [
{ email: '[email protected]', name: 'John Doe', age: 20 },
{ email: '[email protected]', name: 'Foo Bar', age: 30 },
],
subject: 'Welcome {{name}} – it\'s your birthday!',
@mb8z
mb8z / am-emails-template-multiple-recipients.js
Created March 3, 2021 17:25
Sending an email to multiple recipients
const { Emails } = require('automagically');
const send = async () => {
const email = Emails.send({
from: { email: '[email protected]', name: 'AwesomeApp' },
to: [
{ email: '[email protected]', name: 'John Doe', age: 30 },
{ email: '[email protected]', name: 'Foo Bar', age: 20 },
],
template: 'my-sendgrid-template-id-here',
# Some python code here