Skip to content

Instantly share code, notes, and snippets.

@gfabrizi
gfabrizi / gogs-on-rpi.md
Created May 20, 2018 09:55 — forked from alex-shpak/gogs-on-rpi.md
Gogs on raspberry pi

Update and install dependencies

apt-get update; apt-get upgrade

dphys-swapfile swapoff
dphys-swapfile uninstall

apt-get remove -y --purge wolfram-engine triggerhappy xserver-common lightdm sonic-pi minecraft-pi pigpio
apt-get autoremove -y
@gfabrizi
gfabrizi / raspi-setup-gitea.md
Created May 20, 2018 09:59 — forked from mirhec/raspi-setup-gitea.md
Installing Gitea on Raspberry Pi with nginx, SSL and automatic backups

Setup Gitea on Raspberry Pi (3)

These instructions are based on this article: https://www.alexruf.net/2016/05/23/setup-gogs-git-service.html.

Setup Raspberry Pi with minimal Raspbian image. You need to connect to the HDMI port and set the following:

sudo raspi-config

There you need to enable the SSH server and you should change the hostname.

@gfabrizi
gfabrizi / humble_bundle_file_downloader.js
Created May 22, 2018 18:08 — forked from tlc/humble_bundle_file_downloader.js
Download HumbleBundle book bundles easier. Puts 'curl' statements on the page for you to copy.
/* 11/27/2017 - Tweaked for a page redesign.
* 1/6/2018 - Handle videos in book bundle.
*/
var pattern = /(MOBI|EPUB|PDF( ?\(H.\))?|CBZ)$/i;
var pattern2 = /(Download)$/;
var nodes = document.getElementsByTagName('a');
var downloadCmd = '';
for (i in nodes) {
var a = nodes[i];
if (a && a.text && pattern.test(a.text.trim())) {
git remote add upstream https://github.com/some_user/some_repo
git fetch upstream
git checkout master
git reset --hard upstream/master
git push origin master --force
Keep in mind, that this makes your repo look exactly like upstream - if you have commits, they will be eaten! If you want to update to upstream (but still keep your commits), you want git merge upstream/master. If you want to start a new patch based on upstream, the best way to do it is git checkout -b my-new-feature upstream/master
Of course, this all expects you have a remote named upstream, which you can create by doing git remote add upstream https://[upstream guy's repo url]
(Just to clarify, the term 'upstream' means the person you forked from)
@gfabrizi
gfabrizi / Docker.md
Created July 21, 2018 15:30
Docker Reference

Docker Reference

This week (May 2017) I have been learning about Docker... Here is what I've learned so far.

The shortcut commands in brackets refer to functions/aliases I've set up in my dotfiles.

Installing Docker on Ubuntu

sudo apt-get install docker docker-compose
@gfabrizi
gfabrizi / elastic-install.sh
Created July 27, 2018 08:36
Install ElasticSearch 0.90.13 on Debian 9 Stretch
#!/bin/bash
cd ~
# Install JDK
apt update
apt install openjdk-8-jre-headless
# Install & Start ES 0.90.1
@gfabrizi
gfabrizi / docker-save-load-images.sh
Created July 27, 2018 20:19 — forked from mathewdgardner/docker-save-load-images.sh
Save / load compressed docker images
#!/bin/bash
# Save docker images
ds() {
docker images | \
cut -d ' ' -f 1 | \
tail -n +2 | \
xargs -t -n 1 -I {} -P 4 \
sh -c 'docker save {} | bzip2 > $(echo "{}" | sed "s/^.*\///").tar.bz2'
}
@gfabrizi
gfabrizi / watchify.js
Last active February 14, 2020 22:12
[JOKE] How a website would look on a smartwatch? Try it by pasting this snippet in the web developer console! 😜🙃😂
let watchify = function() {
let watchFrame = Object.assign(document.createElement('div'), {id: 'watch_frame'});
let size = Math.min(document.documentElement.clientWidth, document.documentElement.clientHeight);
watchFrame.style.cssText = "position:fixed;width:" + size + "px;height:" + size + "px;top:50%;left:50%;margin-top:-" + size/2 + "px;margin-left:-" + size/2 + "px;box-shadow:0 0 0 99999px #000;border-radius:50%;z-index:2147483647;pointer-events:none";
if (oldWatchFrame = document.getElementById("watch_frame")) { oldWatchFrame.remove() }
document.querySelector('body').appendChild(watchFrame);
};watchify();window.addEventListener('resize', watchify);
@gfabrizi
gfabrizi / TheUnexpectedFizzBuzz.php
Created March 9, 2020 20:08
A different (...veeeery different) approach to the good old PHP FizzBuzz test
<?php
if ($argc !== 2 || !ctype_digit($argv[1])) {
echo "You must specifiy only one parameter: the max number as an integer" . PHP_EOL;
exit(1);
}
$input = (int) $argv[1];
$fizzBuzz = [