Skip to content

Instantly share code, notes, and snippets.

View jpfong's full-sized avatar
🤓
coding

jpfong

🤓
coding
  • Montreal, Quebec
View GitHub Profile
@jpfong
jpfong / Confirm.vue
Created March 25, 2019 02:07 — forked from eolant/Confirm.vue
Vuetify Confirm Dialog component that can be used locally or globally
<template>
<v-dialog v-model="dialog" :max-width="options.width" @keydown.esc="cancel" v-bind:style="{ zIndex: options.zIndex }">
<v-card>
<v-toolbar dark :color="options.color" dense flat>
<v-toolbar-title class="white--text">{{ title }}</v-toolbar-title>
</v-toolbar>
<v-card-text v-show="!!message">{{ message }}</v-card-text>
<v-card-actions class="pt-0">
<v-spacer></v-spacer>
<v-btn color="primary darken-1" flat="flat" @click.native="agree">Yes</v-btn>
@jpfong
jpfong / delete-single-object-aws-s3.js
Last active December 2, 2017 19:56
Delete a single object in AWS S3.
var aws = require('aws-sdk');
var s3 = new aws.S3();
var params = {
Bucket: 'bucket',
Key: 'file.png' // if the file is a in a directory, the key would be: 'directory_name/file_name.ext'
};
s3.deleteObject(params, (err, data) => {
if (err) {
console.error(err)
@jpfong
jpfong / put-object-aws
Last active December 2, 2017 19:56
Put object in Amazon S3. Note: can only upload one file at a time
const aws = require('aws-sdk');
const s3 = new aws.S3();
var params = {
Bucket: 'bucket_name',
Key: 'file.png', // if you want to put in a directory, the key would be: 'directory_name/file_name.ext'
ACL: 'public-read', // to allow to access the file
Body: data // the data of the file
};
s3.putObject(params, (err, data) => {
@jpfong
jpfong / delete-aws-s3.js
Last active October 28, 2022 13:25 — forked from jeonghwan-kim/delete-aws-s3.js
delete multiple object in S3
var aws = require('aws-sdk');
var s3 = new aws.S3();
var params = {
Bucket: 'node-sdk-sample-7271',
Delete: { // required
Objects: [ // required
{
Key: 'foo.jpg' // required, if in a directory: 'directory_name/file.ext'
},
@jpfong
jpfong / numberDaysInMonth.js
Last active November 8, 2017 21:40
Get the number of days in a month
// will return the last day of the month = the number of days in a month
function daysInMonth(anyDateInMonth) {
return new Date(anyDateInMonth.getFullYear(), anyDateInMonth.getMonth() + 1, 0).getDate();
}
let dayInNovember2017 = new Date(2017, 10, 1); // 2017-11-01
console.log(daysInMonth(dayInNovember2017)); // 30 days