Skip to content

Instantly share code, notes, and snippets.

View tonis2's full-sized avatar
🐼

Tonis tonis2

🐼
View GitHub Profile
let style = {
transform: `translate(${index*2}px, 0 )`,
transform: `rotate(${index*2}px, 0 )`,
boxShadow:`1px 1px 1px 2px ${index}px`
};
return <section key={index} id="card-container" style={style}>
<div id="card">
<p>{card}</p>
</div>
</section>
@tonis2
tonis2 / gist:1fdcac7a986ad37f259fb6f887296e76
Created April 15, 2016 14:36
random draft.js experiments
import React, {PropTypes} from 'react';
import {Editor, AtomicBlockUtils, Entity, EditorState, Modifier, RichUtils, convertToRaw} from 'draft-js'
import isClient from 'check-client'
const colorStyleMap = {
red: {
color: 'rgba(255, 0, 0, 1.0)',
},
blue: {
color: 'rgba(0, 0, 255, 1.0)',
@tonis2
tonis2 / gist:cfeb6d044347d6f3cbab656d6a94eee2
Last active September 29, 2018 20:38
draft.js remove styles and block-type from selection
clear() {
const {editorState} = this.state
const selection = editorState.getSelection()
const contentState = editorState.getCurrentContent()
const styles = editorState.getCurrentInlineStyle()
const removeStyles = styles.reduce((state, style) => {
return Modifier.removeInlineStyle(state, selection, style) }, contentState)
const removeBlock = Modifier.setBlockType(removeStyles, selection, 'unstyled')
@tonis2
tonis2 / gist:e39a16d198b689d80a8c
Created February 25, 2016 10:45
Pulling feed
const PULL_DATA= 'PULL_DATA'
import agent from 'superagent'
const initialState = {
apiFeed:[],
loaded:false
};
export default function Data(state = initialState, action) {
switch (action.type) {
@tonis2
tonis2 / gist:0b222d4308457d611745
Last active October 15, 2015 13:54
es6 Map function
let numbers = [6, 3, 9];
function map(data,func){
let numbers = [];
for (let i in data){
let as = func(data[i]);
numbers.push(as);
}
return numbers;
}
@tonis2
tonis2 / gist:23ba5a12af009f25152a
Created July 30, 2015 14:47
Uninstall all npm modules
npm ls | grep -v 'npm@' | awk '/@/ {print $2}' | awk -F@ '{print $1}' | xargs npm rm