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 / command.js
Last active November 23, 2020 14:51
Pocket for Backtick: Add current page to pocket for use with Backtick. Script borrowed from Pocket bookmarklet (https://getpocket.com/add/?ep=1).
javascript:(function(){var e=function(t,n,r,i,s){var o=[3432555,2860559,6204857,6335149,5164153,2581108,6183936,4410336,2557063,1623233];var i=i||0,u=0,n=n||[],r=r||0,s=s||0;var a={'a':97,'b':98,'c':99,'d':100,'e':101,'f':102,'g':103,'h':104,'i':105,'j':106,'k':107,'l':108,'m':109,'n':110,'o':111,'p':112,'q':113,'r':114,'s':115,'t':116,'u':117,'v':118,'w':119,'x':120,'y':121,'z':122,'A':65,'B':66,'C':67,'D':68,'E':69,'F':70,'G':71,'H':72,'I':73,'J':74,'K':75,'L':76,'M':77,'N':78,'O':79,'P':80,'Q':81,'R':82,'S':83,'T':84,'U':85,'V':86,'W':87,'X':88,'Y':89,'Z':90,'0':48,'1':49,'2':50,'3':51,'4':52,'5':53,'6':54,'7':55,'8':56,'9':57,'\/':47,':':58,'?':63,'=':61,'-':45,'_':95,'&':38,'$':36,'!':33,'.':46};if(!s||s==0){t=o[0]+t}for(var f=0;f<t.length;f++){var l=function(e,t){return a[e[t]]?a[e[t]]:e.charCodeAt(t)}(t,f);if(!l*1)l=3;var c=l*(o[i]+l*o[u%o.length]);n[r]=(n[r]?n[r]+c:c)+s+u;var p=c%(50*1);if(n[p]){var d=n[r];n[r]=n[p];n[p]=d}u+=c;r=r==50?0:r+1;i=i==o.length-1?0:i+1}if(s==255){var v='';for(var f=0;f<n.le
@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);}())
@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 / 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 / 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.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-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 / 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 / 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 / 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 })
}
}