Skip to content

Instantly share code, notes, and snippets.

@gentunian
gentunian / spreadshitter.js
Created March 27, 2020 17:36
I think we should change the name :)
/**
* Usage:
* var foo = new SpreadShitter({
* sheetId: <this id is in the spreadsheet url>,
* googleApiKey: <any google api key>});
* var sheetName = "My sheet";
* var range ="!A1:A2";
* foo.getValue(sheetName, range, function(data, errorEvent) {
* // handle logix here...
* })
@gentunian
gentunian / demo.sh
Created March 17, 2020 19:41
tmux code golf
#!/bin/sh
splitHorizontal() { tmux split-window -d -t 0 -h ; }
splitVertical() { tmux split-window -d -t $1 -v ; }
replicateM() { for i in `seq 1 $1`; do splitHorizontal; done }
splitEven() { for i in `seq 0 $1`; do splitVertical $(($i * 2)); done }
@gentunian
gentunian / network-order.sh
Last active February 13, 2019 20:31
Prove that docker network order is dict based and compose order is not respected
#!/bin/bash
# autogenerate compose file avoiding file name colisions in the current directory
COMPOSE_FILE_NAME=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 10).xml
cat << EOF > ${COMPOSE_FILE_NAME}
version: "3.4"
services:
alpine:
image: alpine
@gentunian
gentunian / hash2json.sh
Created November 19, 2018 17:53
redis hash to json with awk
redis-cli --raw -d "," hgetall mykey | awk -F',' 'BEGIN { print "{" }
{ for (i=1; i < NF; i++) {
if (i%2) {
printf "\"%s\"", $i
} else {
printf ":%s,\n", $i
}
}
}
END { printf ":%s\n}", $NF}'
@gentunian
gentunian / brightness.sh
Created July 1, 2018 06:33
linux: set brightness using bash for later assign a key bind
#!/bin/bash
# Author: Sebastian Treu
# Date: 2018.06.01
#
# You will need root access for using this script. The best thing you can do
# is to add this script to the sudoers file (or just don't use it :)
#
usage() {
echo "Usage:"
@gentunian
gentunian / gist:3fa473317935db664d4ea2870305b1ab
Last active June 17, 2017 23:52
how to upload a file from body response?
var request = require('request');
var slack_token = process.env.SLACK_TOKEN;
var channel = process.env.SLACK_CHANNEL;
request.post({
url: 'https://slack.com/api/auth.test',
formData: {
token: slack_token
}
@gentunian
gentunian / mock-autoreg-event
Last active February 4, 2022 09:11
educational purpouses: describe how autoregistration works
#!/usr/bin/env bash
#
# Copyright note:
# ---------------
#
# This script is a modification from:
# https://support.zabbix.com/secure/attachment/49385/get.sh
# written by gleb@irc#zabbix
#
@gentunian
gentunian / dialog.html
Last active August 26, 2015 19:29
reactive dialogs without extra packages?
<template name="dialog">
<div class="modal fade" id="{{dialogId}}">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">{{dialogTitle}}</h4>
</div>
@gentunian
gentunian / selector.js
Last active August 29, 2015 14:27
tabular server-side selector
selector: function( userId ) {
var roleNames = _.pluck(Roles.find({users: {$in: [userId]}}, {fields: {name: 1, _id: 0}}).fetch(), 'name');
var users = [];
var query;
if (_.contains(roleNames, 'manager')) {
// this wrapping is just for keeping the code readable
query = Meteor.users.find({}, { fields: {_id: 1 }, transform: function (doc) { doc.users = doc._id; return doc;}});
// or:
// query = { users: [ userId ] };
} else if (_.contains(roleNames, 'admin')) {
{{#autoForm ... }}
...
{{> afQuickField name="createdBy" }}
...
{{/autoForm}}