Skip to content

Instantly share code, notes, and snippets.

View totomz's full-sized avatar

Tommaso Doninelli totomz

View GitHub Profile
@totomz
totomz / gist:4d033fa1b991504a4e31
Last active August 29, 2015 14:12
[GCE] Download and execute a powershell startup script from Google Cloud Storage in Google Cloud Engine
$gscript = "test-script/startup.ps1";Invoke-Expression $(Invoke-RestMethod -Uri $("https://storage-download.googleapis.com/"+$gscript+"?access_token=" + $($(Invoke-RestMethod -Uri "http://metadata/computeMetadata/v1/instance/service-accounts/default/token" -Headers @{"Metadata-Flavor"="Google"}).access_token)));
@totomz
totomz / gist:387910fb497f35d41c15
Created December 24, 2014 17:34
[GCE] Mounting disk
# Mounting pgdata disk
parted -s /dev/disk/by-id/google-pgdata mktable gpt
parted -s /dev/disk/by-id/google-pgdata mkpart primary ext4 0% 100%
sleep 5
mkfs.ext4 /dev/disk/by-id/google-pgdata-part1 -L pgdata
sleep 2
mkdir $PGDATA_MOUNT
echo "/dev/disk/by-id/google-pgdata-part1 $PGDATA_MOUNT ext4 noatime,data=writeback,barrier=0,nobh 0 2" >> /etc/fstab
mount -a
@totomz
totomz / gist:8523544
Created January 20, 2014 16:36
Export an Excel to a SQL-like text file
Sub ExportSQL()
Dim FilePath As String
Dim CellData As String
Dim LastCol As Long
Dim LastRow As Long
CellData = ""
FilePath = Application.ActiveWorkbook.Path & "\insert.sql"
@totomz
totomz / gist:ea7944ae9dd45930f10a
Created January 22, 2016 10:18
Monitor downloaded files
while true; do echo $(date +%H:%M:%S) $(awk "BEGIN { printf \"%6.2f%\n\", $(ls | grep -v .gstmp | wc -l)/135530 *100 }") $(df -h --output=avail /dev/sdd2 | awk END{print}) free; sleep 3; done
@totomz
totomz / gist:b00855bf66d3f85b04b54b5a35c17012
Created June 13, 2017 19:35
AppleScript to launch new windows instead of moving focus
# iTerm
```
tell application "iTerm"
set newWindow to (create window with default profile)
tell newWindow
activate
end tell
end tell
```
@totomz
totomz / phpnet.user.js
Created May 14, 2018 15:22
Greasemonkey/Tampermonkey redirect php.net pages to the ENG version
// ==UserScript==
// @name PHP Manual redirect
// @namespace https://github.com/totomz
// @version 0.1
// @description Force contents fro php.net/manual to be served in ENG!
// @author You
// @match http://php.net/manual/*
// @grant none
// ==/UserScript==
<script>
hbspt.forms.create({
portalId: "0000",
formId: "aaa-bbbb-cccc",
onFormReady: function($form){
var input = $form.find('input[type=email]');
input.addClass('form-control');
input.attr('placeholder','Enter your e-mail address');
<script>
hbspt.forms.create({
portalId: "0000",
formId: "aaa-bbb-ccc",
onFormReady: function($form){
var input = $form.find('input[type=email]');
input.addClass('form-control');
input.css('width', '100%');
@totomz
totomz / docker-attach.js
Created July 25, 2019 20:21
Sample js code to attach a running container using websocket
const WebSocket = require('ws');
const id = '81bf9a17d914';
const url = `ws+unix:///var/run/docker.sock:/containers/${id}/attach/ws?stream=1&stdout=1&logs=1`;
const socket = new WebSocket(url, {
perMessageDeflate: false
});
@totomz
totomz / rsync.sh
Created December 29, 2019 22:52
rsync max/linux
# Sync a local folder via ssh
rsync --delete -v -r -a --exclude=.git --exclude=.idea -h -e ssh ./ totomz@tomhost:/home/totomz/bomba