Skip to content

Instantly share code, notes, and snippets.

n = ((n >> 1) & 0x55555555) | ((n << 1) & 0xaaaaaaaa);
n = ((n >> 2) & 0x33333333) | ((n << 2) & 0xcccccccc);
n = ((n >> 4) & 0x0f0f0f0f) | ((n << 4) & 0xf0f0f0f0);
n = ((n >> 8) & 0x00ff00ff) | ((n << 8) & 0xff00ff00);
n = ((n >> 16) & 0x0000ffff) | ((n << 16) & 0xffff0000);
// -- C code which reverses the bits in a word
@azeey
azeey / git_submodule_remote_merge
Created November 11, 2010 05:25
Pulls updates for each submodule from the remote repository
git submodule foreach git merge origin/master
@azeey
azeey / dotfiles_setup.sh
Last active September 25, 2015 14:37
Setup Dotfiles from github
#!/bin/bash
# This gist can be run with the following command. (May not always work)
# wget https://gist.github.com/azeey/936969/raw/dotfiles_setup.sh -O- | bash
DOTFILES_DIR="$HOME/dotfiles"
GIT_URL="git://github.com/azeey/dotfiles.git"
# Update repo
sudo su <<EOF
apt-get update
@azeey
azeey / 82-ez430.rules
Last active December 17, 2015 17:19
Udev rule for the MSP-EXP430F5529 which uses eZ430-EMULATION for programming and debugging
#mspdebug
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="f432", MODE="0666", GROUP="users"
#msp430-bsl
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2047", ATTRS{idProduct}=="0200", MODE="0666", GROUP="users"
#msp fet430uif
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="f430", MODE="0666", GROUP="users"
@azeey
azeey / ctags-nesc
Last active December 18, 2015 05:09
Ctag command for TinyOS/Nesc
ctags -R --regex-c='/^(generic )?module[ \t]*([a-zA-Z0-9_]+)/\2/d,definition/' \
--regex-c='/^(generic )?configuration[ \t]*([a-zA-Z0-9_]+)/\2/d,definition/' \
--regex-c='/^interface[ \t]*([a-zA-Z0-9_]+)/\1/d,definition/' \
--langmap=c:.nc.h --language-force=c -L taglist
@azeey
azeey / .ctags
Created July 5, 2013 15:59
.ctags file for nesc
--langdef=nesC
--langmap=nesC:.nc
--regex-nesC=/^[ \t]*configuration[ \t]*([a-zA-Z0-9_]+)/\1/b,configuration/
--regex-nesC=/^[ \t]*generic configuration[ \t]*([a-zA-Z0-9_]+)/\1/b,configuration/
--regex-nesC=/^[ \t]*command[ \t]*([a-zA-Z0-9_]+)[ \t]+([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)[ \t]*\(/\1 \2\.\3/c,command/
--regex-nesC=/.*\.([a-zA-Z0-9]+)[ \t]*->.*/\1/d,definition/
--regex-nesC=/^[ \t]*event[ \t]*([a-zA-Z0-9_]+)[ \t]+([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)[ \t]*\(/\1 \2\.\3/e,event/
--regex-nesC=/^[ \t]*void[ \t]+([a-zA-Z0-9_]+)[ \t]*\(/void \1/f,function/
--regex-nesC=/^[ \t]*inline[ \t]+([a-zA-Z0-9_]+)[ \t]+([a-zA-Z0-9_]+)[ \t]*\(/\1 \2/f,function/
--regex-nesC=/^[ \t]*interface[ \t]*([a-zA-Z0-9_]+)/\1/i,interface/
@azeey
azeey / 82-cc-tool.rules
Created February 19, 2014 17:45
Udev rules for cc-tools
# SmartRF05 Evaluation Board
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="16a0", MODE="0666"
# SmartRF04 Evaluation Board
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="11a0", ATTRS{idProduct}=="db20", MODE="0666"
# CC Debugger
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="16a2", MODE="0666"
@azeey
azeey / ncc-dump
Created May 29, 2014 16:18
ncc-dump
#!/bin/sh
#set -x
ncc "-fnesc-dump=referenced(interfaces,components,functions)" "-fnesc-dump=functions(!global())" "-fnesc-dump=interfaces" "-fnesc-dump=components(wiring)" "-fnesc-dump=interfacedefs" -fsyntax-only $@
- git: {local-name: mitsubishi_arm, uri: 'git://github.com/azeey/mitsubishi_arm.git'}
- git: {local-name: mac_ros, uri: '[email protected]:azeey/mac.git'}
@azeey
azeey / CMakelists.patch
Created January 10, 2020 17:07
Add address and leak sanitizer to sdformat
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -199,16 +199,21 @@ else()
endif()
filter_valid_compiler_warnings(${WARN_LEVEL} -Wextra -Wno-long-long
-Wno-unused-value -Wno-unused-value -Wno-unused-value -Wno-unused-value
-Wfloat-equal -Wshadow -Winit-self -Wswitch-default
-Wmissing-include-dirs -pedantic -Wno-pragmas)