Skip to content

Instantly share code, notes, and snippets.

View mrcaron's full-sized avatar
👾
Typing typing typing

Michael Caron mrcaron

👾
Typing typing typing
View GitHub Profile
@mrcaron
mrcaron / setControls.cpp
Created September 17, 2009 17:20
Sets up unicode font in a rich text edit control for MFC
/* SET UNICODE FONT */
CDC *pDC = GetDC();
LOGFONT lf;
memset(&lf, 0, sizeof(lf));
lf.lfHeight = MulDiv(20, ::GetDeviceCaps(pDC->m_hDC, LOGPIXELSY), 72);
lf.lfWeight = FW_NORMAL;
lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;
wcscpy(lf.lfFaceName, _T("Lucida Sans Unicode"));
CFont font;
font.CreateFontIndirect(&lf);
@mrcaron
mrcaron / gitprojinit.sh
Created October 22, 2009 20:12
Git project init script
#!/bin/bash
# input repository name, using '-' for any spaces ($1)
# input GH username $2
mkdir ${1}
cd ${1}
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@github.com:${2}/${1}.git
@mrcaron
mrcaron / ghpushexisiting.sh
Created October 22, 2009 20:16
Git Push Existing script
#!/bin/bash
# use this script at the root directory of your local repo
# Input repo name and username
git remote add origin git@github.com:${2}/${1}.git
git push origin master
@mrcaron
mrcaron / Powershell_Prompt.ps1
Created January 20, 2010 17:16
Powershell prompt
# Powershell Prompt
$global:CurrentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent()
function prompt
{
$un = [Regex]::Match($CurrentUser.Name,"SOLIDWORKS\\+(.*)").Groups[1].Value
$hn = [Net.DNS]::GetHostName()
$host.ui.rawui.WindowTitle = $un + "@" + $hn #+ " Line: " + $host.UI.RawUI.CursorPosition.Y
Write-Host($un + "@" + $hn + " ") -foregroundcolor Green -nonewline; Write-Host ($(get-location)) -foregroundcolor Yellow
Write-Host(">") -nonewline -foregroundcolor Green
@mrcaron
mrcaron / GridNode.fx
Created February 5, 2010 16:43
Creating a jfxtras Grid in JFX
/* Creating an org.jfxtras.scene.layout.Grid */
public class MyGrid extends CustomNode {
override function create(): Node {
Grid {
rows: [
Row{
cells: [Text {content: "Username:"}, TextBox {}]
},
Row{
@mrcaron
mrcaron / .vimrc
Created September 21, 2010 13:32
.vimrc
# .vimrc
filetype off
filetype plugin indent on
set nocompatible
set modelines=0
set tabstop=4
@mrcaron
mrcaron / InterestingWindowsErrors.md
Created January 6, 2011 20:35
Windows error descriptions that may be hard to find

Out of heap resources allocated for SolidWorks gives:
GetLastError() == 0x00000486 "The current process has used all of its system allowance of handles for Window Manager objects."

Out of heap resources due to other applications using a ton of windows gives: GetLastError() == 0x00000008 "Not enough storage is available to process this command."

@mrcaron
mrcaron / utf16_2_ascii.py
Created May 10, 2011 15:39
Python UTF-16 to Ascii file converter
import codecs
import sys
import os
if __name__ == "__main__":
lines = ''
with codecs.open(sys.argv[1], 'r', 'utf-16') as f:
lines = f.read()
os.rename(sys.argv[1], sys.argv[1] + '_utf16')
with codecs.open(sys.argv[1], 'w', 'ascii') as w:
@mrcaron
mrcaron / vcpp_property_macros.h
Created February 1, 2012 15:00
VCPP STD::Map-backed Property Macros
#define _UNICODE
#define _map_property(_type, _name, _map) \
_type Get##_name() { ASSERT( K_##_name > -1 ); return _map[K_##_name]; } \
void Set##_name( _type val ) { ASSERT( K_##_name > -1); _map[K_##_name] = val; } \
__declspec(property(get=Get##_name, put=Set##_name)) _type _name
typedef std::map<int, wstring> wstrmap;
class myClass
{
@mrcaron
mrcaron / SingletonTemplate.hpp
Last active December 11, 2015 21:49
Working on a singleton implementation
namespace Utils
{
template <class T>
class Singleton
{
public:
static T& Instance()
{
if (MInstance == 0)
MInstance = new T();