Skip to content

Instantly share code, notes, and snippets.

View hankliu5's full-sized avatar
🐶

Yu-Chia "Hank" Liu hankliu5

🐶
View GitHub Profile
import ast
class CrazyTransformer(ast.NodeTransformer):
def visit_BinOp(self, node):
print(node.__dict__)
node.op = ast.Mult()
print(node.__dict__)
return node
@hankliu5
hankliu5 / gist:31d5633ae1d21aa533d982b6db08fa2f
Created February 26, 2019 02:16 — forked from carlosmcevilly/gist:2221249
fix git commit with wrong email address in git config, before pushing
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"
#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>
array = Array.new()
t1 = Thread.new { array.append(4) }
t2 = Thread.new { array.append(7) }
t1.join
t2.join
puts array.size
from threading import Thread
import time
def count():
i = 0
for _ in range(50000000):
i += 1
return True
def main():
from threading import Thread
import time
def count():
i = 0
for _ in range(50000000):
i += 1
return True
def main():
#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;
#include <stdio.h>
#include <string.h>
int main(void)
{
int a[3];
int b[3];
int i;
b[0] = 1;
#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";
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)