Skip to content

Instantly share code, notes, and snippets.

@Muzietto
Muzietto / promiseWriteCsvFile.js
Last active March 8, 2017 04:20
Promise to write data into a CSV file using npm module 'csv-write-stream'
putPortfolioData = function(result, dataSinkName) {
return new Promise(function (resolve, reject) {
var filename = __dirname + dataSinkName,
writer = csvStream(),
ws = fs.createWriteStream(filename)
;
writer.on('error', function(error) {
reject(error);
});
@Muzietto
Muzietto / index.js
Created March 16, 2017 08:43
npm configuration and app entry script for media library using redux-saga (https://scotch.io/tutorials/build-a-media-library-with-react-redux-and-redux-saga-part-1)
import React from 'react';
import ReactDOM from 'react-dom';
import {Router, hashHistory} from 'react-router';
import routes from './routes';
// require the routes and render to the DOM using ReactDOM API
ReactDOM.render(
<Router history={hashHistory} routes={routes} />,
document.getElementById('root')
)
@Muzietto
Muzietto / CmsEntry.json
Last active June 30, 2017 10:10
Generic item for headless CMS
{
"id": "http://socialsweethearts.de/CmsEntry#",
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "schema for an headless_cms_mvp entry",
"type": "object",
"properties": {
"value": {
"type": "object",
"oneOf": [{
"$ref": "#/definitions/ListicleItems",
@Muzietto
Muzietto / Instructions.md
Created November 29, 2017 11:44
Instructions

Open this readme in your browser


Instructions

  • Use the given minimal app project to implement the User Stories
  • Take your time. This coding challenge is not designed to get finished
  • Focus on functionality, but do not neglect appearance
  • Try to write generic and re-usable code
  • You are free to implement the application logic any way you like, using any library you think is suited for the task. However, we expect you to be able to justify with solid motives every choice you make (and please be advised that we LOVE vanilla JS)
@Muzietto
Muzietto / unobfuscatedRaygunScript.js
Last active December 15, 2017 13:11
This is how Raygun manages to peek into window.onerror and dispatch the error to its servers
!function (
window,
document,
scriptString,
minifiedRaygunScript,
rg4jsString,
domScriptElement,
firstStriptTag,
windowOnError
) {
@Muzietto
Muzietto / DataField.js
Last active August 29, 2018 06:52
React + OnsenUI - Making the form smaller and scrollable when the keyboard pops up. Bonus points because friggin onsenui' Input has no onFocus prop.
import React from 'react'
import ReactDOM from 'react-dom'
import { Input } from 'react-onsenui'
export default class DataField extends React.Component {
componentDidMount() {
this.focusHandler = this.mainInputFocusEventHandler.bind(this)
if (this.mainInput) {
@Muzietto
Muzietto / Preferences.sagas.js
Last active August 29, 2018 09:19
Sagas to write localstorage and read it back. Gotta save info in state instead...
import { call, put, takeLatest, take, race } from 'redux-saga/effects'
import {
SWITCH_BIOMETRIC_UNLOCK_REQUEST,
SWITCH_BIOMETRIC_UNLOCK_REJECTED,
SWITCH_BIOMETRIC_UNLOCK_SUCCESS,
} from './Preferences.actions'
import {
CLOSE_PASSWORD_MODAL,
OPEN_PASSWORD_MODAL,
PASSWORD_VALIDATED,
@Muzietto
Muzietto / animations.js
Last active August 30, 2018 07:37
Simple Swiping Up, compare with the White Rabbit (https://codepen.io/rachelnabors/pen/eJyWzm)
export function playSwipeInAnimation(element, height) {
const ANIMATION_DURATION = 500;
const TIMING = {
duration: ANIMATION_DURATION,
fill: 'forwards',
easing: 'cubic-bezier(0.42,0,0.58,1)',
};
@Muzietto
Muzietto / Icon.js
Created November 15, 2018 16:21
Scalable import of FontAwesome icons in generic icon component, with Storybook story
import React from 'react';
import PropTypes from 'prop-types';
import './Icon.scss';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
const Icon = ({ icon: iconName, color, backgroundColor, ...rest }) => {
const faIconName = `fa${iconName.replace(/./, c => c.toUpperCase())}`;
const faIcon = require(`@fortawesome/pro-light-svg-icons/${faIconName}.js`)[faIconName];
return (
@Muzietto
Muzietto / wget_urls_from_file.sh
Created January 26, 2019 19:00
Shellscript to read urls from a text file and download them one after the other (with some rest in between)
cat urls.txt | while read url; do wget -mpEkL "$url"; sleep 2; done