Skip to content

Instantly share code, notes, and snippets.

View GiovanniGrieco's full-sized avatar
💭
mumble mumble

Giovanni Grieco GiovanniGrieco

💭
mumble mumble
View GitHub Profile
@GiovanniGrieco
GiovanniGrieco / decompress_gzip_stream
Created June 16, 2013 15:42
Decompress a gzip stream that was pushed to a webserver
$x = file_get_contents("compress.zlib://php://input");
<?php
define("TIMEINTERVAL", 60); // define the interval in seconds
//we have a session, so I call it
session_start();
// if the user have not visited a page under an interval of 60 seconds, destroy the session
if ( (time() - $_COOKIE['session_time']) > TIMEINTERVAL ) {
@GiovanniGrieco
GiovanniGrieco / getTerminalCols
Last active August 29, 2015 14:12
Get terminal width - Cross-platform
<?php
function getTerminalCols()
{
$cols = 0;
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
$cmdHandler = popen('more', 'r');
$cmdInfo = fread($cmdHandler, 2096);
pclose($cmdHandler);
$cmdInfo = explode("\n", $cmdInfo);
$cols = trim(substr($cmdInfo[9], -4, 4));
@GiovanniGrieco
GiovanniGrieco / Imagine_Saviano2015.sh
Last active January 24, 2016 14:24
ITALIAN - Questo script scarica la puntata "Imagine - Saviano racconta il 2015", mandata in onda a dicembre 2015. Non sfrutta alcuna hack, infatti utilizza il metodo di streaming di brightcove e salva lo stream in locale.
#!/bin/sh
printf "Downloading metadata...\n"
url=$(curl -s "http://c.brightcove.com/services/mobile/streaming/index/master.m3u8?videoId=4677882746001" | grep http | tail -1)
i=0
curl -s "$url" | grep http > TSList.m3u8
cat TSList.m3u8 | while read -r line; do
printf -v out "fragment_%05d.ts" $i
printf "Downloading fragment %d / 494\r" $i
curl -s "$line" -o $out
i=$((i+1))
@GiovanniGrieco
GiovanniGrieco / Preferences.sublime-settings
Last active November 26, 2016 11:06
Personal settings for Sublime Text 3
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/Material Theme/schemes/Material-Theme.tmTheme",
"detect_intendation": false,
"font_face": "Roboto Mono",
"font_size": 12,
"highlight_line": true,
"ignored_packages":
@GiovanniGrieco
GiovanniGrieco / cleanup.sh
Created April 6, 2017 20:38
TODO things for Fedora at post-install
sudo dnf remove libreoffice* rhythmbox evolution gnome-calculator gnome-calendar cheese gnome-clocks gnome-contacts gnome-maps gnome-weather
sudo dnf update
sudo dnf install binutils gcc gcc-c++ patch bison cmake flex python perl-ExtUtils-MakeMaker perl-Thread-Queue vim
sudo reboot
@GiovanniGrieco
GiovanniGrieco / circumvent-gnome-memhog.sh
Last active April 28, 2018 20:17
Circumvent GNOME 3 Memory Leak
#!/usr/bin/bash
# Copyright 2018 Giovanni Grieco <giovanni.grc96@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
@GiovanniGrieco
GiovanniGrieco / calc_hash.py
Created November 10, 2018 23:21
Calulate md5 hash (or any other hash supported by Python) of a given string quickly. For more information: https://docs.python.org/3.7/library/hashlib.html
import hashlib
in = b'My beautiful input string'
hashlib.md5(in).hexdigest()
# '0b78bf24d7128899723fb0e5cf7648b6'
# List Installed Appx (Metro/Store/Modern Apps)
#Get-AppxPackage | Select Name
# Appx I do not need
# More info: https://docs.microsoft.com/it-it/windows/application-management/apps-in-windows-10
$AppxToRemove = @(
'Microsoft.Windows.Photos',
'Microsoft.WindowsCamera',
'Microsoft.WindowsStore',
'microsoft.windowscommunicationsapps',
  1. Write into /etc/wsl.conf
[automount]
options = "metadata"
  1. Restart WSL (Go to powershell and write wsl --shutdown, then reopen WSL2 terminal)
  2. Execute these commands below:
$ cd ~/
$ ln -s /mnt/c/Users//.ssh .ssh