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 ast | |
class CrazyTransformer(ast.NodeTransformer): | |
def visit_BinOp(self, node): | |
print(node.__dict__) | |
node.op = ast.Mult() | |
print(node.__dict__) | |
return node |
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
If: | |
- you add and commit with the wrong email address in git, and | |
- your remote has a hook set up to prevent you from pushing with the bad address | |
Then you need to amend the author of your commit before push can succeed: | |
1. fix your email address in git config: | |
$ git config user.name "Your Name" |
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> | |
#include <string.h> | |
#include <stdint.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
#include <sys/time.h> | |
#include <sys/mman.h> | |
#include <sys/stat.h> |
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
array = Array.new() | |
t1 = Thread.new { array.append(4) } | |
t2 = Thread.new { array.append(7) } | |
t1.join | |
t2.join | |
puts array.size |
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 threading import Thread | |
import time | |
def count(): | |
i = 0 | |
for _ in range(50000000): | |
i += 1 | |
return True | |
def main(): |
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 threading import Thread | |
import time | |
def count(): | |
i = 0 | |
for _ in range(50000000): | |
i += 1 | |
return True | |
def main(): |
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> | |
int main(void) | |
{ | |
int a[3]; | |
for (int i = 0; i <= 4096; i++) | |
{ | |
printf("address of a[%d] = %p, a[0] = %p\n", i, &a[i], &a[0]); | |
a[i] = i; |
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 <string.h> | |
int main(void) | |
{ | |
int a[3]; | |
int b[3]; | |
int i; | |
b[0] = 1; |
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 <fcntl.h> /* O_ constants */ | |
#include <unistd.h> /* ftruncate */ | |
#include <sys/mman.h> /* mmap */ | |
#include <string.h> | |
int main() { | |
int fd; | |
char *map; | |
char *name = "test.txt"; |
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 sys | |
import collections | |
class Buf(): | |
def __init__(self, buf=0, size=0): | |
self.buf = buf | |
self.size = size | |
def __repr__(self): | |
return 'buf: {}, size: {}'.format(self.buf, self.size) |
NewerOlder