Skip to content

Instantly share code, notes, and snippets.

@martisj
martisj / matrix.py
Created Oct 28, 2020
Matrixify your life
View matrix.py
class Matrix:
def __init__(self, matrix_string):
self.matrix = matrix_string.split("\n")
def row(self, index):
row = self.matrix[index - 1]
row_list = row.split()
final_list = list(map(int, row_list))
return final_list
@martisj
martisj / app.js
Last active Feb 28, 2017
HTTPS redirect express.js node kind of specifically for Heroku
View app.js
const express = require('express');
const app = express();
app.use((req, res, next) => {
if (req.headers['x-forwarded-proto'] !== 'https' && process.env.NODE_ENV === 'production') {
res.redirect(`https://${req.hostname}${req.url}`);
} else {
next();
}
});
@martisj
martisj / SassMeister-input-HTML.html
Created May 20, 2015
Generated by SassMeister.com.
View SassMeister-input-HTML.html
<div class="volume-estimator-output">
<p class="text-center">You will love</p>
<p id="volume-result" class="readonly-output">0</p>
<p class="text-center">Litres</p>
</div>
@martisj
martisj / Convert photoshop tracking to CSS letter-spacing
Last active Aug 29, 2015
A mixin to help my forgetful brain convert Photoshop tracking settings from the `Character` panel to meaningful CSS letter-spacing.
View Convert photoshop tracking to CSS letter-spacing
@mixin psd-tracking($tracking) {
letter-spacing: #{$tracking / 1000}em;
}
// To use do: `@include psd-tracking(50);` if your Photoshop character panel says 60.
@martisj
martisj / data-install-0.1.0.php
Last active Aug 29, 2015
adding attribute to set
View data-install-0.1.0.php
<?php
// die('dont do this now');
/**
* Helper methods
*/
function reindexAllIndices() {
for ($i = 1; $i <= 9; $i++) {
$process = Mage::getModel('index/process')->load($i);
$process->reindexAll();
@martisj
martisj / config.xml
Created May 12, 2014
data resource setup
View config.xml
<config>
<modules>
<Pointbreak_BoardCategory>
<version>0.1.0</version>
</Pointbreak_BoardCategory>
</modules>
<global>
<resources>
<boardcategory_setup>
<setup>
@martisj
martisj / Setup.php
Created May 12, 2014
class name for module resource setup
View Setup.php
<?php
class Pointbreak_BoardCategory_Model_Resource_Setup extends Mage_Catalog_Model_Resource_Setup {
}
@martisj
martisj / mysql4-install-0.1.0.php
Last active Aug 29, 2015
Add Attribute to attributeset default and group general
View mysql4-install-0.1.0.php
<?php
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
// Add attributes to the various sets
$attributeId = $setup->getAttribute('catalog_product', 'teaser');
$attributeSetId = $setup->getAttributeSetId('catalog_product', 'Default');
//Get attribute group info
$attributeGroupId = $setup->getAttributeGroup('catalog_product', $attributeSetId, 'General');
View request_a_demo.php
<div class="content pad request_a_demo_page">
<div class="text">
<form action="" class="public-form" id="request-demo" method="post">
<fieldset>
<legend>Request a Demo</legend>
<p>All fields are required</p>
<ol>
<li>
<label for="name">Name</label>
@martisj
martisj / home.php
Created Apr 24, 2014
email validation form
View home.php
public function request_a_demo() {
$data = array();
$data['for_universities_section'] = TRUE;
$this->form_validation->set_rules('name', 'Name', 'trim|required');
$this->form_validation->set_rules('institution', 'University/College', 'trim|required');
$this->form_validation->set_rules('position', 'Position', 'trim|required');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
if ($this->form_validation->run() == FALSE)