Skip to content

Instantly share code, notes, and snippets.

View fabiosussetto's full-sized avatar

Fabio Sussetto fabiosussetto

View GitHub Profile
.col50 {
float:left;/* NOTE: allineamento di col50 a six */
width: 450px;/* NOTE: larghezza di col50 */
margin: 25px;
}
@media (max-width: 700px) {
.col50 {
float: none;
}
.col50 {
float:left;/* NOTE: allineamento di col50 a six */
width: 450px;/* NOTE: larghezza di col50 */
margin: 25px;
}
@media (max-width: 700px) {
.col50 {
float: none;
}
@fabiosussetto
fabiosussetto / compose_hoc.js
Created December 19, 2016 18:18
compose hoc
import { connect } from 'react-redux'
// compose can be implemented in a few different ways:
//https://en.wikipedia.org/wiki/Function_composition_(computer_science)
// a nice compact way I found is the following:
function compose (..._fns) {
return (...args) => {
const [fn, ...fns] = _fns.reverse()
return fns.reduce((acc, f) => f(acc), fn(...args))
@fabiosussetto
fabiosussetto / index.js
Created November 7, 2016 10:29
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
const u = require('updeep');
console.log(u);
const state = {
users: [
// Action creator
const selectPost = postId => ({ type: 'SELECT_POST', postId });
// A reducer listens for SELECT_POST and saves that in the store.
const selectPostAndNavigate = postId => {
return dispatch => {
dispatch(selectPost(postId));
// Navigate here, e.g. dispatch(push(`/posts/${postId}`)) or use router directly
// If you use react-router-redux you don't even actually interact directly with location
}
#!/usr/bin/env bash
set -e
BUILD_DIR=$(pwd)/.tmp-build
rm -rf $BUILD_DIR
mkdir $BUILD_DIR
docker run \
-v $(pwd)/frontend:/tmp/frontend \
@fabiosussetto
fabiosussetto / deploy_docker_image.yml
Created September 2, 2016 12:24
deploy_docker_image.yml
- hosts: all
remote_user: ubuntu
sudo: yes
gather_facts: True
tasks:
- name: Ensure valid locale
command: locale-gen en_GB.UTF-8
- apt_key: keyserver=hkp://p80.pool.sks-keyservers.net:80 state=present id=58118E89F3A912897C070ADBF76221572C52609D
/*
* Since I'm studying a bit of functional programming with Js,
* this is an example of how I'd build a widget that fetches images from Reddit,
* trying to use a "practical" functional style (thanks to lodahs/fp).
*/
requirejs.config({ baseUrl: 'https://cdn.jsdelivr.net' });
requirejs(['lodash/4.13.1/lodash.min',
'lodash/4.13.1/lodash.fp.min',
import { STEP_NAMES } from '../constants'
import { setOrderRef, goToStep } from './actionCreators'
import { fetchList as fetchFaqList } from './faqs'
import { getCurrentStepName } from '../selectors/wizard'
export function goToNextStep (stepData) {
return (dispatch, getState) => {
const state = getState()
assert 'priority' in {tag_name.to_lower() for tag_name in project.tags.values()}, 'priority tag not found in project tags'
# If you find yourself doing this many times, just create a simple test helper function.
# A lot easier, more flexible and composable than creating a ProjectTestCaseMixin with a assertProjectTags method to extend.
# No need for classes and (multiple/mixin) inheritance at all.
def get_normalised_project_tags(project):
return {tag_name.to_lower() for tag_name in project.tags.values()}
assert 'priority' in get_normalised_project_tags(project), 'priority tag not found in project tags'