Skip to content

Instantly share code, notes, and snippets.

View MichalZalecki's full-sized avatar

Michał Załęcki MichalZalecki

View GitHub Profile
@MichalZalecki
MichalZalecki / await-async.js
Created November 13, 2015 05:16
Run generators and and await/async
import axios from "axios";
export default async function () {
const { data: { id } } = await axios.get("//localhost:3000/id");
const { data: { group } } = await axios.get("//localhost:3000/group");
const { data: { name } } = await axios.get(`//localhost:3000/${group}/${id}`);
console.log(name); // Michał
}
@MichalZalecki
MichalZalecki / .eslintrc.json
Last active May 29, 2016 15:38
Reasonable .eslint confiig
{
"extends": "airbnb",
"parser": "babel-eslint",
"settings": {
"import/resolver": {
"webpack": { "config": "./webpack/webpack.prod.config.js" }
}
},
"rules": {
"quotes": ["error", "double"],
@MichalZalecki
MichalZalecki / index.js
Created March 12, 2016 12:24
How to import RxJS 5
// Import all
import Rx from "rxjs/Rx";
Rx.Observable
.interval(200)
.take(9)
.map(x => x + "!!!")
.bufferCount(2)
.subscribe(::console.log);
@MichalZalecki
MichalZalecki / mixins-decorators.js
Last active May 29, 2016 19:23
Multiple mixins by using extends/decorators/virtual methods/stamps
function hi() {
console.log(`Hi ${this.name}!`);
}
function by() {
console.log(`By ${this.name}!`);
}
function mixin(fn, name = fn.name) {
return target => {
root=true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
@MichalZalecki
MichalZalecki / CycleRun.js
Created July 9, 2016 19:13
Mount Cycle.js app as react component
import React, { PropTypes, Component } from "react";
import ReactDOM from "react-dom";
import { makeDOMDriver } from "@cycle/dom";
import { run } from "@cycle/xstream-run";
class CycleRun extends Component {
static propTypes = {
main: PropTypes.func.isRequired,
drivers: PropTypes.object,
};
@MichalZalecki
MichalZalecki / visor-archivos-online.md
Created September 5, 2016 20:23 — forked from izazueta/visor-archivos-online.md
Google Docs Viewer & Office Web Apps Viewer

Google Docs Viewer

Only files under 25 MB can be previewed with the Google Drive viewer.

Google Drive viewer helps you preview over 16 different file types, listed below:

  • Image files (.JPEG, .PNG, .GIF, .TIFF, .BMP)
  • Video files (WebM, .MPEG4, .3GPP, .MOV, .AVI, .MPEGPS, .WMV, .FLV)
  • Text files (.TXT)
  • Markup/Code (.CSS, .HTML, .PHP, .C, .CPP, .H, .HPP, .JS)
  • Microsoft Word (.DOC and .DOCX)
@MichalZalecki
MichalZalecki / storage.js
Last active July 20, 2021 23:37
Simple sessionStorage/localStorage wrapper factory
import storageFactory from "./storageFactory";
export const localStore = storageFactory(localStorage);
export const sessionStore = storageFactory(sessionStorage);
@MichalZalecki
MichalZalecki / validateType.js
Last active May 5, 2017 10:03
Filter uploaded files by file type
export default function validateType(accepts) {
const typeExps = accepts.split(/ *, */).map(type => new RegExp(type));
return file => Boolean(typeExps.find(exp => exp.test(file.type)));
}
// function onChange({ target }) {
// const acceptedFiles = target.files.filter(validateType("images/*, application/pdf"));
// }
@MichalZalecki
MichalZalecki / Dockerfile
Last active January 25, 2023 23:23
Install oh-my-zsh in Docker
RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "zsh"]
RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true
# docker exec -it my-app-container /bin/zsh