gcc adt.c array.c -o adt
./adt
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 <stdio.h> | |
#include <stdlib.h> | |
// super "class" | |
typedef struct | |
{ | |
int age; | |
double weight; | |
} Animal; |
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 <stdio.h> | |
#include <stdlib.h> | |
// vtable is a virtual method table that implements dynamic binding | |
// The goal is to write code that operates abstractly on Shapes rather than on | |
// specific Circles or Rects as a form of // polymorphism // | |
// abstract and concrete objects | |
typedef struct Shape Shape; | |
typedef struct Circle Circle; |
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 <chrono> | |
#include <iostream> | |
#include <thread> | |
int main() | |
{ | |
// time now | |
auto start = std::chrono::high_resolution_clock::now(); | |
std::this_thread::sleep_for(std::chrono::seconds(5)); |
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
-- json parsing | |
function json_decode(msg) | |
local js = {} | |
for k,v in string.gmatch(msg,'"(%w+)":"(%w+)",') do | |
js[k] = v; | |
end | |
for k,v in string.gmatch(msg,'"(%w+)":"(%w+)"}') do | |
js[k] = v; | |
end | |
return js |
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
__author__ = 'march' | |
ips = ["192.312.3", "192.312.3", "192.312.3", "10.10.3.4", "99.23.1.3", "99.23.1.3"] | |
ts = ["1", "2", "3", "4", "5", "6"] | |
new_ips = [] | |
new_ts = [] | |
for ip in ips: | |
new_ips.append(ip) |
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
def delay_check(self, delay): | |
# get the units and the delay value | |
unit = delay.lstrip("0123456789") | |
# TODO: this raises exception, still caught by the parser, but incorrect | |
# for example input node 1 timer on aksldjhf will crash here | |
if unit not in "": | |
value = int(delay[:-len(unit)]) | |
else: | |
return int(delay) |
NewerOlder