Skip to content

Instantly share code, notes, and snippets.

View creaux's full-sized avatar
:octocat:

Petr Juna creaux

:octocat:
View GitHub Profile
@creaux
creaux / mixins.less
Created October 11, 2013 13:16
LESS CSS scale model mixin
//
// Dummy represent scale model of specificaly sized image
// Mixin is base on popular http://placehold.it/ solution
// arguments: width, height
// data: int, int
//
.dummy(@width, @height) {
background: url("http://placehold.it/@{width}x@{height}");
width: @width*1px;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var foobar = {
@creaux
creaux / static_block_transactional
Created November 27, 2014 07:51
Insert static block into transactional email
<!-- where cms/content.phtml return cms block content! -->
{{block type="cms/block" block_id="blockIdHere" template="cms/content.phtml"}}
@creaux
creaux / fiddle.js
Last active August 29, 2015 14:12
Allows to add new method to classes with chaining functionality.
Function.prototype.method = function(name, fn) {
this.prototype[name] = fn;
return this;
}
@creaux
creaux / RouteCtrl.ts
Last active August 29, 2015 14:14
Route Controller
export function RouteCtrl($scope, $route, $routeParams, $rootScope) {
// Function for page rendering
function render() {
// Properties
// ----------------------------------
var action,
path,
section;
@creaux
creaux / Route.html
Last active August 29, 2015 14:14
View for Route Controller
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<script src="//localhost:35729/livereload.js"></script>
<!-- bower:css -->
@creaux
creaux / Routes.ts
Created February 6, 2015 09:21
Routes for modules Routing
export function routeProvider($routeProvider) {
$routeProvider.when(
"/whatever", {
action: "whatever.home"
}
).otherwise({ "action": "home" });
}
@creaux
creaux / rtree.js
Last active August 29, 2015 14:21
// Usage:
//
// 1. Put this in the file that gets first loaded by RequireJS
// 2. Once the page has loaded, type window.rtree.map() in the console
// This will map all dependencies in the window.rtree.tree object
// 3. To generate UML call window.rtree.toUml(). The output can be used
// here: http://yuml.me/diagram/scruffy/class/draw
requirejs.onResourceLoad = function (context, map, depMaps) {
if (!window.rtree) {
window.rtree = {};
//
// Get all values from object
//
var obj = { something: "value1", somethingElse: "value2" };
// Object.keys method
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
// Put all keys from object to array
//
// Object.map method

Angular2 + JSPM cheat sheet

First time setup

  • install jspm beta: npm install -g jspm@beta
  • set up your project: jspm init
  • install dependencies: jspm install angular2 reflect-metadata zone.js es6-shim

This will create a jspm_packages folder, and a config.js file.

Open the config.js file - this file manages options for the System.js loader - tweak it as appropriate