Skip to content

Instantly share code, notes, and snippets.

View larsch's full-sized avatar

Lars Christensen larsch

View GitHub Profile
@larsch
larsch / bootstrap-esp-open-sdk-arch.sh
Last active January 6, 2017 16:57
Bootstrap script for ESP8266 SDK on Arch Linux
#!/bin/sh -exu
sudo pacman -S --needed --noconfirm base-devel python2 expat ncurses gperf git wget unzip
sudo ln -sf /usr/bin/python2 /usr/bin/python
git clone --recursive https://github.com/pfalcon/esp-open-sdk.git
cd esp-open-sdk
make STANDALONE=y
@larsch
larsch / list-installed-arch.sh
Last active December 26, 2016 14:46
List packaged installed in Arch Linux (except base/base-devel)
comm -23 <(pacman -Qq|sort) <(pacman -Qqg base base-devel|xargs -n1 pactree -ul|sort -u)
#!/bin/sh -ex
sudo pacman --needed --noconfirm -S base-devel
curl -LO https://github.com/larsch/libbcm2835-aur/archive/v1.42-1.tar.gz
tar xfz v1.42-1.tar.gz
cd libbcm2835-aur-1.42-1
makepkg -sf
sudo pacman --noconfirm -U libbcm2835*.pkg.tar.xz
curl -LO https://aur.archlinux.org/packages/ra/raspi-off-button/raspi-off-button.tar.gz
#!/bin/sh -ex
sudo pacman -Sy base-devel --needed --noconfirm
curl -O https://aur.archlinux.org/packages/pa/package-query/package-query.tar.gz
tar xfz package-query.tar.gz -C /tmp
pushd /tmp/package-query
makepkg --noconfirm -sf
sudo pacman -U --noconfirm package-query-*.pkg.tar.xz
popd
curl -O https://aur.archlinux.org/packages/ya/yaourt/yaourt.tar.gz
tar xfz yaourt.tar.gz -C /tmp

Update package index and upgrade all installed packaged

pacman -Syu

(S = sync, y = update, u = upgrade installed)

Install packages from AUR:

  1. Partion the disk
parted /dev/sda
mklabel gpt
mkpart ext2 1 3
set 1 bios_grub on
mkpart ext2 3 131
mkpart ext4 131 -1
  1. Create the file systems
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
void* thread_routine(void* param) {
printf("I'm running\n");
}
#define CP(x) \
{ int r = (x); \
@larsch
larsch / create-arch-image-raspberry-pi-2.sh
Last active March 11, 2024 13:55
Shell script that creates a Arch Linux image for the Raspberry Pi 2. Downloads the latest distribution from archlinuxarm.org and creates the flash filesystems including boot partition. Partitions are aligned for typical SD cards and ext filesystem tuned accordingly.
#!/bin/sh -ex
losetup /dev/loop0 && exit 1 || true
image=arch-linux-$(date +%Y%m%d).img
wget -q -N http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
truncate -s 1G $image
losetup /dev/loop0 $image
parted -s /dev/loop0 mklabel msdos
parted -s /dev/loop0 unit s mkpart primary fat32 -- 1 65535
parted -s /dev/loop0 set 1 boot on
parted -s /dev/loop0 unit s mkpart primary ext2 -- 65536 -1
@larsch
larsch / human_size.rb
Created September 22, 2014 04:02
Number to human file size conversion (IEC units)
def human_size(n)
return "0 B" if n.zero?
sizes = %w{B KiB MiB GiB TiB PiB EiB ZiB YiB}
x = (Math.log(n) / Math.log(1024)).floor
n = n / (1024.0 ** x)
n = n.round(2)
n = n.to_i if n.round == n
"#{n} #{sizes[x]}"
end
option(WITH_VLD "With Visual Leak Detection" OFF)
if(WITH_VLD AND MSVC)
message("Enabling Visual Leak Detector")
find_library(VLD vld
HINTS "c:/Program Files (x86)/Visual Leak Detector/lib/Win32" "c:/Program Files/Visual Leak Detector/lib/Win32")
find_file(VLD_H vld.h
HINTS "c:/Program Files (x86)/Visual Leak Detector/include" "c:/Program Files/Visual Leak Detector/include")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FIwinsock2.h")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \"/FI${VLD_H}\"")
get_filename_component(VLD_LIBRARY_DIR "${VLD}" PATH)