Skip to content

Instantly share code, notes, and snippets.

View vinjn's full-sized avatar

Jing Zhang vinjn

View GitHub Profile

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@vinjn
vinjn / run.bat
Created June 10, 2014 13:11
从当前文件夹全屏运行 Processing 项目
processing-java --sketch=%~dp0 --output=%~dp0\build --force --present
#! /usr/bin/env python
# coding=utf-8
__author__ = 'jszhou'
from bottle import *
import hashlib
import xml.etree.ElementTree as ET
import urllib2
# import requests
import json
@vinjn
vinjn / ReadbackImage.cpp
Created June 7, 2012 05:06
GfxDeviceD3D9::ReadbackImage
bool GfxDeviceD3D9::ReadbackImage( /* params */ )
{
HRESULT hr;
IDirect3DDevice9* dev = GetD3DDevice();
SurfacePointer renderTarget;
hr = dev->GetRenderTarget( 0, &renderTarget );
if( !renderTarget || FAILED(hr) )
return false;
D3DSURFACE_DESC rtDesc;
@vinjn
vinjn / gist:2922506
Created June 13, 2012 07:23
Fastest method of screen capturing
void dump_buffer()
{
IDirect3DSurface9* pRenderTarget=NULL;
IDirect3DSurface9* pDestTarget=NULL;
const char file[] = "Pickture.bmp";
// sanity checks.
if (Device == NULL)
return;
// get the render target surface.
@vinjn
vinjn / gist:3366792
Created August 16, 2012 04:19
Direct3D Programming Tip #9: Use The Managed Resource Pool
//http://legalizeadulthood.wordpress.com/2009/10/12/direct3d-programming-tip-9-use-the-managed-resource-pool/
template <typename Index>
class index_lock
{
public:
// lock in constructor, unlock in destructor
index_lock(IDirect3DIndexBuffer9 *ib,
DWORD flags = 0,
UINT offset = 0,
@vinjn
vinjn / gist:3629716
Created September 5, 2012 03:12
Macro for run once
#define BLOCK_RUNONCE_START {\
static bool runonce_first = true;\
if (runonce_first)\
{\
runonce_first = false;
#define BLOCK_RUNONCE_END }}
@vinjn
vinjn / gist:3721038
Created September 14, 2012 09:40
technique11_template
BlendState NoBlend
{
BlendEnable[0] = False;
};
RasterizerState rsWireframe { FillMode = WireFrame; };
technique11
{
pass
@vinjn
vinjn / gist:3866579
Created October 10, 2012 16:06
perl_replace_translation
perl -pe "s/\sPage\s(\d+)/chr(ord(\1))-13/ge" <ch1_7_36.txt > cc.txt
@vinjn
vinjn / gist:4992484
Last active December 13, 2015 23:29
ppt翻页服务端
#!D:/Python26/python.exe
# -*- coding:cp936 -*-
import socket
import sys
import wx
import win32api
import win32ui
import win32gui
import SocketServer
import threading