Skip to content

Instantly share code, notes, and snippets.

View ibolmo's full-sized avatar
🧠

Olmo Maldonado ibolmo

🧠
View GitHub Profile
@ibolmo
ibolmo / jsonapi_oas.yml
Created July 6, 2020 20:13 — forked from naesean/jsonapi_oas.yml
OpenAPI 3.0 schemas that comply with the JSON:API 1.0 specification
JSONAPIObject:
description: Includes the current JSON:API version for this specification as well as optional meta information
type: object
required:
- version
properties:
version:
type: string
default: '1.0'
example: '1.0'
javascript:(function()%7B(function(params)%20%7Bsleep%20%3D%20async%20(timeout%20%3D%201000)%20%3D%3Enew%20Promise(resolve%20%3D%3E%20setTimeout(resolve%2C%20timeout))%3BfindDeletable%20%3D%20()%20%3D%3E%5B...document.querySelectorAll(%22.branch-actions%22)%5D.filter(el%20%3D%3Eel.querySelector(%22.State--red%22)%20%7C%7C%20el.querySelector(%22.State--purple%22)).map(el%20%3D%3E%20el.querySelector(%22form%20button%22))%3BclickDelete%20%3D%20async%20deletable%20%3D%3E%20%7Bfor%20(button%20of%20deletable)%20%7Bbutton.click()%3Bawait%20sleep()%3B%7D%7D%3BnextPage%20%3D%20async%20()%20%3D%3E%20%7Bawait%20sleep(2000)%3Bnext%20%3D%20%5B...document.querySelectorAll(%22.pagination%20a%22)%5D.filter(el%20%3D%3E%20%2FNext%2F.test(el.innerText))%5B0%5D%3Bif%20(!next)%20throw%20new%20Error(%22done%3F%22)%3Bnext.click()%3B%7D%3Bgo%20%3D%20async%20()%20%3D%3E%20%7Bawait%20clickDelete(findDeletable())%3Bawait%20nextPage()%3B%7D%3Bgo()%3B%7D)()%7D)()
@ibolmo
ibolmo / imgpbcopy
Created June 20, 2018 15:43
Copy an image (from URL) into your clipboard
#!/bin/bash
tmp_image_file="$TMPDIR.imgpbcopy.png"
curl $1 > $tmp_image_file
osascript -e "set the clipboard to (read (POSIX file \"$tmp_image_file\") as JPEG picture)"
@ibolmo
ibolmo / graylog-alert.js
Created September 28, 2017 02:53
Get alerted when graylog has a new item.
count = () => $('.fields-row').length;
isEmpty = () => $('h1')[0].innerText == 'Nothing found';
tick = () => {
if (isEmpty()) {
found = 0;
} else if (found < count()) {
alert('Found new stuff!');
@ibolmo
ibolmo / recipe.js
Created July 6, 2017 21:28
A Zapier Platform CLI resource with hooks inside.
const _sharedBaseUrl = 'http://57b20fb546b57d1100a3c405.mockapi.io/api';
const subscribeHook = (z, bundle) => {
// `z.console.log()` is similar to `console.log()`.
z.console.log('console says hello world!');
z.console.log(bundle);
// bundle.targetUrl has the Hook URL this app should call when a recipe is created.
const data = {
url: bundle.targetUrl,
@ibolmo
ibolmo / dshell
Last active September 12, 2017 18:14 — forked from bcooksey/dshell
dshell: A little wrapper around the docker-compose run command that intelligently gets you a shell inside a container
#!/bin/bash
CONTAINER_ID=`docker ps -f status=running -f name=web_run -n 1 | head -n 2 | tail -n 1 | cut -d' ' -f1`
if [[ "${CONTAINER_ID:0:9}" = "CONTAINER" ]]; then
echo "No container exists, creating it (hit enter after a sec to bring up terminal)..."
docker-compose run --service-ports web /bin/bash
exit 0
fi
@ibolmo
ibolmo / node.green.js
Created December 9, 2016 18:48
Adds filtering of node.green results. Append ?max=4 to url. Uses: https://github.com/defunkt/dotjs
const get = (url, key) => {
const a = document.createElement('a');
a.href = url;
if (!a.search) return null;
const regex = new RegExp(key, 'i');
return a.search.split('&').filter(regex.test, regex)[0].split('=')[1];
}
const max = get(location.href, 'max');
if (max) {
@ibolmo
ibolmo / URLShortener.js
Last active December 5, 2016 18:15
Google Apps Script (Google Form) web service for creating service like: yourdomain.com/l/slug to http://web.com/page
SHEET_ID = '...';
LINKS_UPDATE_WEBHOOK_URL = '...';
function doGet(request) {
if (!request) request = { parameter: {secret: null} };
var set = {};
SpreadsheetApp.openById(SHEET_ID).getSheets().forEach(function(sheet){
var name = sheet.getName().toLowerCase();
@ibolmo
ibolmo / github-spy-partial.js
Last active October 6, 2016 01:44
This is portion of the https://github.com/ibolmo/github-spy main index.js file. Refactored, and documented for edification.
var pagesEnroute = {};
var keensEnroute = {};
var uid = 0;
USERS.forEach(function(user){
var handleEvents = function(err, events){
if (err) throw new Error(err);
var Animal = function(name){
this.name = name;
};
Animal.prototype.speak = function(){
console.log(this.name);
};
var Dog = function(name){
Animal.call(this, name);