Skip to content

Instantly share code, notes, and snippets.

View Mooophy's full-sized avatar
😏

Yue Wang Mooophy

😏
  • Auckland, New Zealand
View GitHub Profile
@Mooophy
Mooophy / ex9_45_genrics.cpp
Last active August 29, 2015 14:07
C++ Primer 5th exercise 9.45 generics version
//! @author @Queequeg @Alan
//! @date 4 Oct,2014.
//!
//! Exercise 9.45:
//! Write a funtion that takes a string representing a name and two other
//! strings representing a prefix, such as “Mr.” or “Ms.” and a suffix,
//! such as “Jr.” or “III”. Using iterators and the insert and append functions,
//! generate and return a new string with the suffix and prefix added to the
//! given name.
//!
/**
*****************************************************************************
* @file main.c
* @author Yue Wang 12027710
* @version V1.0.0
* @date 22-May-2013
* @brief For the Assignment 5, 159.270 Hardware Oriented Programming.
****************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
@Mooophy
Mooophy / find_contiguous_block.cpp
Last active August 29, 2015 14:07
made for a question on SO
//!
//! @author Yue Wang
//! @date 15 Oct 2014
//! @note for a question on SO:
//! http://stackoverflow.com/questions/26353067/how-to-recursively-compare-vectors/26359781#26359781
//!
#include <iostream>
#include <vector>
#include <algorithm>
@Mooophy
Mooophy / lisp90.cpp
Last active August 17, 2020 15:05 — forked from ofan/lisp.cpp
Lisp interpreter in 90 lines of C++
//Lisp interpreter in 90 lines of C++
//I've enjoyed reading Peter Norvig's recent articles on Lisp. He implements a Scheme interpreter in 90 lines of Python in the first, and develops it further in the second.
//Just for fun I wondered if I could write one in C++. My goals would be
//1. A Lisp interpreter that would complete Peter's Lis.py test cases correctly...
//2. ...in no more than 90 lines of C++.
//Although I've been thinking about this for a few weeks, as I write this I have not written a line of the code. I'm pretty sure I will achieve 1, and 2 will be... a piece of cake!
@Mooophy
Mooophy / gist:5d35fb8f73b8e5921692
Last active August 29, 2015 14:08
word_ladder.cpp
#include <iostream>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
class Solution
{
//! O(n)
dialog.h
/**
*****************************************************************************
* @file dialog.h
* @author Yue Wang 12027710
* @version V1.0.0
* @date 03-June-2013
* @brief For the Assignment 6, 159.270 Hardware Oriented Programming.
****************************************************************************
*/
@Mooophy
Mooophy / ftp_server.c
Created November 11, 2014 03:47
My code for Assignment 1, 159.334, s2 2013.
/**
*****************************************************************************
* @file FTP_server.c
* @author Yue Wang 12027710
* @version V1.0.0
* @date 15-Oct-2013
* @brief 159.334 Assignment 1
****************************************************************************
*/
#include <windows.h>
//!
//! @author Yue Wang
//! @date 13 11 2014
//!
//! @ex 41.01
//! (a) share data between two threads.
//! (b) use mutex to avoid data race.
//!
// to compile (on linux) :
// g++ -std=c++11 -Wall ex41_01.cpp -pthread
@Mooophy
Mooophy / thread_and_mutex_as_class_data_member.cpp
Created November 14, 2014 23:47
using std::thread std::mutex std::lock_guard in the same class
#include <iostream>
#include <thread>
#include <mutex>
struct ThreadTest
{
ThreadTest():
t1{[this]{ print(1);} },
t2{[this]{ print(2);} }
{}
#include <iostream>
#include <thread>
#include <mutex>
#include <vector>
struct ThreadTest
{
ThreadTest():
threads_vector{10}
{