gcc adt.c array.c -o adt
./adt
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
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) |
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
__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 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 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 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 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 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> | |
// function pointers in C | |
// a function is just another address in memory which contains | |
// executable code, similar to getting address of a variable by using | |
// pointers, we can get an addr of function using function pointers | |
void func() | |
{ |
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
#include <stdio.h> | |
#include <stdlib.h> | |
// node structure | |
typedef struct node_s | |
{ | |
int value; | |
struct node_s *lnode; | |
struct node_s *rnode; | |
} node_t; |
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
#include <stdio.h> | |
#include <stdlib.h> | |
// list node | |
typedef struct node_s | |
{ | |
int data; | |
struct node_s *next; | |
struct node_s *prev; | |
} node_t; |
OlderNewer