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 <stdlib.h> | |
#include <stdio.h> | |
#include <ucontext.h> | |
#define STACKSIZE 4096 | |
ucontext_t foo_context, main_context; | |
void foo() { | |
printf("Executing foo!\n"); |
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 <ucontext.h> | |
#include <sys/types.h> | |
#include <sys/time.h> | |
#include <signal.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
#include <poll.h> | |
/* ucontext sample program |
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 <ucontext.h> | |
#include <sys/types.h> | |
#include <signal.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
#define STACKSIZE 4096 | |
void f(){ |
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
.section __TEXT,__text,regular,pure_instructions | |
.section __TEXT,__literal8,8byte_literals | |
.align 3 | |
LCPI0_0: | |
.quad -4609434218613702656 ## double -3 | |
LCPI0_1: | |
.quad 4616189618054758400 ## double 4 | |
.section __TEXT,__text,regular,pure_instructions | |
.globl _poly1a | |
.align 4, 0x90 |
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 <stdlib.h> | |
#include <stdio.h> | |
int poly1(int x) { | |
return x*x - 3*x + 4; | |
} | |
int poly2(int x) { | |
return x*(x - 3) + 4; |
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
--- context_hello_world.c 2013-10-23 19:47:07.000000000 -0400 | |
+++ context_hello_world1.c 2013-10-23 19:47:13.000000000 -0400 | |
@@ -7,8 +7,11 @@ | |
#define STACKSIZE 4096 | |
+ucontext_t main_context; | |
+ | |
void f(){ | |
printf("Hello World\n"); |
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
#!/bin/bash | |
trap "echo ' Batman!'; exit" SIGINT SIGQUIT | |
while (true) | |
do | |
echo -n "Na" | |
sleep 0.1 | |
done |
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
# Start an HTTP server from a directory, optionally specifying the port | |
function server() { | |
# Default to port 8000 | |
local port="${1:-8000}" | |
# Since the one-liner blocks, we open the browser beforehand. However, we want to | |
# wait just a couple of seconds since the server will not be ready just yet. | |
# Also, I think Linux users should be able to use 'xdg-open' ('open' is for OS X). | |
( sleep 2; open "http://localhost:${port}/" ) & | |
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
var toArray = function(orig) { | |
var arr = []; | |
for (var i = 0; i < orig.length; i++) { | |
arr.push(orig[i]); | |
} | |
return arr; | |
} | |
var find_child_by_class = function(root, klass) { | |
var queue = toArray(root.children); |
NewerOlder