Skip to content

Instantly share code, notes, and snippets.

View maciejmatu's full-sized avatar
🌵

Maciej Matuszewski maciejmatu

🌵
View GitHub Profile
import Sound from 'react-native-sound';
const sound = new Sound('http://sounds.com/some-sound', null, (error) => {
if (error) {
// do something
}
// play when loaded
sound.play();
});
import Video from 'react-native-video';
// From documentation
<Video source={{uri: "background"}} // Can be a URL or a local file.
ref={(ref) => {
this.player = ref
}} // Store reference
rate={1.0} // 0 is paused, 1 is normal.
volume={1.0} // 0 is muted, 1 is normal.
muted={false} // Mutes the audio entirely.
import { AudioRecorder, AudioUtils } from 'react-native-audio';
let audioPath = AudioUtils.DocumentDirectoryPath + '/test.aac';
AudioRecorder.prepareRecordingAtPath(audioPath, {
SampleRate: 22050,
Channels: 1,
AudioQuality: "Low",
AudioEncoding: "aac"
});
const soundObject = new Expo.Audio.Sound();
try {
await soundObject.loadAsync(require('./assets/sounds/hello.mp3'));
await soundObject.playAsync();
// Your sound is playing!
} catch (error) {
// An error occurred!
}
@maciejmatu
maciejmatu / config.yml
Created May 3, 2018 17:50
Example netlify-cms config.yml file, I used for my 'smoothielicious' project.
backend:
name: git-gateway
branch: master
media_folder: static/img
public_folder: /img
collections:
- name: "blog"
label: "Blog"
@maciejmatu
maciejmatu / email-response.js
Created May 3, 2018 21:01
Lambda function I use for email auto-response with Netlify forms.
require("dotenv").config(); // read .env file if present.
const nodemailer = require("nodemailer");
const createHtmlMail = require("./modules/mail-template"); // this function returns html email code
exports.handler = function(event, context, callback) {
const user = process.env.MAIL_USER; // some@mail.com
const pass = process.env.MAIL_PASSWORD; // 42isthecoolestnumber
let transporter = nodemailer.createTransport({
@maciejmatu
maciejmatu / add-page-visit.js
Created May 3, 2018 21:24
Lambda function that connects to mongo database and increments a number
const { MongoClient } = require('mongodb');
const DB_URL = process.env.DB_URL || 'mongodb://localhost:27017';
const DB_NAME = 'serverless-smoothielicious';
function errorResponse(callback, err) {
console.error(err);
callback(null, {
statusCode: 500,
@maciejmatu
maciejmatu / template.mjml
Last active May 26, 2018 20:00
Example MJML email template
<mjml>
<mj-head>
<mj-title>My Title</mj-title>
<mj-attributes>
<mj-class
name="text"
font-family="Open Sans, Arial"
color="#111111"
font-size="16px"
line-height="26px">
@maciejmatu
maciejmatu / inky-temlate.html
Created May 28, 2018 09:48
Example inky email template
<container>
<style>
.columns {
border: 1px solid #333;
}
</style>
<row>
<columns small="6" large="4">4 columns, 6 columns on small</columns>
<columns small="6" large="8">8 columns, 6 columns on small</columns>
@maciejmatu
maciejmatu / slack-webtask.js
Created February 28, 2019 23:42
Simple server-less slack webtask
const { WebClient } = require('@slack/client');
const fetch = require("node-fetch");
const API_URL = 'http://ron-swanson-quotes.herokuapp.com/v2/quotes';
const CHANNEL_ID = 'D6X9SM885';
module.exports = async (context, cb) => {
const [quote] = await fetch(API_URL).then(res => res.json());
const { chat } = new WebClient(context.secrets.SLACK_TOKEN);