Skip to content

Instantly share code, notes, and snippets.

View chlab's full-sized avatar

Christof Leuenberger chlab

View GitHub Profile
@chlab
chlab / README.md
Last active April 28, 2021 09:48
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.
@chlab
chlab / element_ui_flexbox_forms.sass
Last active November 29, 2017 09:18
Element UI Flexbox forms
/**
* Override element ui styles to make their forms use flexbox for:
* - positioning form labels and input fields next to each other without fixed widths
* - grouping fields like zip / city
*
* The former is done automatically. For the latter, just apply .el-form-item--grouped
* to the <el-form-item> element. Then you can add multiple <el-input> elements to it.
* Add .el-input--expanded to the <el-input> you want to expand (use up the remaining space).
*
* Example:
// in webpack.config.js
module: {
loaders: [
{
test: require.resolve('blueimp-bootstrap-image-gallery/js/bootstrap-image-gallery'),
loader: 'imports?define=>false,blueimp=blueimp-gallery'
},
{
test: require.resolve('blueimp-gallery'),
loader: 'imports?define=>false'
@chlab
chlab / git_changed_files.sh
Last active September 11, 2015 12:44
Git: show all files you changed between two git commits
#!/bin/sh
# get git user from git config
gituser="$(git config user.email)"
# tell user how to set git user if we didn't get one
if [ -z "$gituser" ]; then
echo "Please configure your git user:"
echo "git config --global user.name \"your name\""
echo "git config --global user.email \"your email\""
@chlab
chlab / Smart_Sitewide_Notices_Widget.class.php
Last active August 29, 2015 14:14
Smarter BuddyPress sitewide notices widget that doesn't display the widget when there are no notices to show
<?php
/**
* Smarter version of the buddypress sitewide notices widget
*
* Fetches the notices in an output buffer and does not display widget when
* there is no content to display.
*
* Sadly this widget is necessary because buddypress only finds out if there
* are notices to be displayed while displaying them.
*
@chlab
chlab / kalandae_diff.js
Last active December 23, 2015 10:39
This diff describes the changes necessary to get Kalendae to work in IE7.
@@ -12,7 +12,6 @@
var today;
var Kalendae = function (targetElement, options) {
- if (typeof document.addEventListener !== 'function' && !util.isIE8()) return;
//if the first argument isn't an element and isn't a string, assume that it is the options object
var is_element = false;
@@ -574,10 +573,19 @@
},
<?php
/**
* Parse raw HTTP request data
*
* Pass in $a_data as an array. This is done by reference to avoid copying
* the data around too much.
*
* Any files found in the request will be added by their field name to the
* $data['files'] array.
*