Skip to content

Instantly share code, notes, and snippets.

@rgranadino
rgranadino / gwsdecoder.php
Created August 23, 2012 04:43
D-Link gws file decoder
#/usb/bin/php
<?php
//author rgranadino aug 22 2012
//tested on a D-Link DIR-615 B2 v2.25 firmware.
//this is a php translation of:
// http://www.shulerent.com/2009/08/21/cracking-the-d-link-settings-file/
$file = $argv[1];
if (!is_readable($file)) {
echo "Cannot read file: $file\n";
@rgranadino
rgranadino / main.tf
Created September 7, 2018 16:27
terraform example of app autoscaling based on customized metric specification
resource "aws_appautoscaling_policy" "scale_out" {
name = "scale-up"
policy_type = "TargetTrackingScaling"
resource_id = "service/${data.terraform_remote_state.ecs_cluster.ecs_cluster_name}/${var.service_name}"
scalable_dimension = "ecs:service:DesiredCount"
service_namespace = "ecs"
target_tracking_scaling_policy_configuration {
target_value = "${var.scaling_target_value}"
scale_in_cooldown = "${var.scale_in_cooldown}"
@rgranadino
rgranadino / ecs-ssh.rb
Last active February 16, 2018 18:12
AWS ECS ssh helper
#!/usr/bin/ruby
require 'json'
$sshUser = 'ec2user'
#NOTE all of our ecs clusters are prefixed with "ecs-"
#which we assume here to save the time & trouble of having to type that out
#all of our tasks are also suffixed with the "environment" name
def sshToEcsInstance(clusterName)
cmd = "aws ecs list-container-instances --cluster ecs-"+ clusterName
instances = JSON.parse(`#{cmd}`)["containerInstanceArns"]
ec2InstanceHostname = getInstanceInfo(clusterName, instances.sample)
### Keybase proof
I hereby claim:
* I am rgranadino on github.
* I am beeplogic (https://keybase.io/beeplogic) on keybase.
* I have a public key ASAbXks9Scgwvunw_13NMBXnVYDNLdWqCEZRRNKFZGzP7go
To claim this, I am signing this object:
@rgranadino
rgranadino / gist:7530093
Created November 18, 2013 15:50
simple log4j properties
log4j.rootLogger = ALL, Console
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.conversionPattern=%m%n
<?php
class Email {
//...
public function setAttachments(array $files) {
$this->attachment_list = array();
foreach($files as $filename => $file) {
if (is_str($filename)) {
$this->addAttachment($file, $filename);
} else {
@rgranadino
rgranadino / gist:6645104
Created September 20, 2013 23:07
Magento Sync Product Attributes
public function syncConfigProductAttributes(Mage_Catalog_Model_Product $product)
{
if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
/* @var $productType Mage_Catalog_Model_Product_Type_Configurable */
$productType = $product->getTypeInstance(true);
$syncAttributes = array('short_description', 'description');
foreach ($productType->getUsedProductCollection($product) as $childProduct) {
//$childProduct->load($childProduct->getId());
/* @var $childProduct Mage_Catalog_Model_Product */
foreach ($syncAttributes as $attributeCode) {
@rgranadino
rgranadino / gist:5977733
Created July 11, 2013 18:05
install dummy rice and beans product in magento
#!/usr/bin/env php
<?php
require 'app/Mage.php';
if (!Mage::isInstalled()) {
echo "Application is not installed yet, please complete install wizard first.";
exit(1);
}
$baseDir = getcwd();
//not sure if this is necessary, ported over from cron.php script
$_SERVER['SCRIPT_NAME'] = $baseDir.'/index.php';
@rgranadino
rgranadino / gist:3100752
Created July 12, 2012 20:29
php object comparison recursion example
class Foo {
public $x = null;
}
$a = new Foo();
$b = new Foo();
$c = new Foo();
$d = new Foo();
$a->x = $c;
@rgranadino
rgranadino / .gitignore
Created May 7, 2012 23:33
magento (1.6.1.0) .gitignore
.buildpath
.htaccess
.htaccess.sample
.settings
.project
app/etc/local.xml
app/code/community/Find/
app/code/community/Phoenix/
app/code/core/
app/design/adminhtml/default/default/