Skip to content

Instantly share code, notes, and snippets.

View junkycoder's full-sized avatar

Dan Hromada junkycoder

  • Česká republika
View GitHub Profile
// Prints size of free space in localStorage
(1024 * 1024 * 5 - unescape(encodeURIComponent(JSON.stringify(localStorage))).length)/1024/1024
@junkycoder
junkycoder / record.js
Created July 23, 2015 10:29
Use React Prop Types to validate Immutable Records
import React from 'react';
import Immutable from 'immutable';
import {Record, Map} from 'immutable';
import ImmutablePropTypes from 'react-immutable-proptypes';
import merge from 'merge';
export const PropTypes = merge(ImmutablePropTypes, React.PropTypes);
export function alteredRecord(...args) {
const methods = [
@junkycoder
junkycoder / chart.d3.js
Last active August 29, 2015 14:26
Reusable D3 chart
import d3 from 'd3';
import {responsivefy} from './lib';
export default function Chart(node, options, initialData) {
const [width, height] = [
options.width - options.margin.left - options.margin.right,
options.height - options.margin.top - options.margin.bottom
];
function chart(data) {
@junkycoder
junkycoder / .babelrc
Last active April 14, 2016 09:02
Material-UI's styleResizable mixin as a decorator
{
"presets": ["es2015", "react"],
"plugins": [
"transform-class-properties",
"transform-function-bind",
"transform-runtime",
"transform-object-rest-spread"
]
}
@junkycoder
junkycoder / .bashrc
Last active April 25, 2016 12:00
Raspberry Pi - full screen browser
# ...
# Run the browser
if [ $(tty) == /dev/tty1 ]; then
xinit ./run_browser.sh
fi
@junkycoder
junkycoder / fixup_hg.sh
Last active August 10, 2016 12:25
Make mercurial_keyring work on OS X with homebrew mercurial 2.7.2.
#brew install python
#brew install mercurial
#/usr/local/bin/pip install mercurial_keyring
# patch from http://selenic.com/repo/hg/rev/e3a5922e18c3
cat <<-EOF | patch -p2 /usr/local/Cellar/mercurial/3.8.4/lib/python2.7/site-packages/mercurial/demandimport.py
diff -r 8bbe208c1812 -r e3a5922e18c3 mercurial/demandimport.py
--- a/mercurial/demandimport.py Sat Oct 05 01:02:22 2013 +0900
@junkycoder
junkycoder / reboot.css
Created August 24, 2016 15:24
Bootstrap reboot.scss rewritten in pure CSS
/**
* Global styles based on Reboot.css
* http://v4-alpha.getbootstrap.com/content/reboot/
* https://github.com/twbs/bootstrap/blob/v4-dev/scss/_reboot.scss
*/
/*
Reset the box-sizing
Change from `box-sizing: content-box` to `border-box` so that when you add
@junkycoder
junkycoder / react.js
Last active November 15, 2016 09:01
concept
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
/**
* Statefull application
*/
class App extends Component {
/**
* Application state
@junkycoder
junkycoder / App.js
Created November 17, 2016 16:27
React Native Router + goToLink
import React, { Component } from 'react';
import Router from './Router';
import NewDocument from './NewDocument';
import DocumentsList from './DocumentsList';
export default class App extends Component {
@junkycoder
junkycoder / script.js
Last active September 27, 2017 07:53
Convert CSS to JS in Marketch panel
// Can be used with Custom JavaScript for Websites
// https://chrome.google.com/webstore/detail/custom-javascript-for-web/poakhlngfciodnhlhhgnaaelnpjljija
// but is necessary to allow 'local URLs' in chrome://extensions/
if (document.title.indexOf('Marketch') === 0) {
$('.artboard').on('mouseup', () => setTimeout(init, 100));
}
function init () {
const $code = $('textarea[name="code"]');