Skip to content

Instantly share code, notes, and snippets.

View lextm's full-sized avatar
💭
I may be slow to respond.

Lex Li lextm

💭
I may be slow to respond.
View GitHub Profile
@lextm
lextm / gist:3198483
Created July 29, 2012 12:43
ANTLR generated method
private sealed partial class statement_return : AstParserRuleReturnScope<CommonTree, IToken>
{
public MibDocument result = new MibDocument();
public statement_return(SmiParser grammar) {OnCreated(grammar);}
partial void OnCreated(SmiParser grammar);
}
partial void EnterRule_statement();
partial void LeaveRule_statement();
// $ANTLR start "statement"
@lextm
lextm / compare.pas
Created July 27, 2012 02:13
Inno Setup script sample part 3
function GetNumber(var temp: String): Integer;
var
part: String;
pos1: Integer;
begin
if Length(temp) = 0 then
begin
Result := -1;
Exit;
end;
@lextm
lextm / version.pas
Created July 27, 2012 02:10
Inno Setup script sample part 2
function InitializeSetup(): Boolean;
var
oldVersion: String;
uninstaller: String;
ErrorCode: Integer;
begin
if RegKeyExists(HKEY_LOCAL_MACHINE,
'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F768F6BA-F164-4599-BC26-DCCFC2F76855}_is1') then
begin
RegQueryStringValue(HKEY_LOCAL_MACHINE,
@lextm
lextm / gist:3185804
Created July 27, 2012 02:08
Inno Setup script sample part 1
AppVersion=6.0.0.1004
AppID={{F768F6BA-F164-4599-BC26-DCCFC2F76855}
@lextm
lextm / innosample.pas
Created July 27, 2012 02:05
Inno Setup script sample for advanced part 3
function Count(What, Where: String): Integer;
begin
Result := 0;
if Length(What) = 0 then
exit;
while Pos(What,Where)>0 do
begin
Where := Copy(Where,Pos(What,Where)+Length(What),Length(Where));
Result := Result + 1;
end;
@lextm
lextm / gist:3185774
Created July 27, 2012 02:01
Inno Setup script sample for advanced part 2
[Code]
// function IsModuleLoaded to call at install time
// added also setuponly flag
function IsModuleLoaded(modulename: String ): Boolean;
external 'IsModuleLoaded@files:psvince.dll stdcall setuponly';
// function IsModuleLoadedU to call at uninstall time
// added also uninstallonly flag
function IsModuleLoadedU(modulename: String ): Boolean;
external 'IsModuleLoaded@{app}\psvince.dll stdcall uninstallonly' ;
@lextm
lextm / gist:3185759
Created July 27, 2012 01:54
Inno Setup script sample for advanced part 1
#define MyAppID "{F768F6BA-F164-4599-BC26-DCCFC2F76855}"
#define MyAppCopyright "Copyright (C) 2005-2007 Lex Li and other contributors."
#define MyAppName "Code Beautifier Collection"
#define MyAppVersion GetFileVersion("..\bin\release\Lextm.CodeBeautifierCollection.Framework.dll")
[Setup]
AppName={#MyAppName}
AppVerName={#MyAppName}
AppPublisher=Lex Li (lextm)
AppPublisherURL=http://lextm.com
@lextm
lextm / antlr_csproj_reference.xml
Created July 27, 2012 01:40
ANTLR reference in csproj files
<Reference Include="Antlr3.Runtime, Version=3.4.1.9004, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Antlr.Unofficial.3.4.1.0\lib\Antlr3.Runtime.dll</HintPath>
</Reference>
@lextm
lextm / antlr_csproj_grammar.xml
Created July 27, 2012 01:39
ANTLR grammar files in csproj files
<Antlr3 Include="Mib\Smi.g" />
<None Include="Mib\Smi_no_action.g" />
@lextm
lextm / antlr_csproj_targets.xml
Created July 27, 2012 01:36
Targets fragment for csproj files
<PropertyGroup>
<AntlrBuildTaskPath>$(MSBuildProjectDirectory)\..\lib\ANTLR</AntlrBuildTaskPath>
<AntlrToolPath>$(MSBuildProjectDirectory)\..\lib\antlr\antlr3.exe</AntlrToolPath>
</PropertyGroup>
<Import Project="..\lib\ANTLR\Antlr3.targets" />