Skip to content

Instantly share code, notes, and snippets.

View martisj's full-sized avatar
🐊

Martin Sjåstad martisj

🐊
View GitHub Profile
@martisj
martisj / matrix.py
Created October 28, 2020 14:45
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
martisj / app.js
Last active February 28, 2017 10:12
HTTPS redirect express.js node kind of specifically for Heroku
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 12:12
Generated by SassMeister.com.
<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 August 29, 2015 14:16
A mixin to help my forgetful brain convert Photoshop tracking settings from the `Character` panel to meaningful 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 August 29, 2015 14:01
adding attribute to set
<?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 14:34
data resource setup
<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 11:41
class name for module resource setup
<?php
class Pointbreak_BoardCategory_Model_Resource_Setup extends Mage_Catalog_Model_Resource_Setup {
}
@martisj
martisj / mysql4-install-0.1.0.php
Last active August 29, 2015 14:01
Add Attribute to attributeset default and group general
<?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');
<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 April 24, 2014 07:04
email validation form
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)