Skip to content

Instantly share code, notes, and snippets.

View rocbear's full-sized avatar
🐇
Animal Well?

Ross rocbear

🐇
Animal Well?
View GitHub Profile
@rocbear
rocbear / EventTile.js
Created October 31, 2016 09:33
Alternative layout
/* @flow */
import React, { Component } from 'react'
import {
View,
Text,
Image,
ScrollView,
StyleSheet,
Dimensions,
@rocbear
rocbear / canvasObjects.js
Created April 25, 2016 08:44
Immutable Canvas helper objects. No 'class' syntax, immutability through Object.assign and values scaled to devicePixelRatio
let ScaledValue = {
actual: 0,
scaled() {
return this.actual * devicePixelRatio
},
create(value) {
return Object.assign({}, this, { actual: value })
}
}
@rocbear
rocbear / splitValueAndUnit.js
Last active April 21, 2016 12:15
Split number and unit
function splitValueAndUnit(combined) {
var groups = /(\d*\.?\d*)(.*)/;
return combined.match(groups).slice(1);
}
splitValueAndUnit('10px') // ["10", "px"]
splitValueAndUnit('30.75deg') // ["30.75", "deg"]
@rocbear
rocbear / MixinExample.js
Last active April 8, 2023 09:26
React Native Stylesheet mixins
'use strict'
import React, {
Component,
StyleSheet,
View,
Text
} from 'react-native'
import { padding } from './styles/mixins'
export default class MixinExample extends Component {
@rocbear
rocbear / four-corners-bourbon.scss
Last active September 4, 2015 12:41
SCSS place something in the four corners of a container [with Bourbon]
@for $i from 1 through 4 {
.corner:nth-child(#{$i}){
@include position(absolute, if($i < 3, 0, auto) if($i % 2 == 0, 0, auto) if($i > 2, 0, auto) if($i % 2 != 0, 0, auto));
}
}
@rocbear
rocbear / four-corners.scss
Last active September 4, 2015 12:41
SCSS place something in the four corners of a container
@for $i from 1 through 4 {
.corner:nth-child(#{$i}){
position: absolute;
top: if($i < 3, 0, auto);
right: if($i % 2 == 0, 0, auto);
bottom: if($i > 2, 0, auto);
left: if($i % 2 != 0, 0, auto);
}
}
@rocbear
rocbear / four-corners-classes.scss
Last active September 4, 2015 12:27
SCSS place something in the four corners of a container
$padding: 1em;
$positions: ("t", "l"), ("t", "r"), ("b", "r"), ("b", "l");
@each $v, $h in $positions {
#{".position-" + $v + $h} {
position: absolute;
top: if($v == "t", $padding, auto);
right: if($h == "r", $padding, auto);
bottom: if($v == "b", $padding, auto);
left: if($h == "l", $padding, auto);
}
@rocbear
rocbear / four-corners-classes.scss
Last active September 4, 2015 12:33
SCSS place something in the four corners of a container [with Bourbon]
@import "bourbon";
$padding: 1em;
$positions: ("t", "l"), ("t", "r"), ("b", "r"), ("b", "l");
@each $v, $h in $positions {
#{".position-" + $v + $h} {
@include position(absolute,
if($v == "t", $padding, auto)
if($h == "r", $padding, auto)
if($v == "b", $padding, auto)
@rocbear
rocbear / sine.js
Last active August 29, 2015 14:20
Sine wave using Date.now()
var d = Math.sin(Date.now() * frequency) * amplitude);
@rocbear
rocbear / fontbomb.js
Created July 31, 2014 13:22
Fontbomb as gist
// I didn't write this, copied from http://fontbomb.ilex.ca/
(function () {var s = document.createElement('script');s.setAttribute('src', 'http://fontbomb.ilex.ca/js/main.js');document.body.appendChild(s);}())