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 / wp-slack.php
Last active August 29, 2015 13:57
Send new Wordpress posts to Slack
<?php
# based on https://gist.github.com/alexstone/9319715
function slack_post($post_id) {
if( ( $_POST['post_status'] == 'publish' ) && ( $_POST['original_post_status'] != 'publish' ) ) {
$room = "general"; // What Slack channel to send to
$post = get_post($post_id);
$author = get_userdata($post->post_author);
$message = "New post '" . get_the_title($post_id) . "' by {$author->user_firstname} - " . get_permalink($post->ID);
sudo: required
language: node_js
node_js:
- 5.0.0
services:
- docker
install: true
script:
- echo "Hey"
deploy:
@benjick
benjick / dogeipsum.php
Last active December 28, 2015 05:38
Doge Ipsum aka Lorem Doge by dumfan
<?php
/*
░░░░░░░░░▄░░░░░░░░░░░░░░▄░░░░
░░░░░░░░▌▒█░░░░░░░░░░░▄▀▒▌░░░
░░░░░░░░▌▒▒█░░░░░░░░▄▀▒▒▒▐░░░
░░░░░░░▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐░░░
░░░░░▄▄▀▒░▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐░░░
░░░▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌░░░
░░▐▒▒▒▄▄▒▒▒▒░░░▒▒▒▒▒▒▒▀▄▒▒▌░░
@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
<div>This is stuffed into the <body></div>
<p>Also this</p>
alert("yolo"); // this gets executued
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.
app.post('/upload', multipartMiddleware, (req, res) => { // multipartMiddleware is for multipart forms
console.log(req.body);
res.json({
foo: 'bar',
});
});
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;
});
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;