Skip to content

Instantly share code, notes, and snippets.

@yagop
yagop / Readme.md
Last active November 15, 2017 09:56
Webtask bot sample

This is a sample Telegram Bot to showcase Webtask.

Hints included

  • Main function promisification through Bluebird.try and asCallback.
  • Query params and body access.
  • Secrets (TG_TOKEN)
  • Get the Webtask runner URL
  • Basic Telegram Bot API usage

Setup

@yagop
yagop / README.md
Last active October 22, 2017 19:49
Simple example of WebTask Storage

This example demostrate the usage of WebTask Storage with multiple models and how to save / filter / find them.

$ curl https://__host__.run.webtask.io/example\?action\=delete_all
{}

$ curl https://__host__.run.webtask.io/example\?action\=save_model \
  -H "Content-Type: application/json" \
  --data '{"modelName": "planets", "properties": {"name": "Earth"}}'
{}
@yagop
yagop / index.js
Last active June 27, 2017 11:56
Stream server
const ts = require('tail-stream')
const http = require('http')
const PORT = 1234
const HOST = '0.0.0.0'
const FILE = 'info.log'
const server = http.createServer((req, resp) => {
const tstream = ts.createReadStream(FILE, {
beginAt: 0,
@yagop
yagop / insomnia.sh
Created April 21, 2017 11:21
Insomnia REST Client Arch installer
#! /bin/bash
cd $(mktemp -d)
wget https://aur.archlinux.org/cgit/aur.git/snapshot/insomnia.tar.gz
tar xzf insomnia.tar.gz
cd insomnia
makepkg -s
sudo pacman -U insomnia-*-x86_64.pkg.tar
@yagop
yagop / node-js-app.service
Created January 7, 2017 15:30
Nodejs Systemd service example
[Unit]
Description=Node.js App
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/node-v7.4.0/bin/node index.js
WorkingDirectory=/home/yago/produccion/app
Environment="HOST=127.0.0.1"
Environment="PORT=1234"
@yagop
yagop / emojis.js
Created December 25, 2016 22:48
Simple Twitter emoji streamer
const emojisStr = '๐Ÿ˜€๐Ÿ˜‚๐Ÿ˜…๐Ÿ˜†๐Ÿ˜‡๐Ÿ˜˜๐Ÿ˜๐Ÿ˜œ๐Ÿ˜Ž๐Ÿค“๐Ÿ˜ถ๐Ÿ˜๐Ÿค—๐Ÿ˜๐Ÿ˜ก๐Ÿ˜Ÿ๐Ÿ˜ž๐Ÿ™„โ˜น๏ธ๐Ÿ˜”๐Ÿ˜ฎ๐Ÿ˜ด๐Ÿ’ค๐Ÿ’ฉ๐Ÿ˜ญ๐Ÿ˜ˆ๐Ÿ‘ฟ๐Ÿ‘Œ๐Ÿ‘ธ๐ŸŽ…๐Ÿ‘…๐Ÿ‘€๐Ÿ‘๐Ÿ’ช๐Ÿ‘ป๐Ÿค–๐Ÿ˜บ๐ŸŸ๐Ÿ ๐Ÿท๐ŸŒ๐Ÿผ๐Ÿบ๐Ÿฏ๐Ÿ…๐Ÿฆƒ๐Ÿ•๐Ÿ‡๐ŸŒพ๐ŸŽ๐Ÿ€๐Ÿพ๐ŸŒ๐ŸŒš๐ŸŒ๐ŸŒž๐ŸŒฆ๐Ÿ”ฅ๐Ÿ’ฅโ˜ƒ๏ธโœจโ„๏ธ๐Ÿ’ง๐Ÿ๐ŸŠ๐ŸŒ๐ŸŒฝ๐Ÿ”๐ŸŒฎโ˜•๏ธ๐Ÿงโšฝ๏ธ๐Ÿ๐ŸŽ–๐ŸŽน๐ŸŽฐ๐ŸŽฃ๐Ÿ“๐Ÿšต๐ŸŽฎ๐ŸŽฌ๐Ÿš—๐Ÿš“๐Ÿšจ๐Ÿš‹๐Ÿš ๐Ÿ›ฅ๐Ÿš€๐Ÿšข๐ŸŽ ๐Ÿšง๐Ÿšง๐Ÿšงโœˆ๏ธ๐Ÿฅ๐Ÿ“ฑโŒจ๐Ÿ’ป๐Ÿ“ ๐Ÿ“ž๐Ÿ”ฆ๐Ÿ’ด๐Ÿ’ธ๐Ÿ”ฎ๐Ÿ’Š๐Ÿ”ฌ๐Ÿ”ญ๐Ÿ“ซ๐Ÿ“ˆ๐Ÿ“‰๐Ÿ–‡โœ‚๏ธ๐Ÿ”’๐Ÿ”“๐Ÿ“’๐Ÿ’›โค๏ธ๐Ÿ’™๐Ÿ’”๐Ÿ’ž๐Ÿ’•๐Ÿ’๐Ÿ’˜๐Ÿšพโš ๏ธโ™ป๏ธ๐ŸŽต๐Ÿ’ฌ๐Ÿ•๐Ÿ‡ฌ๐Ÿ‡ง๐Ÿ‡บ๐Ÿ‡ธ๐Ÿ‡ช๐Ÿ‡ธ๐Ÿ‡ต๐Ÿ‡น๐Ÿ‡ณ๐Ÿ‡บ๐Ÿ‡ณ๐Ÿ‡ท๐Ÿ‡ฌ๐Ÿ‡พ๐Ÿ‡ฌ๐Ÿ‡ฆ๐Ÿ‡ฎ๐Ÿ‡ธ๐Ÿ‡ฏ๐Ÿ‡ต';
const emojis = [...emojisStr]
.filter(emoji => emoji.length > 0)
.filter(emoji => emoji !== '\uFE0F');
module.exports = emojis;
@yagop
yagop / config.toml
Last active December 9, 2016 22:50
Telegram bot torrent to folder
BotToken = "123456:AAAAAAA"
AdminId = 11696011
TorrentDownloadPath = "/tmp"
@yagop
yagop / irc.yago.me.conf
Created October 20, 2016 10:01
My Lounge IRC Configuration
server {
listen 80;
root /home/yago/production/lounge/client/;
server_name irc.yago.me;
autoindex off;
try_files $uri $uri @remote;
@yagop
yagop / base.sh
Last active April 10, 2018 21:50
My Scaleway Ubuntu base script
mkdir -p /mnt/downloads
chmod 777 /mnt/downloads/
sudo cp /usr/share/systemd/tmp.mount /etc/systemd/system/tmp.mount
sudo systemctl enable tmp.mount
sudo systemctl start tmp.mount
mkfs -t ext4 /dev/vdb
cp mnt-downloads.mount /etc/systemd/system/
systemctl enable mnt-downloads.mount
@yagop
yagop / hackerman.sh
Created April 23, 2016 23:08
Youtube2GIF
cd /tmp
youtube-dl "https://www.youtube.com/watch?v=bS5P_LAqiVg"
# 6s of durantion. Starting from 00:10:46. Kung Fury as input file. 11 fps. 640x360 frame size. Yes to all. Save as out.gif
ffmpeg -t 6 -ss 00:10:46 -i KUNG\ FURY\ Official\ Movie\ \[HD\]-bS5P_LAqiVg.mkv -r 11 -s 640x360 -y out.gif
# The maximum GIF file size for twitter is 5MB, our file is 4.8MB