Skip to content

Instantly share code, notes, and snippets.

ramons03 /
Created Oct 24, 2019 — forked from chlab/
vue webpack boilerplate: how to add env-specific build targets

When using the vue-webpack-boilerplate, you will have only a production build by default (besides dev and test setups). My team often has at least another environment we call "staging" where the client can test new features before we move them to production. Oftentimes, these environments will have env-specific config values, like a different API URL.

With the changes outlined below, you can create a separate config per environment. This assumes you've created a Vue.js project with vue-webpack-boilerplate.

  1. Apply the changes to the corresponding files in your project as outlined below
  2. Now, when you run npm run build staging it will build your project with the config values specific to your staging environment. You can easily add any number of other environments and build them the same way. npm run build or npm run build production will still build your production environment.
ramons03 / simplejsexportcsv.js
Created Aug 1, 2019
Export to csv from javascript.
View simplejsexportcsv.js
function downloadFile(fileName, urlData) {
console.log('downloadFile', fileName);
var aLink = document.createElement('a');
var evt = document.createEvent("HTMLEvents");
evt.initEvent("click"); = fileName;
aLink.href = urlData;
View detect-objects.js
import * as cocoSsd from "@tensorflow-models/coco-ssd";
const image = document.getElementById("image")
.then(model => model.detect(image))
.then(predictions => console.log(predictions))
View VisualStudio.gitignore
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
## Get latest from
# User-specific files
ramons03 / linqlambda.cs
Created May 31, 2017
LINQ async options with lambda using whenall
View linqlambda.cs
var tasks = foos.Select(DoSomethingAsync).ToList();
await Task.WhenAll(tasks);
var results = await Task.WhenAll(tasks);
return await Task.WhenAll(tasks);
var tasks = foos.Select(foo => DoSomethingAsync(foo)).ToList();
ramons03 / uncheckall.js
Created Mar 7, 2017
Uncheck all checkbox in javascript console.
View uncheckall.js
var allInputs = document.getElementsByTagName("input");
for (var i = 0, max = allInputs.length; i < max; i++){
if (allInputs[i].type === 'checkbox')
allInputs[i].checked = false;
ramons03 / massrename.bat
Created Jan 11, 2017
Mass rename files windows command prompt
View massrename.bat
REM dir / -B > fileList.txt
REM for /f "tokens=1,2,3" %i in (fileList.txt) DO ren "%i %j %k" %k
for /f "tokens=1,2,3" %i in ('dir / -B') DO ren "%i %j %k" %k
ramons03 / yearupdate.sql
Last active Jan 11, 2017
Change Year only to a date column in SQL.
View yearupdate.sql
--SQL Server
UPDATE table SET DateToModify = DATEADD(YEAR, -1, DateToModify)
where YEAR(DateToModify) = 2015
UPDATE table SET DateToModify = DATE_ADD(DateToModify, INTERVAL 1 YEAR)
where YEAR(DateToModify) = 2015
ramons03 / flashtitle.js
Last active Jan 11, 2017
Flashing HTML Title Script
View flashtitle.js
(function () {
var original = document.title;
var timeout;
var defaultTimes = 5;
window.flashTitle = function (newMsg, howManyTimes) {
function step() {
document.title = (document.title == original) ? newMsg : original;
ramons03 / 1x1transparentgif.html
Last active Jan 4, 2017
Base64 Encode of 1x1px Transparent GIF
View 1x1transparentgif.html
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=">