Skip to content

Instantly share code, notes, and snippets.

View mladenilic's full-sized avatar

Mladen Ilić mladenilic

View GitHub Profile
@mladenilic
mladenilic / index.html
Created February 4, 2020 14:06
Make sure dom element is present
<ul id="accordion">
<li></li>
...
</ul>
@mladenilic
mladenilic / rocketboost.js
Last active December 17, 2019 15:10
RocketBoost SDK example
const rocketboost = require('rocketboost')('secret_key_1WHdd4COznElyScC5as9');
const pass = await rocketboost.passes.create('template_BQ2wwXblWgH4olfQ2', {
expiration_date: '2021-01-01 00:00:00',
customer: {
first_name: 'John',
last_name: 'Doe'
}
});
@mladenilic
mladenilic / .editorconfig
Created October 10, 2018 13:47
Sample editorconfig
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
@mladenilic
mladenilic / payload.json
Last active January 25, 2023 13:21
Sample payload for Stripe `customer.source.expiring` event webhook.
{
"id": "evt_000000000000000000000000",
"object": "event",
"api_version": "2017-02-14",
"created": 1535997315,
"data": {
"object": {
"id": "card_000000000000000000000000",
"object": "card",
"address_city": null,
@mladenilic
mladenilic / active-storage-validation.rb
Created August 1, 2018 13:49
Rails Active Storage – Validate attachment content type (allow images only)
# Workaround for validating Active Storage content type
#
# Currently Active Storage does not support validation.
# This "workaround" will not prevent attachment from being saved.
# It will be saved, validated and then deleted if validation fails.
class User < ApplicationRecord
has_one_attached :avatar
validate :validate_avatar
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install x.x.x
@mladenilic
mladenilic / local.xml
Created February 28, 2018 18:46
[Magento 1.x] Remove Category filter from layered navigation
<catalog_category_layered>
<reference name="catalog.leftnav">
<action method="unsetChild"><alias>category_filter</alias></action>
</reference>
</catalog_category_layered>
@mladenilic
mladenilic / scramble-magento-emails.sql
Last active June 25, 2018 14:08
Scramble emails in test Magento DB
-- mladen@stuntcoders.com -> mladen@example.com
UPDATE `customer_entity` SET `email` = REPLACE(`email`, SUBSTRING(`email`, INSTR(`email`, '@') + 1), 'example.com');
UPDATE `sales_flat_quote_address` SET `email` = REPLACE(`email`, SUBSTRING(`email`, INSTR(`email`, '@') + 1), 'example.com');
UPDATE `sales_flat_order_address` SET `email` = REPLACE(`email`, SUBSTRING(`email`, INSTR(`email`, '@') + 1), 'example.com');
@mladenilic
mladenilic / install-magento.sh
Last active December 20, 2017 13:32
Install Magento 2
# Don't forget to change base-url ;)
bin/magento setup:install --admin-firstname=Mladen --admin-lastname=Ilic --admin-email=mladen@stuntcoders.com --admin-user=admin --admin-password=sc123123 --base-url=http://example.com/ --backend-frontname=admin --db-password=root
@mladenilic
mladenilic / ea-cpanel-cli-php.sh
Last active December 1, 2017 09:10
Choose EasyApache (cPanel) php cli version
php -ea_php 70 script.php // execute script with PHP v7.0.x
php -ea_php 71 script.php // execute script with PHP v7.1.x
php -ea_php 72 script.php // execute script with PHP v7.2.x