Skip to content

Instantly share code, notes, and snippets.

View maciekgrzybek's full-sized avatar
🏠
Working from home

maciek_grzybek maciekgrzybek

🏠
Working from home
View GitHub Profile

Keybase proof

I hereby claim:

  • I am maciekgrzybek on github.
  • I am maciejgrzybek (https://keybase.io/maciejgrzybek) on keybase.
  • I have a public key ASCBYRW-OGnwomR69i2XT9b8lnlSmU8Vj0dYryhBASma7Ao

To claim this, I am signing this object:

@maciekgrzybek
maciekgrzybek / clean-memory-docker.sh
Last active August 20, 2019 09:44
Removes exited docker images, to clean up some space - fix the 'No space left on device error'
docker rm $(docker ps -q -f 'status=exited') // OR
docker rmi $(docker images -q -f "dangling=true")
const AWS = require('aws-sdk');
module.exports = async (meta) => {
const rekognition = new AWS.Rekognition();
const params = {
Image: {
S3Object: {
Bucket: meta.bucket.name,
Name: meta.object.key,
},
module.exports = (username, labels = []) => {
let message = '';
const ANIMAL_LABELS = ['Animal', 'Mammal', 'Bird', 'Fish', 'Reptile', 'Amphibian'];
const isAnimal = labels.length && labels.some(label => ANIMAL_LABELS.includes(label.Name));
if (labels.length === 0) {
message = `Sorry @${username}, you need to upload an image.`;
} else if (isAnimal) {
const recongizedLabels = labels.map(label => label.Name);
message = `Hi @${username}. On your image, I can recognize: ${recongizedLabels.join(', ')}.`;
const TwitterController = require('../TwitterController');
module.exports.handler = async () => {
const controller = new TwitterController(
process.env.TWITTER_CONSUMER_KEY,
process.env.TWITTER_CONSUMER_SECRET,
process.env.TWITTER_TOKEN,
process.env.TWITTER_TOKEN_SECRET,
process.env.URL_BASE,
const crypto = require('crypto');
const encodeCrc = (crcToken, consumerSecret) => crypto.createHmac('sha256', consumerSecret).update(crcToken).digest('base64');
module.exports.handler = async (event) => {
const responseToken = encodeCrc(
event.queryStringParameters.crc_token,
process.env.TWITTER_CONSUMER_SECRET,
);
return {
setRequestOptions(type, webhhokId) {
let url = null;
let content = {};
const { urlBase, environment, credentials, crcUrl } = this;
switch (type) {
case ('registerWebhook'):
url = `${urlBase}${environment}/webhooks.json`;
content = {
form: {
const request = require('request-promise');
module.exports = class TwitterController {
constructor(consumerKey, consumerSecret, token, tokenSecret, urlBase, environment, crcUrl) {
this.consumerKey = consumerKey;
this.consumerSecret = consumerSecret;
this.token = token;
this.tokenSecret = tokenSecret;
this.urlBase = urlBase;
this.environment = environment;
@maciekgrzybek
maciekgrzybek / gist:536cc60788e26fc590bd
Created January 19, 2016 21:09
Puting img in div ///// WORDPRESS
add_filter( 'image_send_to_editor', 'wp_image_wrap_init', 10, 8 );
function wp_image_wrap_init( $html, $id, $caption, $title, $align, $url, $size, $alt ) {
return '<div id="wp-image-wrap-'. $id .'" class="wp-image-wrap">'. $html .'</div>';
}