If you have to extend an existing object with additional property, always prefer Vue.set()
over Object.assign()
(or spread operator).
Example below explains implications for different implementations.
export class cloneable { | |
public static deepCopy<T>(source: T): T { | |
return Array.isArray(source) | |
? source.map(item => this.deepCopy(item)) | |
: source instanceof Date | |
? new Date(source.getTime()) | |
: source && typeof source === 'object' | |
? Object.getOwnPropertyNames(source).reduce((o, prop) => { | |
Object.defineProperty(o, prop, Object.getOwnPropertyDescriptor(source, prop)!); | |
o[prop] = this.deepCopy((source as { [key: string]: any })[prop]); |
version: '2' | |
services: | |
grafana: | |
image: grafana/grafana:5.0.0 # or probably any other version | |
container_name: grafana | |
restart: always | |
environment: | |
- VIRTUAL_HOST=YOUR.DOMAIN.TEST # adjust to match your domain name | |
- VIRTUAL_PROTO=https |
package main | |
import( | |
"fmt" | |
"reflect" | |
) | |
func main() { | |
items := []int{1,2,3,4,5,6} | |
fmt.Println(SliceExists(items, 5)) // returns true |
cd ~ | |
apt-get install libfontenc1 xfonts-75dpi xfonts-base xfonts-encodings xfonts-utils openssl build-essential libssl-dev libxrender-dev git-core libx11-dev libxext-dev libfontconfig1-dev libfreetype6-dev fontconfig -y | |
#https://github.com/wkhtmltopdf/wkhtmltopdf/releases | |
#replace arch | |
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb | |
dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb | |
apt --fix-broken install |
sudo apt-get update | |
sudo apt-get install build-essential chrpath libssl-dev libxft-dev -y | |
sudo apt-get install libfreetype6 libfreetype6-dev -y | |
sudo apt-get install libfontconfig1 libfontconfig1-dev -y | |
cd ~ | |
export PHANTOM_JS="phantomjs-2.1.1-linux-x86_64" | |
wget https://github.com/Medium/phantomjs/releases/download/v2.1.1/$PHANTOM_JS.tar.bz2 | |
sudo tar xvjf $PHANTOM_JS.tar.bz2 | |
sudo mv $PHANTOM_JS /usr/local/share | |
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin |
#!/bin/bash | |
# Install PHP 5.6 (FPM) on Ubuntu 14.04 LTS | |
sudo add-apt-repository ppa:ondrej/php -y | |
sudo add-apt-repository ppa:ondrej/php5-compat -y | |
sudo apt-get update | |
sudo apt-get install php5.6 php5.6-fpm php5.6-curl php5.6-gd -y | |
# Change PHP FPM from socket to tcp connection. | |
sudo sed -i "s/^listen = \/run\/php\/php5.6-fpm.sock/;listen = \/run\/php\/php5.6-fpm.sock\nlisten = 127.0.0.1:9000/g" /etc/php/5.6/fpm/pool.d/www.conf | |
sudo service php5.6-fpm restart |
##Golang Type Switch - Arbitrary JSON Array Parsing I'm writing this mostly as a reference for myself. This could also be helpful to people who are new to GO.
####Note 1: Until Problem 3 we will assume we are dealing with a JSON for which we know the data types of key,value pairs. Only in Problem 3 we will look at how Type Switch is used to parse a 100% arbitary JSON
####Note 2: I know the following examples given here can be easily solved by declaring approprite structs and just decoding the PUT JSON into them, but, as im not able to come up with a better scenario, im going to stick with this to explain arbitrary JSON parsing.
/var/lib/redis/logs/redis.log { | |
daily | |
rotate 14 | |
copytruncate | |
delaycompress | |
compress | |
notifempty | |
missingok | |
} |
########################################## | |
# To run: | |
# curl -sSL https://gist.githubusercontent.com/sirkkalap/e87cd580a47b180a7d32/raw/d9c9ebae4f5cf64eed4676e8aedac265b5a51bfa/Install-Docker-on-Linux-Mint.sh | bash -x | |
########################################## | |
# Check that HTTPS transport is available to APT | |
if [ ! -e /usr/lib/apt/methods/https ]; then | |
sudo apt-get update | |
sudo apt-get install -y apt-transport-https | |
fi |