Skip to content

Instantly share code, notes, and snippets.

Maciej Matuszewski maciejmatu

Block or report user

Report or block maciejmatu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View lamp-algorithm.md

Simplified lamp software algorithm

  1. Define constants for pins e.g. #define LED_RED 9
  2. Instantiate hueRotart, saturationRotary and bluetooth software serial
  3. Run void setup() { ... }
    1. Run startup sequence R => G => B => GB => RB => RG => RGB (helps with checking if colors are hooked up correctly
    2. Begin listening for bluetooth serial on 9600 rate
    3. Begin listening for hueRotatary and saturationRotary
    4. Setup brightness controls pins VALUE_INCREASE and VALUE_DECREASE to INPUT_PULLUP to avoid faulty readings
  4. Run void loop() { ... } in loop
View lamp-materials.csv
item price description
Concrete 25 PLN (~7$) 5 kilograms of fast-dry (1h) concrete. We used about one-third of it.
Wood 40 PLN (~10$) I bought some low-quality pine planks, which we later painted. I recommend investing a bit more in a better type of wood if you can.
MOSFET x 3 4.50 PLN (~1.20$) Model: N-MOSFET IRFZ44N - THT
5V Stabilizer x 1 1.5 PLN (~0.40$)
ATmega328 x 1 12 PLN (~3.23$) Model: ATmega328P-U DIP AVR
Rotary Encoder x 2 6.60 PLN (~1.80$) With pressable button, 20-pulse 12mm - EC11 vertical
Knob for Encoder x 2 2.40 PLN (~0.70$) model: GCL15 silver - 6/15mm
Power Supply x 1 8.90 PLN (~2.40$) model: 12V / 1,4A - DC 5,5 / 2,5mm
DC Socket 5.5x2.1 mm 1 PLN (~0.30$)
@maciejmatu
maciejmatu / slack-webtask.js
Created Feb 28, 2019
Simple server-less slack webtask
View slack-webtask.js
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);
@maciejmatu
maciejmatu / inky-temlate.html
Created May 28, 2018
Example inky email template
View inky-temlate.html
<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 / template.mjml
Last active May 26, 2018
Example MJML email template
View template.mjml
<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 / add-page-visit.js
Created May 3, 2018
Lambda function that connects to mongo database and increments a number
View add-page-visit.js
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 / email-response.js
Created May 3, 2018
Lambda function I use for email auto-response with Netlify forms.
View email-response.js
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 / config.yml
Created May 3, 2018
Example netlify-cms config.yml file, I used for my 'smoothielicious' project.
View config.yml
backend:
name: git-gateway
branch: master
media_folder: static/img
public_folder: /img
collections:
- name: "blog"
label: "Blog"
View expo-sound-api.js
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!
}
View react-native-audio.js
import { AudioRecorder, AudioUtils } from 'react-native-audio';
let audioPath = AudioUtils.DocumentDirectoryPath + '/test.aac';
AudioRecorder.prepareRecordingAtPath(audioPath, {
SampleRate: 22050,
Channels: 1,
AudioQuality: "Low",
AudioEncoding: "aac"
});
You can’t perform that action at this time.