Skip to content

Instantly share code, notes, and snippets.

View qqwqqw689's full-sized avatar
:octocat:

qqwqqw689

:octocat:
  • China
View GitHub Profile
@qqwqqw689
qqwqqw689 / ThreadedBinaryTree.cpp
Created June 30, 2024 06:36
Threaded Binary Tree(unread)
#include <iostream>
#include <cstdlib>
#define MAX_VALUE 65536
using namespace std;
class N { //node declaration
public:
int k;
N *l, *r;
bool leftTh, rightTh;
};
@qqwqqw689
qqwqqw689 / wallpaper.md
Created June 28, 2024 12:38
python script : wallpaper of himawari8.
# Use latest himawari 8 photo as wallpaper
# for Windows user

from datetime import datetime, timezone, timedelta
import requests
import ctypes
from PIL import Image, ImageDraw, ImageFont
import cv2
import numpy as np
@qqwqqw689
qqwqqw689 / MPIsort.cpp
Created June 18, 2024 15:49
MPI sort example.
#include <mpi.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <ctime>
void bubble_sort(std::vector<int>& arr) {
int n = arr.size();
for (int i = 0; i < n - 1; ++i) {
@qqwqqw689
qqwqqw689 / markdown.md
Last active May 23, 2024 08:39
Converting between Windows and Linux line breaks.

The Windows and Linux operating systems have a slight variation in how they handle newlines in files. Typically, in the Windows environment a line is terminated with the two characters \r\n. The \r character represents a carriage return, and \n represents a newline. In Linux, only the \n character is used to terminate a line.

This causes some interesting behavior issues when moving between the Windows and Linux environment. For example, if you have a multi-line text file that was created in Linux, and then try to open it using a program such as Windows Notepad, the entire contents of the file will appear on a single line.

Converting from Linux to Windows Line Breaks

@qqwqqw689
qqwqqw689 / nextPowerOfTwo.cpp
Created May 16, 2024 15:28
A function to find the next power of two greater than a given number.
#include <iostream>
#include <bitset>
typedef unsigned int uint;
static uint nextPowerOfTwo(uint x) {
std::bitset<32> a(x);
std::cout << a << '\n';
--x;
a = x;
@qqwqqw689
qqwqqw689 / dup2.c
Last active March 17, 2024 15:31
dup2
#define _POSIX_SOURCE
// If you define this macro, then the functionality from
// the POSIX.1 standard (IEEE Standard 1003.1) is available
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#undef _POSIX_SOURCE
#include <stdio.h>
@qqwqqw689
qqwqqw689 / membenchmark.c
Created March 15, 2024 02:17
memory access benchmarking program(MS).
#include <stdio.h>
#include <time.h>
#include <tchar.h>
#define ARRAY_MIN (1024) /* 1/4 smallest cache */
#define ARRAY_MAX (4096*4096) /* 1/4 largest cache */
int x[ARRAY_MAX]; /* array going to stride through */
double get_seconds() { /* routine to read time in seconds */
__time64_t ltime;
_time64(&ltime);
@qqwqqw689
qqwqqw689 / prlimit.c
Created February 23, 2024 07:53
prlimit function
#define _GNU_SOURCE
/*
If you define this macro, everything is included: ISO C89, ISO C99,
POSIX.1, POSIX.2, BSD, SVID, X/Open, LFS, and GNU extensions.
*/
#define _FILE_OFFSET_BITS 64
/*
This macro determines which file system interface
shall be used, one replacing the other.
*/
@qqwqqw689
qqwqqw689 / MPILOOP.c
Last active February 23, 2024 07:55
MPI-split-loop
#include <stdio.h>
#include <mpi.h>
int main (int argc, char *argv[])
{
int rank, comm_size;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);