Skip to content

Instantly share code, notes, and snippets.

View palladius's full-sized avatar
🎯
Focusing on GCP, RoR and SRE

Riccardo Carlesso palladius

🎯
Focusing on GCP, RoR and SRE
View GitHub Profile
@palladius
palladius / migrate-snippets.md
Last active April 19, 2023 14:34
Some cool Migration Org bash scripts
@palladius
palladius / gcp-write-metric-excerpt.rb
Last active November 10, 2022 05:18
Push a generic metric name/number to GCP (excerpt of bigger script)
#!/usr/bin/env ruby
# full script here: https://github.com/palladius/sakura/blob/master/bin/gcp-write-metric
require 'google/cloud/monitoring'
require 'socket' # for hostname
require 'openssl'
require 'colorize' # makes life worth living
# I want to know server side who called me
@palladius
palladius / macbook-battery excerpt
Last active November 10, 2022 03:53
An excerpt with the logic of my Macbook Battery.
#!/usr/bin/env ruby
# Note1. buridone is currently not used. It's for a more efficient use to extrapolate all info from a single file read.
# Note2. This does NOT work on M1. I've just fixed this in the github repo sakura. Find the updated 0.2 code there.
def processMacCapacity(buridone)
ret = {}
ret[:debug] = 'Will fill numerator and denominator until I nail it.'
ret[:capacity_pct] = 142 # clearlly wrong
# `ioreg -l -w0 | grep AppleRawMaxCapacity`.split
# => ["|", "|", "\"AppleRawMaxCapacity\"", "=", "4320"]
#!/bin/bash
VER=1.0a
# This script extracts stats from previous one (latency-eu-us-script) and also publishes your public
# IP and the city you use script from.
# This part might not be super reliable, though.
#
# **Requires**
#
@palladius
palladius / latency-eu-us-script
Last active August 29, 2015 14:04
Test latency to two EU/US-hosted otherwise-identical GAE apps
#!/bin/bash
# This script tries to find the difference in latency between Us/EU HTTP/HTTPS AppEngine apps.
# Also testing a simple '/' path from a '/slow' (which does a sleep(1) and simulates some traffic on page).
# Appids:
# - http://eu-ricc-test.appspot.com/
# - http://us-ricc-test.appspot.com/
VER=1.1c
@palladius
palladius / bq-case-03352234
Last active December 21, 2015 04:18
I drafted the code in here
#!/bin/bash
# Case #03352234
# BQ load
# Riccardo modifications:
# 1. I added a sort/uniq to make sure the lines are unique.
# 2. I removed parallelism in bq commands.
#composed_files_gs_path='/path/to/gs/files'
@palladius
palladius / rcarlesso-ggadget-helloworld.xml
Created November 22, 2012 14:48
HelloWorld Riccardo GGadget v1.2
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Developer Forum v1.2"
title_url="http://groups.google.com/group/Google-Gadgets-API"
height="200"
category="from_googlers"
author="Riccardo Carlesso"
author_email="ricc@google.com"
>
<Require feature="setprefs" />
@palladius
palladius / iCalAddEntry.sh
Created December 11, 2011 12:18 — forked from joet3ch/iCalAddEntry.sh
MacOSX osascript to tell you what time is it
#!/bin/bash
DEFAULT_ALARM='current date'
alarm=$DEFAULT_ALARM
foo=`osascript <<EOF
tell application "iCal"
set newtodo to (make new todo at end of todos of calendar "Home")
tell newtodo
set summary to "Bills"
set due date to ($alarm)
@palladius
palladius / itunes.sh
Created December 11, 2011 12:16 — forked from rkumar/itunes.sh
control iTunes from command line (fichissimo!)
#!/bin/bash
#
####################################
# iTunes Command Line Control v1.0
# originally written by David Schlosnagle
# created 2001.11.08
# edit 2010.06.01 rahul kumar
# edit 2011.12.11 Riccardo Carlesso
####################################