Skip to content

Instantly share code, notes, and snippets.

View benjick's full-sized avatar
🌱
🅱enjick

Max Malm benjick

🌱
🅱enjick
  • Sweden
View GitHub Profile
@benjick
benjick / router.js
Last active June 20, 2017 11:41
mobx router
import Route from 'route-parser';
import {extendObservable, computed} from 'mobx';
class Router {
constructor(routes, notFound) {
extendObservable(this, {
routes: [],
currentPath: window.location.pathname,
notFound: null,
current: computed(() => this.computeCurrent()),
<input
type="file" onChange={(e) => {
const file = e.target.files[0];
const metadata = {
contentType: 'image/jpeg',
};
const imageRef = storageRef.child(`images/${file.name}`);
const uploadTask = imageRef.put(file, metadata);
import fetch from 'node-fetch';
const channel = 'C03T4C7MS';
const channelInfoUrl = `https://slack.com/api/channels.info?token=${token}&channel=${channel}`;
const userListUrl = `https://slack.com/api/users.list?token=${token}`;
async function fetchUsers() {
try {
let usersInChannel = await fetch(channelInfoUrl).then(res => res.json());
usersInChannel = usersInChannel.channel.members;
User.defineStatic('validate', async function validateUser(email, password) {
const user = await User.getAll(email, { index: 'email' }).run();
if (user.length !== 1) {
throw new Error('No user found');
}
if (!compare(password, user[0].password)) {
throw new Error('Wrong password');
}
return true;
});
app.post('/upload', multipartMiddleware, (req, res) => { // multipartMiddleware is for multipart forms
console.log(req.body);
res.json({
foo: 'bar',
});
});
import Html exposing (li, text, ul)
import Html.Attributes exposing (class, href)
{-| This snippet uses the <ul> and <li> tags to create an unorderd
list of French grocery items. Notice that all occurrences of 'ul'
and 'li' are followed by two lists. The first list is for any HTML
attributes, and the second list is all the HTML nodes inside the
tag.
<div>This is stuffed into the <body></div>
<p>Also this</p>
alert("yolo"); // this gets executued
@benjick
benjick / todo
Last active February 2, 2016 11:50
Serier
The Expanse
Childhood's End
One Punch Man
The Magicians
Narcos
Jessica Jones
House of Cards
Peaky Blinders
Bloodline
Con Man
@benjick
benjick / dogeipsum.php
Last active December 28, 2015 05:38
Doge Ipsum aka Lorem Doge by dumfan
<?php
/*
░░░░░░░░░▄░░░░░░░░░░░░░░▄░░░░
░░░░░░░░▌▒█░░░░░░░░░░░▄▀▒▌░░░
░░░░░░░░▌▒▒█░░░░░░░░▄▀▒▒▒▐░░░
░░░░░░░▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐░░░
░░░░░▄▄▀▒░▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐░░░
░░░▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌░░░
░░▐▒▒▒▄▄▒▒▒▒░░░▒▒▒▒▒▒▒▀▄▒▒▌░░
sudo: required
language: node_js
node_js:
- 5.0.0
services:
- docker
install: true
script:
- echo "Hey"
deploy: