Skip to content

Instantly share code, notes, and snippets.

View Luhua-codes's full-sized avatar
🍣

Luhua-codes

🍣
  • Canada
View GitHub Profile
@Luhua-codes
Luhua-codes / pingpong.c
Created September 2, 2025 04:40
Write a program that uses UNIX system calls to "ping-pong" a byte between two processes over a pair of pipes, one for each direction. Measure the program's performance, in exchanges per second.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/wait.h>
#define NUM_EXCHANGES 10000
int main() {
int parent_to_child[2], child_to_parent[2];
@Luhua-codes
Luhua-codes / EECS3311W25_Lab2.java
Last active January 28, 2025 01:55
EECS 3311 W25 Lab 2 exercises
package com.company;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
public class EECS3101W25_Lab2 {
import java.util.Scanner;
public class Week1Exercises {
/* C-1.16
* Write a short program that takes as input three integers, a, b, and c, from the Java
* console and determines if they can be used in a correct arithmetic formula (in the
* given order), like “a+b = c,” “a = b−c,” or “a ∗ b = c.”
*/
public static void main(String[] args) {
@Luhua-codes
Luhua-codes / Codility4.4.java
Created October 28, 2022 04:30
Codility developer training lesson 4 exercise 4 solution https://app.codility.com/programmers/lessons/4-counting_elements/
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
import java.util.Arrays;
class Solution {
public int solution(int[] A){
@Luhua-codes
Luhua-codes / Codility1.java
Last active October 28, 2022 01:47
Codility Developer training lesson 1 solution https://app.codility.com/programmers/lessons/1-iterations/
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int solution(int N) {
int longest = 0, countZero = 0, currentIndex = 0, start, end;
String bs = Integer.toBinaryString(N);
=match(F2,indirect("sheet7!W2:W"),0) <- og formula, Natasha's
if searchKey:[F2 person's role] matches with range[sheet7 column for that lesson], search type 0 (exact match with range not sorted)
=match(Training Role, Assignments.[Administraton lesson 1].column, not sorted)
=match(D3, hlookup(F1, indirect("Assignments!A1:BD2"),2,FALSE),0) <- my formula
- how to get the hlookup to return a cell reference or address instead of the value?
- Once cell reference returned, can use cell() to get the associated column, and supply that column as the search range for match
=cell("column",ref)
{
"name": "react-bootstrap",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
@Luhua-codes
Luhua-codes / Test.js
Last active July 21, 2022 19:45
Clock Example.jsClock Example.js
class Clock extends React.Component {
constructor(props) {
super(props);
this.state = {date: new Date()}; //add date property in constructor
}
componentDidMount() { //called when mounting (after component rendered to DOM)
this.timerID = setInterval( //create a timer that "ticks" every second (is a class field just like this.state and this.props)
() => this.tick(), //call tick method
1000 //wait one second
class Car extends React.Component {
constructor(props) {
super(props);
this.state = { //add states just like class properties (except that keys do not have to be strings)
brand: "Ford",
model: "Mustang",
color: "red",
year: 1964
};
}
//Q1
let city, country, location;
//Q2
city = 'Toronto';
country = 'Canada';
//Q3
location = city + ', ' + country;