Skip to content

Instantly share code, notes, and snippets.

🕴️
I may be slow to respond.

Tomáš Ehrlich tricoder42

🕴️
I may be slow to respond.
View GitHub Profile
@tricoder42
tricoder42 / osx_boot2docker
Created Aug 14, 2014
Helper script to install boot2docker with added guest additions.
View osx_boot2docker
#!/bin/bash
# Helper script to install boot2docker with added guest additions
# Directory /Users will be mounted as shared dir.
#
# Source:
# https://medium.com/boot2docker-lightweight-linux-for-docker/boot2docker-together-with-virtualbox-guest-additions-da1e3ab2465c
BOOT2DOCKER_PATH=~/.boot2docker/boot2docker.iso
RELEASE=http://static.dockerfiles.io/boot2docker-v1.1.2-virtualbox-guest-additions-v4.3.12.iso
RELEASE_MD5=5e39eb7e960e30b433ffefb02bfce4ba
@tricoder42
tricoder42 / e2e.conf.js
Created Dec 1, 2014
Karma/Protractor config files
View e2e.conf.js
exports.config = {
allScriptsTimeout: 11000,
specs: [
'e2e/**/*.coffee'
],
multiCapabilities: [
{
// 'browserName': 'Safari'
View .editorconfig
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
@tricoder42
tricoder42 / gist:3969491
Created Oct 28, 2012
Show song info from internet radio in pop up using mplayer and notify-send
View gist:3969491
#!/bin/sh
# Show song info from internet radio in pop up window.
#
# Copyright (c) 2012 Tomáš Ehrlich <tomas.ehrlich@gmail.com>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
@tricoder42
tricoder42 / Input.jsx
Created Nov 23, 2015
Usage of `uncontrollable`
View Input.jsx
const PureInput = React.createClass({
propTypes: {
name: React.PropTypes.string.isRequired,
label: React.PropTypes.string,
type: React.PropTypes.string,
placeholder: React.PropTypes.string,
// value/callback pair
value: React.PropTypes.string,
@tricoder42
tricoder42 / urls.py
Created Jun 11, 2013
Snippet to server static and media files in development.
View urls.py
# Append to your urls.py file.
# Development
from django.conf import settings
if settings.DEBUG:
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
media = static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns = media + staticfiles_urlpatterns() + urlpatterns
@tricoder42
tricoder42 / defaultProps.jsx
Last active Jul 11, 2016
Default props in React
View defaultProps.jsx
// Is there any difference? (In performance for example?)
// A: Using default values in object destructuring
const A = ({
value = "",
foo = "bar",
...props
}) => {};
@tricoder42
tricoder42 / actions.js
Created Sep 5, 2016
How to react on state changes using redux-saga
View actions.js
// just a helper function
const updateComponent = (component, newState) => component.setState(newState)
// 1st approach using redux-promise. Actions returns promises, so component
// can trigger actions when promise is resolved.
const handleEventPromise = (props) => (event) => {
this.props.action({...})
.then((payload) => updateComponent(this, {...}))
}
@tricoder42
tricoder42 / react-translated.jsx
Last active Nov 28, 2016
What style would you prefer when writing multilingual messages?
View react-translated.jsx
// message is constructed using helper functions
const HelperFunction = ({count}) =>
<Trans>
{plural(count, {
one: "One glass",
other: "# glasses"
})} or wine
</Trans>
// message written using template literals
@tricoder42
tricoder42 / 01_simple_selector.js
Created Jun 6, 2017
2017/06/06 [Medium] Use Selectors in Redux for Great Good
View 01_simple_selector.js
const initialState = {
todos: []
}
const reducer = (state = initialState, action = {}) => {
if (action.type === 'ADD_TODO') {
return {
...state,
todos: [...state.todos, action.payload]
}
You can’t perform that action at this time.