Skip to content

Instantly share code, notes, and snippets.

View sonnygauran's full-sized avatar

Sonny Gauran sonnygauran

  • Metro Manila, Philippines
View GitHub Profile
#!/bin/sh
DIR="$(dirname $(readlink -f $0))"
cd $DIR
wget https://www.cloudflare.com/ips-v4 -O ips-v4.tmp
wget https://www.cloudflare.com/ips-v6 -O ips-v6.tmp
mv ips-v4.tmp ips-v4
mv ips-v6.tmp ips-v6
for cfip in `cat ips-v4`; do ufw allow from $cfip; done
@sonnygauran
sonnygauran / cloudflare-ufw.sh
Created May 20, 2017 08:06
Import IP v4 and v6 addresses from cloudflare
#!/bin/sh
DIR="$(dirname $(readlink -f $0))"
cd $DIR
wget https://www.cloudflare.com/ips-v4 -O ips-v4.tmp
wget https://www.cloudflare.com/ips-v6 -O ips-v6.tmp
mv ips-v4.tmp ips-v4
mv ips-v6.tmp ips-v6
for cfip in `cat ips-v4`; do ufw allow from $cfip; done
@sonnygauran
sonnygauran / database-tables-size.sql
Created February 5, 2017 12:27
Show current database's table sizes in descending order. Usually ran inside Sequel Pro Based on http://stackoverflow.com/questions/9620198/how-to-get-the-sizes-of-the-tables-of-a-mysql-database.
SET @table=(SELECT DATABASE());
select @table;
SELECT
table_schema as `Database`,
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
WHERE table_schema = @table
ORDER BY (data_length + index_length) DESC;
@sonnygauran
sonnygauran / index.html
Created November 16, 2015 06:40 — forked from anonymous/index.html
Bootstrap 3 vertically centered modal and scroll fixes Bootstrap 3 vertically centered modal and scroll fixes // source http://jsbin.com/wixako
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Bootstrap 3 vertically centered modal and scroll fixes</title>
<meta name="description" content="Bootstrap 3 vertically centered modal and scroll fixes">
<!-- include bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<style id="jsbin-css">
/* scroll fixes */
@sonnygauran
sonnygauran / frontendDevlopmentBookmarks.md
Created October 21, 2015 00:40 — forked from dypsilon/frontendDevlopmentBookmarks.md
A badass list of frontend development resources I collected over time.
@sonnygauran
sonnygauran / magento-admin_template-path-hints.sql
Last active August 29, 2015 14:08
Magento Admin - Template Path Hints
INSERT INTO `core_config_data` (`config_id`, `scope`, `scope_id`, `path`, `value`) VALUES
(null, 'default', 0, 'dev/debug/template_hints', '1'),
(null, 'default', 0, 'dev/debug/template_hints_blocks', '1'); #creates
SELECT * from `core_config_data` where (`scope` = 'default' and `scope_id` = 0 and `path` LIKE 'dev/debug/template_hints%'); #verifies
UPDATE `core_config_data` SET `value` = '0' where `scope` = 'default' and `scope_id` = 0 and `path` LIKE 'dev/debug/template_hints%'; #disables
UPDATE `core_config_data` SET `value` = '1' where `scope` = 'default' and `scope_id` = 0 and `path` LIKE 'dev/debug/template_hints%'; #enables
@sonnygauran
sonnygauran / getChildCategories.php
Last active August 29, 2015 14:06 — forked from wilhelm-murdoch/getChildCategories.php
Recursively get Magento categories and children. Parameter to return only ID, and active only.
function getCategories(Mage_Catalog_Model_Category $ParentCategory, $id_only = false, $active = true) {
$return = array();
foreach(explode(',', $ParentCategory->getChildren()) as $categoryId) {
$Category = Mage::getModel('catalog/category')->load($categoryId);
if ($Category->getIsActive()) {
if ($id_only) {
$return[] = $categoryId;
} else {
$return[$categoryId] = array(
#!/bin/bash
IGNORE_TABLES=( dataflow_batch_export dataflow_batch_import log_customer log_quote log_summary log_summary_type log_url log_url_info log_visitor log_visitor_info log_visitor_online report_event index_event enterprise_logging_event_changes core_cache core_cache_tag core_session core_cache_tag )
IGNORE_TABLES_AGGRESSIVE=( report_compared_product_index report_viewed_product_index sales_flat_quote_address sales_flat_quote_shipping_rate enterprise_customer_sales_flat_quote enterprise_customer_sales_flat_quote_address sales_flat_quote )
TRUNCATE_TABLES=( dataflow_batch_export dataflow_batch_import log_customer log_quote log_summary log_summary_type log_url log_url_info log_visitor log_visitor_info log_visitor_online report_viewed_product_index report_compared_product_index report_event index_event index_process_event )
CONFIG_FILE="./app/etc/local.xml"
DUMP_FILE="./var/db.sql"
function usage()
{
@sonnygauran
sonnygauran / magento-check.php
Last active April 25, 2023 00:10
Magento System Requirements Check
<?php
// Updated the "HOW DO I KNOW IF MY SERVER MEETS THESE SYSTEM REQUIREMENTS"
// from http://www.magentocommerce.com/knowledge-base/entry/how-do-i-know-if-my-server-is-compatible-with-magento
// specified at http://magento.com/resources/system-requirements
//
// minor adjustments made from original script
// http://www.magentocommerce.com/_media/magento-check.zip
extension_check(array(
'curl',
'dom',