Skip to content

Instantly share code, notes, and snippets.

View bvjebin's full-sized avatar
🎯
Focusing

Jebin bvjebin

🎯
Focusing
View GitHub Profile
@bvjebin
bvjebin / create_zip.ex
Created August 31, 2018 13:48
Create zip in elixir for medium post
def create_zip(path) do
old_path = File.cwd!
File.cd! path
:zip.create("images.zip", ['images'], [{:cwd, path}])
File.cd! old_path
path<>"/images.zip"
end
@bvjebin
bvjebin / send_email.ex
Created August 31, 2018 14:01
send email with bamboo for medium post
def send_email(email, csv_path, zip_path) do
attachments = if !is_nil(zip_path) do
[Bamboo.Attachment.new(zip_path)]
else
[]
end
attachments = [Bamboo.Attachment.new(csv_path) | attachments]
new_email(attachments: attachments)
|> subject("Your download is here")
|> from("support@example.com")
@bvjebin
bvjebin / service_worker.js
Last active April 20, 2019 08:38
Medium article - service worker code
import * as routing from "workbox-routing";
import * as core from "workbox-core";
import * as strategies from "workbox-strategies";
import * as expiration from "workbox-cache-expiration";
import * as cacheableResponse from "workbox-cacheable-response";
self.addEventListener("sync", function (event) {
console.log("Event from sw: ", event);
});
self.addEventListener("install", function () {
@bvjebin
bvjebin / _app.jsx
Last active October 4, 2020 21:17
Medium article - service worker registration
import React from "react";
import App, { Container } from "next/app";
import { Provider } from "react-redux";
import MainLayout from "../components/Layouts/MainLayout";
class MyApp extends App {
static async getInitialProps({ Component, ctx }) {
return {}
}