Skip to content

Instantly share code, notes, and snippets.

@tobkle
tobkle / index.js
Created May 15, 2021 15:15
create-vscode-packages-list
const {execSync, spawn} = require('child_process')
const result = execSync('code --list-extensions')
const list = String(result)
.split('\n')
.filter(Boolean)
.map(
x => `- [${x}](https://marketplace.visualstudio.com/items?itemName=${x})`
)
@tobkle
tobkle / now_secrets
Last active March 1, 2020 19:41
add, update, remove now secrets as script for zeit.co
#!/usr/bin/env node
/**
* Shell script reads now.json and .env.build files
* to add, update, remove Zeit.co now secrets
*
* Usage:
* ./now_secrets add
* ./now_secrets update
* ./now_secrets remove
*
@tobkle
tobkle / Mac OS X: Open in Visual Studio Code
Created December 9, 2019 19:13 — forked from tonysneed/Mac OS X: Open in Visual Studio Code
Add a command to Finder services in Mac OSX to open a folder in VS Code
- Open Automator
- File -> New -> Service
- Change "Service Receives" to "files or folders" in "Finder"
- Add a "Run Shell Script" action
- Change "Pass input" to "as arguments"
- Paste the following in the shell script box: open -n -b "com.microsoft.VSCode" --args "$*"
- Save it as something like "Open in Visual Studio Code"
@tobkle
tobkle / client->pages->payment.vue
Created December 8, 2019 13:32
client/pages/payment.vue
<template>
<!--MAIN-->
<main>
<!--PAYMENT-->
<div class="registerAddress mt-3">
<div class="container-fluid c-section">
<div class="row">
<div class="col-sm-3"></div>
<div class="col-sm-6">
<div class="a-section a-spacing-medium">
@tobkle
tobkle / client->store->index.js
Last active December 8, 2019 13:36
client/store/index.js
// State
export const state = () => ({
// Cart
cart: [],
cartLength: 0,
// Shipping
shipmentType: "",
shippingPrice: 0,
shippingEstimatedDelivery: ""
@tobkle
tobkle / server->routes->payment.js
Last active December 8, 2019 13:38
server/routes/payment.js
const router = require("express").Router()
const moment = require("moment")
const stripe = require("stripe")(process.env.STRIPE_SECRET_KEY)
const verifyToken = require("../middlewares/verify-token")
const Order = require("../models/order")
const Product = require("../models/product")
// SHIPMENT COSTS
const SHIPMENT = {
normal: {
@tobkle
tobkle / server->models->order.js
Last active December 8, 2019 13:40
server/models/order.js
const mongoose = require("mongoose")
const Schema = mongoose.Schema
const OrderSchema = new Schema({
owner: { type: Schema.Types.ObjectId, ref: "User" },
products: [
{
productID: { type: Schema.Types.ObjectId, ref: "Product" },
quantity: Number,
price: Number,
datasource db {
provider = "mysql"
url = "mysql://user:password@mysql.myserver.com:3306/mydb?sslmode=preferred"
default = true
}
generator photon {
provider = "photonjs"
}
@tobkle
tobkle / Google_Map_to_PNG.js
Last active May 18, 2020 11:15
Download Google Map as an PNG Image with Webix 6.4.3
/* Function to download a Google Map as an image file using Webix 6.4.3
* https://www.webix.com
* Solving this issue: Maps were downloaded with ugly white backgrounds or borders
* https://forum.webix.com/discussion/comment/25148#Comment_25148
* @author: Tobias Klemmer
* @date: 06.08.2019
*/
function Google_Map_to_PNG(viewId) {
// https://www.webix.com
@tobkle
tobkle / now.json
Created July 7, 2019 10:20 — forked from codeartistryio/now.json
Vue-Share Client Deployment
{
"version": 2,
"name": "vue-share",
"builds": [{ "src": "package.json", "use": "@now/static-build" }],
"routes": [
{ "src": "^/js/(.*)", "dest": "/js/$1" },
{ "src": "^/css/(.*)", "dest": "/css/$1" },
{ "src": "^/img/(.*)", "dest": "/img/$1" },
{ "src": ".*", "dest": "/index.html" }
]