Skip to content

Instantly share code, notes, and snippets.

View csharpforevermore's full-sized avatar
💭
Developing

Randle csharpforevermore

💭
Developing
View GitHub Profile
@csharpforevermore
csharpforevermore / FileUploadAspNet.cs
Last active December 30, 2015 04:09 — forked from Benrnz/FileUploadAspNet.cs
Uploads a file to the server and save it to disk. (INCOMPLETE)
public static bool UploadToServer(string pathToFile)
{
bool failure = false;
if (!FileUpload1.FileName.ToLowerInvariant().EndsWith(".xml")) {
failure = true;
}
StreamReader reader = new StreamReader(FileUpload1.FileContent);
string xmlContent = reader.ReadToEnd();
if (!xmlContent.TrimStart().StartsWith("<?xml")) {
if (fuImage.HasFile)
{
PostedMediaFile postedMediaFile = new PostedMediaFile
{
ContentLength = fuImage.PostedFile.ContentLength,
ContentType = fuImage.PostedFile.ContentType,
FileName = fuImage.PostedFile.FileName,
InputStream = fuImage.PostedFile.InputStream
};
Media media = MediaFactory.GetMediaFactory(-1, postedMediaFile, new umbraco.BusinessLogic.User(0)).HandleMedia(-1, postedMediaFile, new umbraco.BusinessLogic.User(0), true);
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections>
<log4net>
<appender name="OutputDebug" type="log4net.Appender.OutputDebugStringAppender, log4net">
<layout type="log4net.Layout.PatternLayout,log4net">
<conversionPattern value="%d [%t] %-5p %c - %m%n"/>
</layout>
</appender>
@csharpforevermore
csharpforevermore / UmbracoChangeDocTypeParent
Last active August 29, 2015 14:08 — forked from drift/UmbracoChangeDocTypeParent
Umbraco use of version 6's ContentTypeService
@using Umbraco.Core.Models;
@using Umbraco.Core.Services;
var contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
var contentType = contentTypeService.GetContentType(4200);
contentType.ParentId=3130;
contentTypeService.Save(contentType);
Here are all the classes from Bootstrap 3 (version 3.1.1).
Method of extraction:
1. Download Bootstrap 3 and rename bootstrap.css as "bootstrap.html"
2. Add the following 24 lines of code to the very bottom of the bootstrap.html file:
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script>
<script>
string simpleString = "this string will be cached";
HttpRuntimeCache cache = new HttpRuntimeCache();
cache.Add("simpleString", simpleString);
string fromCache = cache.Get("simpleString") as string;
cache.Remove("simpleString");
@csharpforevermore
csharpforevermore / Timer.cs
Created October 30, 2015 22:09
Stopwatch Timer
var stopwatch = Stopwatch.StartNew();
for (int i = 1; i < 1000000000; i++)
{
// run method here
}
stopwatch.Stop();
Console.writeline("Elapsed time: {0}", stopwatch.Elapsed);
@csharpforevermore
csharpforevermore / FormsValidationExample.cs
Last active November 26, 2015 22:13 — forked from TimGeyssens/Umbraco Forms validation example
Umbraco Forms validation example
public class FormsValidation : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
Umbraco.Forms.Web.Controllers.UmbracoFormsController.FormValidate += UmbracoFormsController_FormValidate;
}
void UmbracoFormsController_FormValidate(object sender, Umbraco.Forms.Mvc.FormValidationEventArgs e)
{
@csharpforevermore
csharpforevermore / umbraco 7 db cleanup.sql
Last active December 15, 2021 14:02 — forked from dampee/umbraco db cleanup.sql
Umbraco Database cleanup. After pulling in an umbraco database from production, you don't need all history or log.
-- Umbraco Clear Old Document Versions To Decrease Database Size And Improve Performance
-- http://borism.net/2008/12/16/fixing-a-large-cmspropertydata-table-in-umbraco/
DECLARE @createdDate Datetime = DATEADD(m, -1, getdate())
-- dump logs
-- TRUNCATE TABLE umbracolog -- faster if log table is very big and you don't need anything
DELETE FROM umbracolog WHERE Datestamp < @createdDate
-- clean up old versions
DELETE FROM cmsPropertyData WHERE