Skip to content

Instantly share code, notes, and snippets.

View csharpforevermore's full-sized avatar
🏠
Working from home

Randle csharpforevermore

🏠
Working from home
View GitHub Profile
@csharpforevermore
csharpforevermore / CreateHostsFileEntries.bat
Last active August 29, 2015 13:58
Will add some entries to the hosts file, unless they are already there. Any requests to those URLs will be redirected to home. www.google.com and www.google.co.uk.
@echo off
SET NEWLINE=^& echo.
FIND /C /I GLOBAL_URL1 %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^127.0.0.1 www.google.com>>%WINDIR%\System32\drivers\etc\hosts
FIND /C /I GLOBAL_URL2 %WINDIR%\system32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^127.0.0.1 www.google.co.uk>>%WINDIR%\System32\drivers\etc\hosts
@csharpforevermore
csharpforevermore / gist:11348692
Created April 27, 2014 15:38
List all Macros, along with their cache durations, in Umbraco CMS SQL Database - tested on version 4 and 6.
USE [MyDatabaseName]
GO
SELECT
macro AS 'ID',
macroName AS 'Name',
macroPropertyName AS "Property Name",
macroPropertyAlias AS 'Alias',
macroRefreshRate AS 'Timeout'
@csharpforevermore
csharpforevermore / AuthoHotKeyList.txt
Created April 27, 2014 15:50
AutoHotKey Key List
Key Name Resulting Keystroke
{F1} - {F24} Function keys. For example: {F12} is the F12 key.
{!} !
{#} #
{+} +
{^} ^
{{} {
{}} }
{Enter} ENTER key on the main keyboard
{Escape} or {Esc} ESCAPE
@csharpforevermore
csharpforevermore / SVN_file_exclude_properties.svnprops
Created May 19, 2014 01:12
SVN suggested global ignore pattern. Umbraco 6. ReSharper.
*.o *.lo .la ## .*.rej .rej .~ ~ .# .DS_Store thumbs.db Thumbs.db *.bak *.class *.exe *.dll *.mine *.obj *.ncb *.lib *.log *.idb *.pdb *.ilk .msi .res *.pch *.suo *.exp ~. cvs CVS .CVS .cvs release Release debug Debug ignore Ignore bin Bin obj Obj *.csproj.user *.user _ReSharper.* *.resharper.user Activity.txt Logs TEMP umbraco.config preview
@csharpforevermore
csharpforevermore / 7zAllFiles.bat
Created June 5, 2014 13:23
7zip all files in the current folder to individual archives.
REM by Goyuix at Stackoverflow, 18th June 2011
REM *********
ECHO Starting
FOR %%i IN (*.*) DO 7z.exe a "%%~ni.7z" "%%i"
ECHO Stopped
@csharpforevermore
csharpforevermore / gist:fe7da20efc3259f56aba
Created June 8, 2014 13:23
Umbraco.NET a .gitignore file
EVPCustomLogs
Tenant.xml
###################
# compiled source #
###################
*.com
*.class
*.dll
*.exe
*.pdb
@csharpforevermore
csharpforevermore / ReflectionHelperMethod.cs
Created June 8, 2014 15:28
Read the value of a given property in an object from the name using reflection
public static object GetPropValue(object src, string propName)
{
return src.GetType().GetProperty(propName).GetValue(src, null);
}
@csharpforevermore
csharpforevermore / Submit.cshtml
Created July 31, 2014 13:40
Set <form/> action value from jQuery
<form action="foo">
<button name="action" value="bar">Go</button>
</form>
<script type="text/javascript">
$('form').attr('action', 'baz'); //this fails silently
$('form').get(0).setAttribute('action', 'http://www.github.com/'); //this works
</script>
@csharpforevermore
csharpforevermore / QueryStringParser.cs
Created July 31, 2014 13:46
Strongly typed reading of querystring collection items.
public static T GetValue<T>(this NameValueCollection collection, string key)
{
if(collection == null)
{
throw new ArgumentNullException("collection");
}
var value = collection[key];
if(value == null)
@csharpforevermore
csharpforevermore / web.config
Created July 31, 2014 13:58
Add folders to your App_Code folder. This will compile any classes found in /App_Code/Extensions/
<configuration>
<system.web>
<compilation>
<codeSubDirectories>
<add directoryName="Extensions"/>
</codeSubDirectories>
</compilation>
</system.web>
</configuration>