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 / # php70-memcached - 2016-08-26_22-43-25.txt
Created August 26, 2016 15:46
php70-memcached (homebrew/php/php70-memcached) on Mac OS X 10.11.6 - Homebrew build logs
Homebrew build logs for homebrew/php/php70-memcached on Mac OS X 10.11.6
Build date: 2016-08-26 22:43:25
@rifki
rifki / my.cnf
Last active September 19, 2016 17:23
Magento2: Solution mysql server has gone way - edit your /etc/my.cnf http://blog.rifkilabs.net/magento2-mysql-server-has-gone-away-during-installation.html
[mysqld]
max_allowed_packet=2G
innodb_file_per_table=OFF
wait_timeout=228800000
connect_timeout=300
# at least 250
table_open_cache=1000
open_files_limit=2048
open-files-limit=2048
@rifki
rifki / reset-mysql-password.txt
Created October 15, 2016 16:27
how to reset root password mysql server > 5.7.6
1. Stop mysql:
$ sudo service mysql stop
2. Step 2: Kill all running mysqld
$ sudo killall -9 mysqld
3. Step 3: Starting mysqld in Safe mode.
$ sudo mysqld_safe --skip-grant-tables --skip-networking &
4. Login as root
@rifki
rifki / Observer.php
Last active February 18, 2017 04:43
Magento customer group registration specific domain
<?php
/**
* Observer change Customer group
*
* @category Rifki
* @package Rifki_MembershipGroup
* @author Muhamad Rifki
* @copyright rifkilabs.net
*/
class Rifki_MembershipGroup_Model_Observer
@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++) {
@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_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 / 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 / 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 / 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"
)