Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Chen Tao jagt

🏠
Working from home
View GitHub Profile
@jagt
jagt / export_camera_standalone.py
Last active Sep 17, 2018
Standalone script for exporting camera animation w/ custom attributes.
View export_camera_standalone.py
'''
export camera standalone
1. put in `C:/Users/<user>/Documents/maya/scripts`
2. open maya and select the camera in outliner
3. menu 'custom->Export Selected Camera'
'''
from maya import cmds
from maya import mel
def make_kwargs(overrides, **kwargs):
@jagt
jagt / ipython_maya_2018.md
Created Jun 19, 2018
Setting up IPython for Maya 2018
View ipython_maya_2018.md
  1. Put mayapy on Path
  2. Open a cmd as admin
  3. run mayapy -m ensurepip --default-pip
  4. run mayapy -m pip install --upgrade pip
  5. run mayapy -m pip install ipython==5.7.0
  6. delete C:\Program Files\Autodesk\Maya2018\Python\Lib\site-packages\_scandir.pyd. it's build against original python release version.
  7. test mayapy -c "from IPython import embed; embed()"
View union.cs
using System;
using System.Runtime.InteropServices;
// turns out primitive C# union is already doable
// http://www.xtremedotnettalk.com/tutors-corner/97390-unions.html
[StructLayout(LayoutKind.Explicit)]
public struct MyUnion
{
[FieldOffset(0)]
@jagt
jagt / twod_array.linq
Last active Jan 4, 2019
c# 2d array example
View twod_array.linq
void Swap(ref float lhs, ref float rhs)
{
float tmp = lhs;
lhs = rhs;
rhs = tmp;
}
void InplaceFlipX(float[,] arr)
{
View core-coding-standard.md

Core Coding Standard

Coding practices are a source of a lot of arguments among programmers. Coding standards, to some degree, help us to put certain questions to bed and resolve stylistic debates. No coding standard makes everyone happy. (And even their existence is sure to make some unhappy.) What follows are the standards we put together on the Core team, which have become the general coding standard for all programming teams on new code development. We’ve tried to balance the need for creating a common, recognizable and readable code base with not unduly burdening the programmer with minor code formatting concerns.

Table Of Contents

@jagt
jagt / InstaLODEditorUtils.cs
Created Feb 1, 2018
InstaLOD binding example
View InstaLODEditorUtils.cs
using System;
using System.IO;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using InstaLOD;
using System.Runtime.InteropServices;
public static class InstaLODEditorUtils
{
@jagt
jagt / publicize.cs
Last active Jan 30, 2018
publicize.cs
View publicize.cs
using Mono.Cecil;
using System;
using System.Linq;
using System.Collections.Generic;
// inplace publicize all methods/types in a dll
// need Mono.Cecil in nuget
class Program
{
View embed_civet_genie.lua
solution 'embed-civet'
location './build'
configurations {'Debug', 'Release'}
platforms {'x32', 'x64'}
startproject 'main'
includedirs {
'civetweb/include',
}
defines {'USE_WEBSOCKET'}
View on_hit.lua
local delegates = {}
local function OnEvent(evt, cb)
local cb_dump = string.dump(cb)
delegates[evt] = cb_dump
end
-- declare callbacks
OnEvent('hit', function(evt)
damage(evt.source)
@jagt
jagt / RoslynCodeGen.cs
Created Dec 15, 2017
Sample roslyn code generation
View RoslynCodeGen.cs
using System;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editing;
// ref https://msdn.microsoft.com/en-us/magazine/mt707527.aspx
// needed packages
// Microsoft.CSharp;
// Microsoft.CodeAnalysis;
// Microsoft.CodeAnalysis.CSharp;
// Microsoft.CodeAnalysis.CSharp.Workspaces;
You can’t perform that action at this time.