Skip to content

Instantly share code, notes, and snippets.

View atomictom's full-sized avatar

Thomas Manning atomictom

  • Google
  • Dublin, Ireland
View GitHub Profile

Keybase proof

I hereby claim:

  • I am atomictom on github.
  • I am atomictom (https://keybase.io/atomictom) on keybase.
  • I have a public key whose fingerprint is ABF1 8947 B280 6045 EE7F 3255 3F61 3807 B9F9 BC1B

To claim this, I am signing this object:

import time
import math
import pymavlink
import droneapi.lib
from pymavlink import mavutil
from droneapi.lib import VehicleMode
DEBUG = True
GPS_3D_FIX = 3
import time
import math
import pymavlink
import droneapi.lib
from pymavlink import mavutil
from droneapi.lib import VehicleMode
DEBUG = True
GPS_3D_FIX = 3
#!/usr/bin/python
import os
import sys
class Node(object):
def __init__(self):
self.is_word = False
self.children = {}
#!/usr/bin/python
import os
import sys
class Node(object):
def __init__(self):
self.is_word = False
self.children = {}
import Text.Parsec
import Text.ParserCombinators.Parsec (GenParser)
import Control.Applicative ((<$>), (*>), (<*>), (<*))
type UnaryOp = Integer -> Integer
type BinOp = Integer -> Integer -> Integer
data Expr = Binary BinOp Expr Expr
| Unary UnaryOp Expr
| Num Integer
<aside class="notice">
You must replace `meowmeowmeow` with your personal API key.
</aside>
import System.Environment
import Control.Applicative
import Data.Maybe
import Data.List
import Data.List.Split
import Data.Map.Strict ((!), Map, fromList)
type Class = String
type Mean = Double
type StdDevSquared = Double
{% highlight c linenos %}
void bitset(unsigned char * array, int index){
int newval;
int oldval;
int bitset_index = index / BITS_PER_INDEX;
int bit_index = index % BITS_PER_INDEX;
do{
oldval = array[bitset_index];
newval = oldval | (1 << (bit_index));
}while(!__sync_bool_compare_and_swap(&array[bitset_index], oldval, newval));
/* Because bitset comprises 3 operations:
* 1. Read array[bitset_index] into 'temp'
* 2. Set bit (bit_index) on 'temp'
* 3. Write 'temp' into array[bitset_index]
* A thread running bitset can be preempted before it can write 'temp', during
* which time another thread has written 'array[bitset_index]', and 'temp' does
* not include the changes made by that thread. Thus, the preempted thread
* overwrites the changes made by the other thread when it executes step 3.
*
* To avoid this, I use the GCC extension '__sync_bool_compare_and_swap' which