Skip to content

Instantly share code, notes, and snippets.

View designbyadrian's full-sized avatar
⚛️
Reacting

Adrian von Gegerfelt designbyadrian

⚛️
Reacting
View GitHub Profile
@designbyadrian
designbyadrian / Child.js
Last active September 2, 2020 17:06
For when you otherwise would try multiple dynamic refs.
import {useLayoutEffect, useRef} from 'react';
export default ({onChange}) => {
const myRef = useRef();
const updatePosition = () => {
const rect = myRef.current.getBoundingClientRect();
onChange(rect);
};
@designbyadrian
designbyadrian / .block
Last active September 12, 2016 11:53
D3 v4 Force - Adding nodes incrementally
license: gpl-3.0
@designbyadrian
designbyadrian / Bohemian.Rhapsody.js
Last active November 19, 2020 20:48
The well known tune transcribed into JavaScript, based on an image I found on the Internet. Please link me the source and author if you have it.
/**
* @author Freddie Mercury
* @copyright Sony/ATV Music Publishing LLC
*/
let BohemianRhapsody = function(){
// Is this the real life?
// Is this just fantasy?
try {
@designbyadrian
designbyadrian / keystroke.scpt
Last active August 29, 2015 14:16
Send keystroke command to Mac OS application
-- run with "osascript keystroke.scpt APPNAME KEY MODIFIER"
on run params
set frontApp to (path to frontmost application as text)
set appl to item 1 of params
set keyy to item 2 of params
if frontApp is not equal to appl then
tell application appl
@designbyadrian
designbyadrian / Tiniest-Base-64-Ever.md
Last active August 29, 2015 14:08
Tiniest Base64 Ever
@designbyadrian
designbyadrian / sassy-tag-mixin.sass
Last active August 29, 2015 14:07
SASS Tag mixin
@mixin tag($fcolor,$color,$bcolor)
$border-radius: 0.3
$nohyp: (1.95) * sin(45deg) // 1.95 = height in ems including padding, minus border radius
padding: .4em .6em
border-radius: #{$border-radius}em
background-color: $color
color: $fcolor
z-index: 1
margin-right: #{$nohyp}em
&:before
@designbyadrian
designbyadrian / Console.log() override.js
Created August 18, 2014 14:41
Hijack console.log, console.warn, and console.error without breaking the default browser function.
var cl,ce,cw;
if(window.console && console.log){
cl = console.log;
console.log = function(){
MyLogFunction(arguments);
cl.apply(this, arguments)
}
}

CSS Style Guide

By Sean Goresht

Contents

  • Layout
  • Colours
  • Sizing and Proportions
  • Type
  • Media Queries
@designbyadrian
designbyadrian / QuickSort.rb
Last active August 29, 2015 14:01
Here are some things you can do with Gists in GistBox.
# Use Gists to store entire functions
class QuickSort
def self.sort!(keys)
quick(keys,0,keys.size-1)
end
private
def self.quick(keys, left, right)
@designbyadrian
designbyadrian / JavaScript Array functions for IE7.js
Last active January 19, 2017 08:57
ECMA262-5 MDC Fallback implementations
'use strict';
// Add ECMA262-5 method binding if not supported natively
//
if (!('bind' in Function.prototype)) {
Function.prototype.bind= function(owner) {
var that= this;
if (arguments.length<=1) {
return function() {
return that.apply(owner, arguments);