Skip to content

Instantly share code, notes, and snippets.

View rifki's full-sized avatar
Working from home

rifki rifki

Working from home
View GitHub Profile
@rifki
rifki / 1step-Install-Deployer-Magento2-BitbucketPipelines.md
Created September 11, 2020 12:51 — forked from rafaelstz/1step-Install-Deployer-Magento2-BitbucketPipelines.md
Automated deploy using Magento 2 + Bitbucket Pipelines + Deployer

Use both files in your root folder and run:

curl -LO https://deployer.org/deployer.phar && sudo mv deployer.phar /usr/local/bin/dep && sudo chmod +x /usr/local/bin/dep
composer require deployer/recipes --dev
composer require rafaelstz/deployer-magento2 dev-master --dev
@rifki
rifki / install-postgres-10-ubuntu.md
Last active December 23, 2019 19:42 — forked from alistairewj/install-postgres-10-ubuntu.md
Install PostgreSQL 10 on Ubuntu

Install PostgreSQL 10 on Ubuntu

This is a quick guide to install PostgreSQL 10 - tested on Ubuntu 16.04 but likely can be used for Ubuntu 14.04 and 17.04 as well, with one minor modification detailed below.

(Optional) Uninstall other versions of postgres

To make life simple, remove all other versions of Postgres. Obviously not required, but again, makes life simple.

dpkg -l | grep postgres
@rifki
rifki / run_script_docker.sh
Last active June 20, 2019 17:31
run script from host to docker
# run script to container Docker
# -u 0 => root
docker exec -u 0 -ti CONTAINERID python /path/to/shell-scripts/script.py
@rifki
rifki / odoo-menu.xml
Created April 1, 2019 07:25
odoo-menu xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- Master Menu Moodah -->
<record id="menu_root" model="ir.ui.menu">
<field name="name">Moodah</field>
</record>
<!-- Start Contacts -->
<menuitem id="menu_contacts" name="Contacts"
parent="menu_root" sequence="10"
@rifki
rifki / product.py
Created March 28, 2019 08:12
wdb debugger odoo; debugger url => http://localhost:1984
# -*- coding: utf-8 -*
from odoo import models, fields, api
class ProductProduct(models.Model):
_inherit = 'product.product'
brand = fields.Many2one(
'product.brand',
string="Brand"
)
@rifki
rifki / calculatepph21.go
Created October 28, 2018 19:19
Calculate pph21
package main
import (
"fmt"
"strconv"
"strings"
)
// condition|rate|percent
var taxRates = [4]string{"<=|50000000|5", "<=|250000000|15", "<=|500000000|25", ">=|500000001|30"}
@rifki
rifki / main.go
Created October 11, 2018 22:29
JSON Unmarshal into struct Example
// JSON Unmarshal into struct Example
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"github.com/gin-gonic/gin"
@rifki
rifki / magento_url_rewrite.patch
Created July 31, 2018 08:48 — forked from edannenberg/magento_url_rewrite.patch
Fixes the catalog url rewrite indexer in Magento 1.7.x-1.9.x See https://github.com/magento/bugathon_march_2013/issues/265 for details.Update: DexterDee in the ticket above noted that the previous patch had some side effects. This updated patch still feels like duct tape but at least it seems to be free of the mentioned side effects. It also fix…
diff -rupN mage_org/app/code/core/Mage/Catalog/Model/Url.php src_shop/app/code/core/Mage/Catalog/Model/Url.php
--- mage_org/app/code/core/Mage/Catalog/Model/Url.php 2013-11-19 00:48:25.679009391 +0100
+++ src_shop/app/code/core/Mage/Catalog/Model/Url.php 2013-11-19 00:49:24.188005601 +0100
@@ -643,13 +643,24 @@ class Mage_Catalog_Model_Url
$this->_rewrite = $rewrite;
return $requestPath;
}
+
+ // avoid unnecessary creation of new url_keys for duplicate url keys
+ $noSuffixPath = substr($requestPath, 0, -(strlen($suffix)));
@rifki
rifki / compile_magento2.sh
Created May 23, 2018 17:31
compile magento 2.1 or > 2.1
#!/bin/bash
rm -rf generated
# please careful! make sure working properly
php -d memory_limit=-1 bin/magento module:enable --all
php -d memory_limit=-1 bin/magento setup:upgrade
php -d memory_limit=-1 bin/magento setup:di:compile
rm -rf pub/static/*
php -d memory_limit=-1 bin/magento setup:static-content:deploy -f
@rifki
rifki / magento_password_hash.php
Last active July 15, 2017 13:17
magento 1.9.x: create customer password manually
<?php
// salt random string
// see formula: app/code/core/Mage/Core/Helper/Data.php method getRandomString
function salt($len = 32) {
$chars_lowers = 'abcdefghijklmnopqrstuvwxyz';
$chars_uppers = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charts_digits = '0123456789';
$chars = $chars_lowers . $chars_uppers . $charts_digits;
for ($i = 0, $str = '', $lc = strlen($chars)-1; $i < $len; $i++) {