Skip to content

Instantly share code, notes, and snippets.

View larsch's full-sized avatar

Lars Christensen larsch

View GitHub Profile
#!/bin/sh -ex
wget -N http://llvm.org/releases/3.4/llvm-3.4.src.tar.gz
wget -N http://llvm.org/releases/3.4/clang-3.4.src.tar.gz
wget -N http://llvm.org/releases/3.4/clang-tools-extra-3.4.src.tar.gz
wget -N http://llvm.org/releases/3.4/compiler-rt-3.4.src.tar.gz
mkdir -p llvm
tar xfz llvm-3.4.src.tar.gz -C llvm --strip-components=1
mkdir -p llvm/tools/clang
tar xfz clang-3.4.src.tar.gz -C llvm/tools/clang --strip-components=1
mkdir -p llvm/tools/clang/tools/extra
@larsch
larsch / cmakevs.rb
Last active August 29, 2015 13:57
Run CMake while closing Visual Studio Solution
#!/usr/bin/env ruby
#
# Script that makes updating Visual Studio Solutions from CMakeLists'
# easier, by closing the solution via COM and automatically re-running
# CMake in the corresponding build directory, then reopening and
# building the solution.
#
# Simply run 'cmakevs.rb' from the command line, and it will find an
# instance of Visual Studio and detect the open solution and re-run
# CMake.
#!/usr/bin/env ruby
#
# b - a cmake convinience tool
#
# Runs build commands (e.g. cmake --build ., ctest, etc) in the
# corresponding build directory, from the source directory. For
# example, this command automatically starts a build in the associated
# build directory:
#
# c:\source\git\repo> b
cmake_minimum_required(VERSION 2.8.11)
# Specify the project name. Not required for subprojects, but it
# will create a dingbat.sln for Visual Studio, which will only
# contain the dingbat project and its dependencies.
project(dingbat)
# Create variables with source and header files. Nice to have if we
# need them as arguments to custom macros.
set(sources dingbat.cpp)
@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
#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); \

Update package index and upgrade all installed packaged

pacman -Syu

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

Install packages from AUR:

#!/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
@larsch
larsch / esp-open-sdk-environment.sh
Created May 3, 2015 09:40
Environment variables for building for ESP8266 using esp-open-sdk
export SDK_BASE=$HOME/esp-open-sdk/esp_iot_sdk_v1.0.1
export XTENSA_TOOLS_ROOT=$HOME/esp-open-sdk/xtensa-lx106-elf/bin
export ESPTOOL=$HOME/esp-open-sdk/esptool/esptool.py
export PATH=$HOME/esp-open-sdk/xtensa-lx106-elf/bin:$PATH
@larsch
larsch / gist:185242
Created September 11, 2009 11:38
AutoHotkey script for window positioning like on Windows 7
;;
;; Mimic Windows7 window positions using Win+Up/Left/Right
;; Not tested with multiple monitors
;;
#up::
WinRestore A
WinMaximize A
return