Skip to content

Instantly share code, notes, and snippets.

View sdcb's full-sized avatar
👋
Console.WriteLine("Hello World");

ZHOU Jie sdcb

👋
Console.WriteLine("Hello World");
View GitHub Profile
@sdcb
sdcb / HslCircleGeometry.js
Last active March 21, 2016 05:54
create hsl circle using three.js in typescript.
class HslCircleGeometry extends THREE.CircleGeometry {
constructor(radius: number, segments: number, thetaStart?: number, thetaLength?: number) {
super(radius, segments, thetaStart, thetaLength);
for (let i = 0; i < segments; ++i) {
let color = new THREE.Color().setHSL(i / segments, 1, 0.5);
this.faces[i].vertexColors.push(color);
this.faces[i].vertexColors.push(color);
this.faces[i].vertexColors.push(color);
}
class VertexColorBoxGeometry extends THREE.BoxGeometry {
constructor(width: number, height: number, depth: number, widthSegments?: number, heightSegments?: number, depthSegments?: number) {
super(width, height, depth, widthSegments, heightSegments, depthSegments);
let faceIndices = ['a', 'b', 'c', 'd'];
for (let face of this.faces) {
let numberOfSides = (face instanceof THREE.Face3) ? 3 : 4;
for (let i = 0; i < numberOfSides; i++) {
let vertexIndex = face[faceIndices[i]];
let point = this.vertices[vertexIndex];
class FaceColorBoxGeometry extends THREE.BoxGeometry {
constructor(width: number, height: number, depth: number, widthSegments?: number, heightSegments?: number, depthSegments?: number) {
super(width, height, depth, widthSegments, heightSegments, depthSegments);
for (let face of this.faces) {
let color = new THREE.Color();
if (face.normal.x < 0 || face.normal.y < 0 || face.normal.z < 0) {
color.setRGB(1, 1, 1);
if (face.normal.x < 0) color.r = 0;
if (face.normal.y < 0) color.g = 0;
@sdcb
sdcb / await-CreateThreadpoolTimer.cpp
Last active March 23, 2016 03:31
C++ await duration CreateThreadpoolTimer
auto operator await(std::chrono::system_clock::duration duration)
{
class awaiter
{
public:
explicit awaiter(std::chrono::system_clock::duration duration) :
_duration(duration)
{
}
@sdcb
sdcb / 抓取博客园首页前4000篇文章大体内容,并保存到数据库.cs
Last active April 14, 2016 17:05
抓取博客园首页前4000篇文章大体内容,并保存到数据库
using Dapper;
using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
@sdcb
sdcb / nanodbc-vcpkg-test.cpp
Created October 14, 2016 03:24
nanodbc-vcpkg-test
#include <nanodbc.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
auto cs = L"Driver={Sql Server Native Client 11.0};Server=(localdb)\\MSSQLLocalDB;Trusted_Connection=yes;Database=test";
auto conn = nanodbc::connection{ cs };
@sdcb
sdcb / ImageFinder.cs
Created January 13, 2017 13:30
ImageFinder
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@sdcb
sdcb / MsgTool.cs
Last active January 13, 2017 14:04
douyutv barrage C# 弹幕获取
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
@sdcb
sdcb / CMakeLists.txt
Created January 27, 2017 03:34
directxtk-cmake
cmake_minimum_required(VERSION 3.0)
project(directxtk)
add_library(directxtk
Src/AlphaTestEffect.cpp
Src/BasicEffect.cpp
Src/BinaryReader.cpp
Src/CommonStates.cpp
Src/DDSTextureLoader.cpp
Src/DGSLEffect.cpp
@sdcb
sdcb / DeviceResources.h
Last active February 3, 2017 03:46
dxtk
//
// DeviceResources.h - A wrapper for the Direct3D 11 device and swapchain
//
#pragma once
namespace DX
{
// Provides an interface for an application that owns DeviceResources to be notified of the device being lost or created.
interface IDeviceNotify