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
from itertools import groupby | |
def splitWithIndices(a, c=' '): | |
p=0 | |
for k,g in groupby(s, lambda x:x:==c): | |
q=p + sum(1 for i in g) | |
if not k: | |
yield p,q | |
p=q |
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
#import pyserial package | |
import serial | |
#open the serial port | |
s = serial.Serial("/dev/ttyACM0") #change port after checking the port in which device is connected | |
#send probe | |
s.write('S') | |
#read ack | |
s.read() | |
#create the bytearray | |
b = bytearray(5) #bytearray of 5 bytes |
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
using LightGraphs | |
using NetworkViz | |
using NetworkLayout | |
using ThreeJS | |
using Colors | |
main(window) = begin | |
"""ar = int(open(readdlm,"jagmesh1.mtx")) | |
x = ar[:,1] | |
y = ar[:,2] |
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
f(a,b) = b,b+a # Function that computes the fibonacci number | |
function fibonacci(N::int64) # Function to find first N fibonacci numbers | |
a = 0 ; b = 1 # Errors can arise depending on the values taken for a and b. | |
for c in 1:N # Loop that runs N times | |
a,b = f(a,b) | |
@show a | |
end | |
end |
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
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | |
/** | |
* Copyright (c) 2011-2015 Regents of the University of California. | |
* | |
* This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and | |
* contributors. | |
* | |
* ndnSIM is free software: you can redistribute it and/or modify it under the terms | |
* of the GNU General Public License as published by the Free Software Foundation, | |
* either version 3 of the License, or (at your option) any later version. |
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
#Run this code in Escher | |
using NetworkViz | |
using LightGraphs | |
main(window) = begin | |
num = Signal(10) | |
width = Signal(1) | |
nodesize = Signal(0.2) | |
edgewidth = Signal(0.5) | |
toggle = Signal(true) |
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
using ThreeJS | |
using Escher | |
using LightGraphs | |
using NetworkViz | |
g = CompleteGraph(10) | |
drawGraph(g,1) | |
@show typeof(g) |