This file contains 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
/** | |
* This program tries to demonstrate the surprising sequential consistency. | |
* A program is sequentially consistent as long as calls made in a single | |
* thread follow the program order. Program order however, does not apply | |
* to the executions across threads. | |
* It's hard to demonstrate that a counterintuitive behavior might actually | |
* be sequentially consistent. Let's say, we have a FIFO queue, q and two threads: A, B | |
* | |
* Thread A does: | |
* q.enq(x); returns at time 1. |
This file contains 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
find: function(req, res) { | |
Items.find().done(function (err, val) { | |
if (err) { | |
res.send(err); | |
} | |
res.send(val); | |
}); | |
}, |
This file contains 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
module.exports = { | |
//... | |
find: function(req, res) { | |
Items | |
.find() | |
.exec(function(err, items) { | |
if (err) { | |
res.send(err); | |
} else if (items) { | |
items.forEach( |
This file contains 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
all: function(params, callback) { | |
var async = require('async'); | |
var reviews = null; | |
async.series([ | |
function load_reviews(cb) { | |
Reviews.find().exec(function (err, result) { | |
reviews = result; | |
cb(null, reviews); | |
}); | |
}, |
This file contains 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
Sep 14 15:50:34 mypc NetworkManager[736]: <info> Activation (wlan0) starting connection 'LessWire' | |
Sep 14 15:50:34 mypc NetworkManager[736]: <info> (wlan0): device state change: disconnected -> prepare (reason 'none') [30 40 0] | |
Sep 14 15:50:34 mypc NetworkManager[736]: <info> NetworkManager state is now CONNECTING | |
Sep 14 15:50:34 mypc NetworkManager[736]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) scheduled... | |
Sep 14 15:50:34 mypc NetworkManager[736]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) started... | |
Sep 14 15:50:34 mypc NetworkManager[736]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) scheduled... | |
Sep 14 15:50:34 mypc NetworkManager[736]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) complete. | |
Sep 14 15:50:34 mypc NetworkManager[736]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) starting... | |
Sep 14 15:50:34 mypc NetworkManager[736]: <info> (wlan0): device state change: prepare -> config (reason 'none') [40 50 |
This file contains 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
Sep 14 20:18:40 mypc kernel: [ 1241.379380] Intel(R) Wireless WiFi driver for Linux, in-tree: | |
Sep 14 20:18:40 mypc kernel: [ 1241.379383] Copyright(c) 2003-2013 Intel Corporation | |
Sep 14 20:18:40 mypc kernel: [ 1241.379429] iwlwifi 0000:02:00.0: enabling device (0000 -> 0002) | |
Sep 14 20:18:40 mypc kernel: [ 1241.379505] iwlwifi 0000:02:00.0: can't disable ASPM; OS doesn't have ASPM control | |
Sep 14 20:18:40 mypc kernel: [ 1241.379576] iwlwifi 0000:02:00.0: irq 51 for MSI/MSI-X | |
Sep 14 20:18:40 mypc kernel: [ 1241.380366] iwlwifi 0000:02:00.0: loaded firmware version 41.28.5.1 build 33926 op_mode iwldvm | |
Sep 14 20:18:40 mypc kernel: [ 1241.409982] iwlwifi 0000:02:00.0: CONFIG_IWLWIFI_DEBUG disabled | |
Sep 14 20:18:40 mypc kernel: [ 1241.409987] iwlwifi 0000:02:00.0: CONFIG_IWLWIFI_DEBUGFS enabled | |
Sep 14 20:18:40 mypc kernel: [ 1241.409988] iwlwifi 0000:02:00.0: CONFIG_IWLWIFI_DEVICE_TRACING enabled | |
Sep 14 20:18:40 mypc kernel: [ 1241.409990] iwlwifi 0000:02:00.0: Detected Intel(R) Centrino(R) Wireless-N + WiMAX 6150 BG |
This file contains 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
filename: /lib/modules/3.13.0-24-generic/kernel/drivers/net/wireless/iwlwifi/iwlwifi.ko | |
license: GPL | |
author: Copyright(c) 2003-2013 Intel Corporation <ilw@linux.intel.com> | |
version: in-tree: | |
description: Intel(R) Wireless WiFi driver for Linux | |
firmware: iwlwifi-100-5.ucode | |
firmware: iwlwifi-1000-5.ucode | |
firmware: iwlwifi-135-6.ucode | |
firmware: iwlwifi-105-6.ucode | |
firmware: iwlwifi-2030-6.ucode |
This file contains 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
Sep 16 20:12:13 mypc wpa_supplicant[905]: wlan0: CTRL-EVENT-SCAN-STARTED | |
Sep 16 20:12:14 mypc wpa_supplicant[905]: nl80211: send_and_recv->nl_recvmsgs failed: -33 | |
Sep 16 20:12:32 mypc kernel: [ 711.959905] cfg80211: Calling CRDA for country: US | |
Sep 16 20:12:32 mypc kernel: [ 711.962582] cfg80211: Regulatory domain changed to country: US | |
Sep 16 20:12:32 mypc kernel: [ 711.962585] cfg80211: DFS Master region: unset | |
Sep 16 20:12:32 mypc kernel: [ 711.962586] cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp) | |
Sep 16 20:12:32 mypc kernel: [ 711.962588] cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2700 mBm) | |
Sep 16 20:12:32 mypc kernel: [ 711.962589] cfg80211: (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 1700 mBm) | |
Sep 16 20:12:32 mypc kernel: [ 711.962591] cfg80211: (5250000 KHz - 5330000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) | |
Sep 16 20:12:32 mypc kernel: [ 711.962592] cfg80211: (5490000 KHz - 5600000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) |
This file contains 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
Experiment a billion times: | |
➜ combinatorial-algorithms git:(master) ✗ java -ea RandomSubset 4 1000000000 | |
Frequencies of chosen subsets .... | |
[3] : 68566736, 6.856674 | |
[] : 79538193, 7.953819 |
This file contains 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
/** | |
* Problem: Print the statistics of RandomSubset algorithm when the experiment | |
* of choosing a subset at random is done the specified number of times. | |
*/ | |
import java.util.*; | |
class RandomSubsetSimulation { | |
static final Random r = new Random(System.currentTimeMillis()); //fix for the bug in the SO thread (see below) | |
public static void main(String[] args) { | |
// arg[0] = the max number n in the set: {1, 2, 3, ... n} | |
// arg[1] = the number of times the experiment is to be done |