Skip to content

Instantly share code, notes, and snippets.

martisj /
Created Oct 28, 2020
Matrixify your life
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 / 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') {
} else {
martisj / SassMeister-input-HTML.html
Created May 20, 2015
Generated by
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>
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 / data-install-0.1.0.php
Last active Aug 29, 2015
adding attribute to set
View data-install-0.1.0.php
// die('dont do this now');
* Helper methods
function reindexAllIndices() {
for ($i = 1; $i <= 9; $i++) {
$process = Mage::getModel('index/process')->load($i);
martisj / config.xml
Created May 12, 2014
data resource setup
View config.xml
martisj / Setup.php
Created May 12, 2014
class name for module resource setup
View Setup.php
class Pointbreak_BoardCategory_Model_Resource_Setup extends Mage_Catalog_Model_Resource_Setup {
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
$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">
<legend>Request a Demo</legend>
<p>All fields are required</p>
<label for="name">Name</label>
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)