This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* gcc atomic-queue.c -mcx16 */ | |
| /* | |
| Copyright (c) 2011, Matteo Bertozzi | |
| All rights reserved. | |
| Redistribution and use in source and binary forms, with or without | |
| modification, are permitted provided that the following conditions are met: | |
| * Redistributions of source code must retain the above copyright | |
| notice, this list of conditions and the following disclaimer. | |
| * Redistributions in binary form must reproduce the above copyright |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* LRU cache | |
| * gcc -Wall cache.c -lpthread && ./a.out | |
| */ | |
| #include <pthread.h> | |
| #include <string.h> | |
| #include <stdlib.h> | |
| #include <stdio.h> | |
| struct cache_entry { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| def balanced_groups(ngroups, items): | |
| items = sorted(items) | |
| wgroups = [0] * ngroups | |
| groups = [[] for _ in xrange(ngroups)] | |
| g = 0 | |
| lo = 0 | |
| dir = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Variable length int encoding. The 1st byte contains the number of bytes left. | |
| * Compared to the 7bit vint-encoding, is worst on small numbers (< 21bit) but | |
| * better with large numbers. | |
| * | |
| * 0: 11110000 -> 4 v7 | |
| * 1: 00000000 -> 8 (12) v7 (14) | |
| * 2: 00000000 -> 8 (20) v7 (21) | |
| * 3: 00000000 -> 8 (28) v7 (28) | |
| * 4: 00000000 -> 8 (36) v7 (35) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.*; | |
| import org.apache.hadoop.conf.Configuration; | |
| import org.apache.hadoop.hbase.*; | |
| import org.apache.hadoop.hbase.client.*; | |
| import org.apache.hadoop.hbase.util.*; | |
| public class HBaseFill { | |
| private static void createTable(final HBaseAdmin admin, final byte[] tableName, | |
| final byte[]... families) throws IOException { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct rwlock { | |
| volatile uint32_t state; | |
| }; | |
| static void __rwlock_init (struct rwlock *lock) { | |
| lock->state = 0; | |
| } | |
| static void __read_lock (struct rwlock *lock) { | |
| unsigned int new_state; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdint.h> | |
| #include <stdlib.h> | |
| #include <stdio.h> | |
| struct node { | |
| struct node *onext; | |
| struct node *cnext; | |
| int type; | |
| int value; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| NOTES = ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#'] | |
| note_name = lambda n: NOTES[n % len(NOTES)] | |
| SCALES = { | |
| 'Major (Ionian)': [2, 2, 1, 2, 2, 2, 1], | |
| 'Major Pentatonic': [2, 2, 3, 2, 3], | |
| 'Natural minor (Aeolian)' : [2,1,2,2,1,2,2], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # th30z@u1310:[Desktop]$ psql -h localhost -p 55432 | |
| # Password: | |
| # psql (9.1.10, server 0.0.0) | |
| # WARNING: psql version 9.1, server version 0.0. | |
| # Some psql features might not work. | |
| # Type "help" for help. | |
| # | |
| # th30z=> select foo; | |
| # a | b | |
| # ---+--- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # | |
| # Copyright 2014 Matteo Bertozzi | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # |