Skip to content

Instantly share code, notes, and snippets.

@kiennt2
kiennt2 / Sublime - replace domain of special files
Created August 2, 2017 10:50
Sublime - replace domain of special files
(https?://[^\/]*?/)([^"]*?\.(jpg|png|js|webp|svg|css|pdf))
/media/courts-aws/assets/$2
@kiennt2
kiennt2 / M2 - remove base URL for files
Last active May 16, 2017 11:44
M2 - remove base URL for files
/vendor/magento/framework/View/Asset/File.php
public function getUrl()
{
return '/static/' . $this->getPath();
}
@kiennt2
kiennt2 / Magento 2 - nginx conf
Created April 19, 2017 04:20
Magento 2 - nginx conf
# cd /etc/nginx/
# sudo mkdir ssl
# sudo openssl req -x509 -sha256 -newkey rsa:2048 -keyout cert.key -out cert.pem -days 1024 -nodes -subj '/CN=www.domain.local'
upstream fastcgi_backend {
# use tcp connection
# server 127.0.0.1:9000;
# or socket
server unix:/run/php/php7.0-fpm.sock;
}
@kiennt2
kiennt2 / Form - jQuery - serializeObject.js
Created January 29, 2017 17:52
Form - jquery - serializeObject
var data = $(form).serializeArray().reduce(function(obj, item) {
obj[item.name] = item.value;
return obj;
}, {});
@kiennt2
kiennt2 / Convert URL Text Into Clickable HTML Link Using JavaScript
Last active September 23, 2024 21:27
Convert URL Text Into Clickable HTML Link Using JavaScript
@kiennt2
kiennt2 / Util - Javascript Parameters
Last active August 15, 2017 07:33
Util - Javascript Parameters
define('utils/getParamValue', ['jquery'], function ($) {
'use strict';
var getParam = {};
getParam.byName = function (name, url) {
if (typeof url === 'undefined' || url === '' || url === null) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)");
var results = regex.exec(url);
@kiennt2
kiennt2 / Currency Format
Created September 21, 2016 03:21
Currency Format
function currencyFormat(num, decimals, dec_point, thousands_sep) {
var n = num, prec = decimals;
var toFixedFix = function (n,prec) {
var k = Math.pow(10,prec);
return (Math.round(n*k)/k).toString();
};
n = !isFinite(+n) ? 0 : +n;
@kiennt2
kiennt2 / bash alias
Last active October 3, 2017 10:13
bash alias
#!/usr/bin/env bash
###############################################################################
# Common Alias ################################################################
###############################################################################
WWW_GROUP=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
alias ...="cd ../../"
alias ll="ls -al --group-directories-first"
alias glom="git pull origin master"
@kiennt2
kiennt2 / Create jQuery function like prototype
Last active August 29, 2015 14:14
Create jQuery function like prototype
<script>
var GlobalVar = GlobalVar || {};
(function($, undefined) {
var FunctionName = GlobalVar.FunctionName = function(opts) {
FunctionName.prototype._singletonInstance = this;
opts = opts || {};
var defaultOpts = {
'element' : '.elementClassOrdId'
};
@kiennt2
kiennt2 / magento - test share wishlist page
Created December 18, 2014 09:24
magento - test share wishlist page
<?php echo Mage::getUrl('*/shared/index', array('code' => $this->getWishlistInstance()->getSharingCode())); ?>