Skip to content

Instantly share code, notes, and snippets.

View MicBrain's full-sized avatar

Rafayel Mkrtchyan MicBrain

View GitHub Profile
void MultiFetcher::Add(JobInfo *info) {
assert(info != NULL);
assert(info->url != NULL);
Failures result;
result = PrepareDownloadDestination(info);
if (result != kFailOk)
return result;
if (info->expected_hash) {
@MicBrain
MicBrain / gist:437606e97e24982a83ae
Last active August 29, 2015 14:27
WaitForNext() Function
JobInfo* MultiFetcher::WaitForNext() {
int index;
int timeout = -1;
int length = getJobInfoList().size();
download_mgr->watch_fds_ =
static_cast<struct pollfd *>(smalloc(length * sizeof(struct pollfd)));
download_mgr->watch_fds_size_ = length;
for (index = 0; index < length; index++) {
download_mgr->watch_fd_[index].fd = JobInfo[idx].pipe_fd
download_mgr->watch_fd_[index].events = POLLIN | POLLPRI;
@MicBrain
MicBrain / gist:a2caaa88f81acd177f06
Last active August 29, 2015 14:27
Test Add and WaitForNext from MultiFetcher
int main () {
std::string *brr = new std::string("http://textfiles.com/100/914bbs.txt");
std::string *grr = new std::string("http://textfiles.com/100/ad.txt");
std::string *vrr = new std::string("http://textfiles.com/100/balls.txt");
std::string *zrr = new std::string("http://textfiles.com/anarchy/001.txt");
std::string *rrr = new std::string("http://textfiles.com/anarchy/176.txt");
std::string *arr = new std::string("http://textfiles.com/hacking/22.txt");
std::string *crr = new std::string("http://textfiles.com/hacking/2600-9-3.txt");
download::JobInfo info1 = download::JobInfo(brr);
@MicBrain
MicBrain / gist:42c736cac71c4f306bd3
Created February 26, 2015 17:46
Pascal's triangle in MAL
pascal: add $sp, $sp, -16 # prologue
sw $31, 0($sp)
sw $4, 4($sp)
sw $5, 8($sp)
sw $16, 12($sp)
li $2, 1 # return 1 if base case
beqz $5, ret
beq $4, $5, ret