Skip to content

Instantly share code, notes, and snippets.

View Canx's full-sized avatar

Ruben Cancho Canx

View GitHub Profile
@trinitronx
trinitronx / start_x11vnc.sh
Last active December 11, 2022 13:33
A script to start x11vnc server and retry with magic cookie if a desktop session is not created. This allows one to SSH into a box with only a gdm or login screen but no existing desktop session and start x11vnc to login the first time.
#!/bin/bash
DEFAULT_DISPLAY=:0
X11VNC_DISPLAY="$DEFAULT_DISPLAY"
if [ -x /usr/bin/x11vnc ]; then
[ "$1" == '-nocache' ] && CACHE_FLAG='-noncache' || CACHE_FLAG='-noncache'
[ "$2" == '-guess' ] && GUESS_FLAG='-auth guess' || GUESS_FLAG=''
[ -f /root/.vnc/passwd ] && PASSWORD="/root/.vnc/passwd"
[ -f $HOME/.vnc/passwd ] && PASSWORD="$HOME/.vnc/passwd"
[ ! -z "$PASSWORD" ] && x11vnc -display $X11VNC_DISPLAY -xkb -rfbauth $PASSWORD -rfbport 5900 -shared -forever -nowf -norc -notruecolor -bg $GUESS_FLAG $CACHE_FLAG -noxdamage
@raelgc
raelgc / Install MSOffice on Ubuntu.md
Last active February 26, 2024 03:10
Install MSOffice on Ubuntu

Install Microsoft Office 2010 on Ubuntu

Requirements

We'll install MSOffice using the PlayOnLinux wizard. Additionally, MSOffice requires samba and winbind to properly work.

So, if not installed, install them:

sudo apt-get install playonlinux samba winbind
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@charles-cooper
charles-cooper / shutdown_idle.sh
Created June 30, 2016 14:10
Cron job to shut down an idle computer
#!/bin/sh
# This script, intended to be run as a cron job, checks if there are any logins or recent logins and shuts down if there are none. It is not intended to be portable and was written on a Ubuntu 16.04 machine.
last_login_time=$(grep "systemd-logind" /var/log/auth.log | perl -pe "s/ ip.*//" | tail -1 | date --file=/dev/stdin +%s)
if [ $(($cur_time - $last_login_time)) -ge 3600 ] && [ $(who | wc -l) -eq 0 ]
then
init 0
else
@plembo
plembo / fixsnmpdubu.md
Last active December 8, 2020 15:32
Fixing SNMPD on Ubuntu

Fixing SNMPD on Ubuntu

SNMP is a foundational protocol for enterprise network and system management. Getting it right shows that a vendor actually cares about servicing IT in the enterprise. Debian, and its downstream progeny, Ubuntu, ship a configuration for the SNMP server, snmpd, that's so broken it positively screams "I don't care".

This brokenness is a known thing. The following bug reports go back to , but nothing has been done to address them:

The following has been tested on both Ubuntu 16.04 LTS and 18.04 LTS.

First steps

@tanaikech
tanaikech / submit.md
Created August 20, 2018 01:03
Replacing Text to Image for Google Document using Google Apps Script

Replacing Text to Image for Google Document using Google Apps Script

This is a sample script for replacing text to image for Google Document using Google Apps Script (GAS). There is a method for replacing text to text at Class Text of DocumentApp. But there are not methods for replacing text to image. So I created this sample script.

Demo :

This sample image was created by k3-studio.

Usage :

@Jiab77
Jiab77 / raspberry-pi-2-3-and-4-wireless-bridge-ubuntu-server-18.04-arm+netplan.md
Last active July 22, 2024 11:54
The initial goal of this project is to use the raspberry pi in place of my Wireless Range Extender and then going from 3 wireless networks (2.4ghz, 2.4ghz extended, 5ghz) at home to only one (5ghz). This way I'm reducing the exposition to radio waves for the whole familly at home.

Raspberry Pi 2/3B/B+/4B Wireless Bridge using Ubuntu Server 18.04 ARM Image and Netplan

The initial goal of this project is to use the raspberry pi in place of my Wireless Range Extender and then going from 3 wireless networks (2.4ghz, 2.4ghz extended, 5ghz) at home to only one (5ghz). This way I'm reducing the exposition to radio waves for the whole familly at home.

Let's go technical

Ok, enough drama for now, let's go technical. 😁

Setup

@garymacindoe
garymacindoe / redshift.conf.d
Last active June 30, 2021 10:22
OpenRC Initscripts for Redshift
# /etc/conf.d/redshift
DISPLAY="${DISPLAY:-:0}"
# Make it a function in case we have to repeat it in init script later
set_xauth() {
# common case (works in almost all tested environments (except of lightdm)):
#XAUTHORITY="$(ps wwax -C X,Xorg -o args= --sort=-stime | grep -m 1 -o '\B[-]auth\s*/var\S*' | cut -d ' ' -f 2)"
@caseywatts
caseywatts / 0-self-publishing.md
Last active October 5, 2024 11:27
Self-Publishing via Markdown
@wrighter
wrighter / get_ticks.py
Created January 23, 2020 23:45
A basic Interactive Brokers command line Python application to fetch streaming market data.
#!/usr/bin/env python
""" A simple Interactive Brokers application that will fetch
current market data for a contract from the IB TWS/Gateway. """
import argparse
import logging
from typing import List
from ibapi import wrapper