Skip to content

Instantly share code, notes, and snippets.

View kedarmhaswade's full-sized avatar
💭
Just trying to catch up with my calendar

Kedar Mhaswade kedarmhaswade

💭
Just trying to catch up with my calendar
  • JyMob
  • Sunnyvale, USA
View GitHub Profile
@kedarmhaswade
kedarmhaswade / SurprisingSequentialConsistency.java
Last active December 25, 2015 01:19
Demonstrating Sequential Consistency Surprises ...
/**
* 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.
@kedarmhaswade
kedarmhaswade / ItemsController.js
Last active August 29, 2015 14:02
sails controller finder ...
find: function(req, res) {
Items.find().done(function (err, val) {
if (err) {
res.send(err);
}
res.send(val);
});
},
@kedarmhaswade
kedarmhaswade / gist:6d1337dc7e840c25b6b8
Created June 5, 2014 20:32
A find method in a Sails Controller that works with disk adapter but not with mysql adapter ...
module.exports = {
//...
find: function(req, res) {
Items
.find()
.exec(function(err, items) {
if (err) {
res.send(err);
} else if (items) {
items.forEach(
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);
});
},
@kedarmhaswade
kedarmhaswade / wlan0.log
Created September 15, 2014 00:10
/var/log/syslog -- debugging wlan0
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
@kedarmhaswade
kedarmhaswade / wlan0.next.log
Created September 15, 2014 03:22
Update on wlan0
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
@kedarmhaswade
kedarmhaswade / modinfo.iwlwifi
Created September 15, 2014 03:30
modinfo iwlwifi
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
@kedarmhaswade
kedarmhaswade / gist:3cd13cc9b5f11aaf47ec
Created September 17, 2014 03:53
Onset of error (terror?) with iwlwifi
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)
@kedarmhaswade
kedarmhaswade / Distribution of Subset Frequencies
Last active August 29, 2015 14:06
Distribution of uar subset selection
Experiment a billion times:
➜ combinatorial-algorithms git:(master) ✗ java -ea RandomSubset 4 1000000000
Frequencies of chosen subsets ....
[3] : 68566736, 6.856674
[] : 79538193, 7.953819
@kedarmhaswade
kedarmhaswade / RandomSubsetSimulation.java
Last active August 29, 2015 14:06
A program to select a random subset of a set uniformly at random
/**
* 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