Skip to content

Instantly share code, notes, and snippets.

View alexaivars's full-sized avatar

Alexander Aivars alexaivars

  • Aivars AB
  • Sweden
View GitHub Profile
class Teaser extends React.Component {
render() {
var model = this.props.model;
return (
<article className="teaser">
<TeaserLink link={model.link}>
<Picture model={model.cover} type="square"/>
<div className="teaser__text">
<TeaserCaption>{model.description}</TeaserCaption>
<div>
@alexaivars
alexaivars / teaser.jsx
Last active August 29, 2015 14:18
teaser.jsx
class Teaser extends React.Component {
render() {
return (
<article className="teaser">
<TeaserLink link={this.props.link}>
<Picture src={this.props.cover} type="square"/>
<div>
<h1>{this.props.description}, {this.props.title}</h1>
<p>{this.props.text}</p>
</div>
@alexaivars
alexaivars / Sticky.js
Created June 4, 2015 21:57
sticky wrapper
'use strict';
var React = require('react');
var util = {
// findPos() by quirksmode.org
// Finds the absolute position of an element on a page
findPos: function (obj) {
/*jshint -W084 */
var curleft = 0,
@alexaivars
alexaivars / gist:1038970
Created June 21, 2011 21:37 — forked from jacobastrom/gist:1038045
Alex Aivars Worldwide!
Alex Aivars Worldwide! Site is forked from Jacob Åström Worldwide.
I help companies and organizations create what they normally don’t,
make things they didn’t know they could and do things they
wouldn’t think was possible. Always digital to most extent.
But then again – what isn’t?
Open for inquiries (or, at least, tea).
@alexaivars
alexaivars / gist:1316269
Created October 26, 2011 12:57
quick n dirty solv
function zeroFill( number, width )
{
width -= number.toString().length;
if ( width > 0 )
{
return new Array( width + (/\./.test( number ) ? 2 : 1) ).join( '0' ) + number;
}
return number;
}
@alexaivars
alexaivars / post-proxy-server.coffee
Created November 16, 2012 10:11
a simple node.js ajax get to post proxy server.
http = require("http")
q = require("querystring")
url = require("url")
server = http.createServer().listen 9006
server.on "request", (req, res) ->
params = url.parse(req.url, true).query
callbackFn = "callback"
if params.url is undefined or params.url is ""
@alexaivars
alexaivars / localstorage.coffee
Created December 5, 2012 13:19
Simple localstorage polyfill
################################################################################
#
# [global] localstorage
# A simple cookie based polyfill for localStorage
#
################################################################################
unless Modernizr.localstorage
window.localStorage =
length: 0
setItem: (key, value) ->
@alexaivars
alexaivars / Rakefile
Created April 11, 2011 11:03 — forked from andreyvit/Rakefile
sass, haml & coffescript watcher
require 'rake/clean'
include ::Rake::DSL
BIN = "public_html"
HAML = FileList['**/*.haml']
LESS = FileList['**/*.less']
COFFEE = FileList['**/*.coffee']
SASS = FileList['**/*.scss']
var canvas = document.getElementById('canvas1');
var img = new Image;
var mst = new Image;
var mstSrc = "http://i.ytimg.com/vi/zNeaXKF0Eik/maxresdefault.jpg";
var imgSrc = "http://www.goodwp.com/images/201303/goodwp.com_27776.jpg";
const drawBackground = (canvas) => {
const ctx = canvas.getContext('2d');
ctx.globalCompositeOperation = "source-over";
ctx.globalAlpha = 1;
@alexaivars
alexaivars / composeReducers.js
Created October 31, 2016 18:46
compose redux reducers
export default function composeReducers(...reducers) {
return (state, action) => reducers.reduce((result, fn)=>fn(result, action), state);
}