Skip to content

Instantly share code, notes, and snippets.

View tsaarni's full-sized avatar

Tero Saarni tsaarni

  • Ericsson
  • Finland
  • 07:56 (UTC +03:00)
View GitHub Profile
@tsaarni
tsaarni / bug-infinite-recursion-accidental-automatic-typecast.cpp
Last active August 29, 2015 14:24
Unintentional typecast that causes infinite recursive loop
// clang++ -Wall -std=c++11 -O0 -o test test.cpp && ./test
// g++ -Wall -std=c++11 -O0 -o test test.cpp && ./test
#include <iostream>
#include <vector>
#include <cstdio>
namespace Ns
{
// clang++ -Wall -std=c++11 -O0 -o scope-exit scope-exit.cpp && ./scope-exit
// g++ -Wall -std=c++11 -O0 -o scope-exit scope-exit.cpp && ./scope-exit
#include <iostream>
template <typename F>
struct ScopeExit
{
ScopeExit(F f) : f(f) {}
~ScopeExit() { f(); }
#include <boost/exception/diagnostic_information.hpp>
struct MyException : virtual boost::exception, virtual std::exception
{
virtual const char* what() const throw() { return boost::diagnostic_information_what(*this); }
};
@tsaarni
tsaarni / 00-PROFANITY-IN-DOCKER-README.md
Last active April 26, 2016 12:02
Run profanity inside docker

Profanity inside Docker container

Building the container image

Clone this repository:

git clone https://gist.github.com/0c6f5f31f874d39e0860c48fd4b575e8.git docker-profanity
cd docker-profanity

and then run following command to build the image:

@tsaarni
tsaarni / strapdown.cgi
Last active August 29, 2017 19:41
Configure Apache to render markdown files automatically
#!/bin/bash
#
# To make apache render files ending with .md with strapdown.js
# markdown renderer (http://strapdownjs.com/), add following lines
# to /etc/apache2/httpd.conf:
#
# Action markdown /cgi-bin/strapdown.cgi
# AddHandler markdown .md
# DirectoryIndex index.html index.md
#
@tsaarni
tsaarni / README.md
Last active November 8, 2017 20:23
Installing any version of go compiler on ubuntu

Prepare working environment for go compiler

Create "go path" directory (will store downloads and the source code that you yourself write)

mkdir ~/go

add following to your .bashrc or somewhere

if [ -d $HOME/go ]; then

export GOPATH=${HOME}/go

drivers/usb/host/dwc_otg/dwc_otg_hcd.c: In function ‘assign_and_init_hc’:
drivers/usb/host/dwc_otg/dwc_otg_hcd.c:1243:19: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
hc->xfer_buff = (uint8_t *) urb->dma + urb->actual_length;
^
drivers/usb/host/dwc_otg/dwc_otg_hcd.c:1287:21: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
hc->xfer_buff = (uint8_t *) urb->setup_dma;
^
drivers/usb/host/dwc_otg/dwc_otg_hcd.c:1318:21: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
hc->xfer_buff = (uint8_t *) hcd->status_buf_dma;
^
@tsaarni
tsaarni / readme.md
Last active December 28, 2019 09:51
Install any version of go (using existing installation of go)

Install any version of go

Get a list of all available go versions by running:

curl -s "https://golang.org/dl/?mode=json&include=all" | jq -r '.[].version' | sort -V

To install latest version of go (not including beta versions) by using existing go installation for bootstrapping:

GOLATEST=$(curl -s "https://golang.org/dl/?mode=json&include=all" | jq -r '.[].version | select(contains("beta") | not )' | sort -V | tail -1)

go get golang.org/dl/$GOLATEST # compiles go downloader

@tsaarni
tsaarni / README.md
Last active January 2, 2020 20:37
Multiboot in UEFI system with Windows 10 installed on separate drive

Windows boot entry missing from grub menu

Problem: After installing Windows 10 on separate disk, Windows entry is not visible in grub menu. Windows 10 installer might not have used GPT partition table, but instead is using MBR for booting. It might still look like UEFI boot since Windows created small system partition with bit similar content as EFI partition would have.

From https://askubuntu.com/questions/447686/how-to-boot-windows-8-from-a-legacy-mbr-partition-in-uefi-mode-via-grub

The custom GRUB entry isn't needed (at least not for windows 10's boot manager), you can install to the BCD to your main EFI partition, with "bcdboot C:\Windows /s X: /f UEFI", where X is the letter you assigned to the UEFI partition. You can assign a letter to the UEFI partition either using the windows gui or using "diskpart" command line utility. This works even if windows isn't in a GPT partition