Skip to content

Instantly share code, notes, and snippets.

View raytroop's full-sized avatar
🎯
Focusing

raytroop

🎯
Focusing
View GitHub Profile
@raytroop
raytroop / virtualInheritanceDemo.cpp
Created November 6, 2019 09:40
c++ virtual inheritance
#include<iostream>
using namespace std;
//大小为4
class A
{
public:
int a;
};
@raytroop
raytroop / mov.cpp
Created November 1, 2019 12:56
copy-and-move-assignment-operators-for-a-class
#include <iostream>
using std::cout;
using std::endl;
class A {
public:
A(int x): mem_(x){}
A& operator=(const A& other) {
cout << "copy assignment operator" << endl;
mem_ = other.mem_;
@raytroop
raytroop / Singleton.cpp
Last active December 3, 2019 01:44
Singleton design pattern
class Singleton{
private:
Singleton();
Singleton(const Singleton& other);
public:
static Singleton* getInstance();
static Singleton* m_instance;
};
Singleton::Singleton() {}
@raytroop
raytroop / MatMulTiled.cu
Created October 23, 2019 09:43
Matrix Multiplication in CUDA using Shared memory
#include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
//http://www.techdarting.com/2014/03/matrix-multiplication-in-cuda-using.html
// This code assumes that your device support block size of 1024
#define MAX_RANGE 9999
@raytroop
raytroop / pycurses.py
Created October 16, 2019 13:22 — forked from claymcleod/pycurses.py
Python curses example
import sys,os
import curses
def draw_menu(stdscr):
k = 0
cursor_x = 0
cursor_y = 0
# Clear and refresh the screen for a blank canvas
stdscr.clear()
@raytroop
raytroop / sbtmkdirs
Created October 6, 2019 15:00
Create an SBT project directory structure with a few simple options.
#!/bin/bash
#------------------------------------------------------------------------------
# Name: sbtmkdirs
# Version: 1.5
# Purpose: Create an SBT project directory structure with a few simple options.
# Author: Alvin Alexander, http://alvinalexander.com
# License: Creative Commons Attribution-ShareAlike 2.5 Generic
# http://creativecommons.org/licenses/by-sa/2.5/
#------------------------------------------------------------------------------
@raytroop
raytroop / 00_conditonal_compilation
Last active September 29, 2019 06:40
Conditional compilation
this page intentionally left blank
@raytroop
raytroop / wi_g++.md
Created September 29, 2019 06:00
Conditional compilation
#include <iostream>

#define na 4

int main() {
  int a[na];

  a[0] = 2;
 for (int n = 1; n &lt; na; n++) a[n] = a[n-1] + 1;