Skip to content

Instantly share code, notes, and snippets.

#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <search.h>
#define ARRAY_SZ (10965116)
#if 0
void *__real_malloc (size_t);
#include<stdio.h>
#include<stdlib.h>
#define N 10L
#define GET_VALUE(i, j, k, l) (N * N * N * i + N * N * j + N * k + l)
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
int quad_array[N][N][N][N];
#!/bin/bash
VERSION=`bash --version|egrep -o "[0-9].[0-9].[0-9]+"`
echo "current bash version $VERSION"
VER="${VERSION%.*}"
echo "bash major version $VER"
PATCHLVL="${VER//.}"
echo "patch level $PATCHLVL"
echo "downloading bash source code"
@DavidPu
DavidPu / setclocks.sh
Last active August 29, 2015 14:21
fix jetson tk1 cpu/gpu/emc clocks to specific frequency.
#!/bin/bash
#usage:
# $source setclocks.sh
# $setxxfreq ..
#set -x
function setcpufreq()
{
if [ -z $1 ]; then
echo "usage:setcpufreq <CPUFREQ in kHz>|max [ONLINECPUS](default 4)"
echo "e.g: setcpufreq max or setcpufreq max 2"
@DavidPu
DavidPu / bitmap.c
Last active February 15, 2017 18:09
bitmap
#include <stdlib.h>
#include <stdio.h>
#define BITS_PER_LONG (sizeof(long) * 8)
#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
#define OFF(x) ((x)%BITS_PER_LONG)
#define BIT(x) (1UL<<OFF(x))
#define LONG(x) ((x)/BITS_PER_LONG)
#define test_bit(bit, array) ((array[LONG(bit)] >> OFF(bit)) & 1)
#define FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG))
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
def maxsum(arr):
# maxsum, start, end:
result = [arr[0], 0, 0]
curr = [0, 0, 0]
for i in range(0, len(arr)):
def check_string(s):
mstack = []
bFind = False
matches = {')': '(', '}': '{', ']': '['}
for c in s:
if c in matches.values():
bFind = True
mstack.append(c)
elif c in matches.keys():
if len(mstack) == 0 or mstack[-1] != matches[c]:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import BaseHTTPServer
import SimpleHTTPServer
import argparse
import socket
parser = argparse.ArgumentParser()
parser.add_argument('-b', action='store', dest='host',
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
def happy_number(val):
nums = []
nums.append(val)
while True:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
class FSO(object):
import win32com.client as com
import pywintypes