Skip to content

Instantly share code, notes, and snippets.

View completejavascript's full-sized avatar

Lam Pham completejavascript

View GitHub Profile
@completejavascript
completejavascript / install-gcc-g++-ubuntu-14.04
Created January 4, 2018 02:26
Install gcc & g++ 5.x on Ubuntu 14.04
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-5
sudo rm -f /usr/bin/gcc
sudo rm -f /usr/bin/g++
sudo ln -s /usr/bin/gcc-5 /usr/bin/gcc
sudo ln -s /usr/bin/g++-5 /usr/bin/g++
@completejavascript
completejavascript / install-certificate-ubuntu
Created January 4, 2018 03:57
Install Certificate on Ubuntu
# Installing a root/CA Certificate
# Given a CA certificate file foo.crt, follow these steps to install it on Ubuntu:
# Create a directory for extra CA certificates in /usr/share/ca-certificates:
sudo mkdir /usr/share/ca-certificates/extra
#Copy the CA .crt file to this directory:
sudo cp foo.crt /usr/share/ca-certificates/extra/foo.crt
#Let Ubuntu add the .crt file's path relative to /usr/share/ca-certificates to /etc/ca-certificates.conf:
sudo dpkg-reconfigure ca-certificates
@completejavascript
completejavascript / TintColor-v2.js
Last active May 15, 2018 03:37
Create Tint Color for Images Using JavaScript.
class TintColor {
constructor(_srcImage, _tintColor) {
this._srcImage = _srcImage;
this._tintColorArray = this._getRGBAArray(_tintColor);
}
setSourceImage(_srcImage) {
this._srcImage = _srcImage;
return this;
}
setTintColor(_tintColor) {
@completejavascript
completejavascript / active-network-interface-manually-arch-linux
Created January 10, 2018 02:34
Enabling and disabling network interfaces in Arch Linux
# You can activate a network interface using:
ip link set <interface> up
Example:
ip link set enp0s3 up
# To deactivate it do:
ip link set <interface> down
Example:
ip link set enp0s3 down
@completejavascript
completejavascript / netctl-configure-dhcp-arch-linux
Created January 10, 2018 02:36
Configuration a DHCP connection in Arch Linux
# Copying the /etc/netctl/examples/ethernet-dhcp example profile to /etc/netctl.
Interface=enp3s0
Connection=ethernet
IP=dhcp
@completejavascript
completejavascript / service-worker-sample.js
Created January 12, 2018 02:35
Basic sample of Service Worker
/*
Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
@completejavascript
completejavascript / NinePatch-v2.js
Last active May 15, 2018 03:36
Scale nine patch image using JavaScript's canvas
class NinePatch {
// New version
scaleImage(srcImg, newWidth, newHeight) {
return new Promise((resolve, reject) => {
// Load 9patch from background-image
this.bgImage = new Image();
this.bgImage.crossOrigin = "Anonymous";
this.bgImage.src = srcImg;
this.bgImage.onload = () => {
@completejavascript
completejavascript / SimpleIndexedDB-v2.js
Last active May 15, 2018 03:35
Simple IndexDB's wrapper using JavaScript Promise.
//prefixes of implementation that we want to test
window.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
//prefixes of window.IDB objects
//IDBTransaction interface of the IndexedDB API provides a static, asynchronous transaction on a database using event handler attributes.
window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || window.msIDBTransaction;
window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange || window.msIDBKeyRange;
if (!window.indexedDB) {
window.alert("Your browser doesn't support a stable version of IndexedDB.");
@completejavascript
completejavascript / overlay-toggle-menu-index.html
Last active January 26, 2018 08:30
Simple Overlay Toggle Menu using jQuery
<div class="container">
<a href="#" class="toggle-menu">Toggle Menu</a>
<div class="overlay hidden">
<ul>
<li>
<a href="#">Menu 1</a>
</li>
<li>
<a href="#">Menu 2</a>
</li>
@completejavascript
completejavascript / grid.css
Last active February 23, 2018 15:54
A Responsive Design CSS Library
/* The padding and border are included in the total width and height of the elements. */
* {box-sizing: border-box;}
/* Mobile first */
/* Define width of col- */
.gr-col-xs-1 {width: 8.33%;}
.gr-col-xs-2 {width: 16.66%;}
.gr-col-xs-3 {width: 25%;}
.gr-col-xs-4 {width: 33.33%;}
.gr-col-xs-5 {width: 41.66%;}