Skip to content

Instantly share code, notes, and snippets.

View MichalGrzegorzak's full-sized avatar

Michal Grzegorzak MichalGrzegorzak

  • UK
View GitHub Profile
@MichalGrzegorzak
MichalGrzegorzak / SetSelectedMultipleItemPropertyValues.cs
Created February 12, 2013 08:36
Fill list controls from episerver custom property settings
protected void SetSelectedMultipleItemPropertyValues(string propertyName, ListControl control)
{
var listValues = EditModel[propertyName] == null ? new List<string>()
: EditModel[propertyName].ToString().Split(',').ToList();
foreach (var option in GetMultipleOptionsListItemsForProperty(propertyName).ListOptions)
{
var newItem = new ListItem(option.Key, option.Value);
if (!control.Items.Contains(newItem))
control.Items.Add(newItem);
public static class IEnumerableExtensions
{
public static IEnumerable<T> OrEmptyListIfNull<T>(this IEnumerable<T> source)
{
return source ?? Enumerable.Empty<T>();
}
}
private void CleanupXFormHtmlMarkup(XFormControl formControl)
{
if (formControl.EditMode)
{
// We need to render the default table when in edit mode, otherwise the form wizard won't work
return;
}
bool firstLiteralControl = false;
import requests
url = 'http://lazyeyedhacker.com/wp-comments-post.php'
headers = {'user-agent':'Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20100101 Firefox/8.0', 'referrer':'http://lazyeyedhacker.com'}
for n in range(3,10000):
payload = {'author':'mua ha ha','email':'muahaha@lazyeyedhacker.com','url':'http://muahaha.lazyeyedhacker.com','comment':'blah','comment_post_ID':'1'}
payload['comment'] = 'muahaha ' * n
r = requests.post(url,data=payload,headers=headers)
private static bool PageDataHasChanged(PageData pageOne, PageData pageTwo)
{
PageType type = PageType.Load(pageOne.PageTypeName);
foreach (var property in type.Definitions.Where(p=> GetPropertynames<CoursePage>().Contains(p.Name)))
{
if (pageOne[property.Name] == pageTwo[property.Name])
{
continue;
}
[XmlIgnore]
public Uri Url { get; set; }
[XmlAttribute("uri")]
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public string UriString
{
get { return Url == null ? null : Url.ToString(); }
set { Url = value == null ? null : new Uri(value); }
}
this.PageName = node.SelectSingleNode("T") != null ? EPiServer.Core.Html.TextIndexer.StripHtml(node.SelectSingleNode("T").InnerXml.Trim().HtmlDecode(),200) : string.Empty;
if (this.PageName.IsNullOrWhiteSpace())
{
this.PageName = "( No Title )";
var UseWebRequestToResolveSupportTitle =
WebConfigurationManager.AppSettings["UseWebRequestToResolveSupportTitle"] != null && Convert.ToBoolean(WebConfigurationManager.AppSettings["UseWebRequestToResolveSupportTitle"]);
if (UseWebRequestToResolveSupportTitle)
{
var cachedTitle =
(string)EPiServer.CacheManager.Get(SupportCacheKey);
require 'albacore'
$msbuildpath = 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe'
$aspnet_compiler_path = 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe'
$publishdir = 'Publish'
$major_version = '1'
task :default => [:full]
task :full => [:publish, :zip] do
# Load posh-git profile
. 'C:\Projects\Tools\posh-git\profile.example.ps1'
function vsh() {
Write-Output "Opening first solution..."
$sln = (dir -in *.sln -r | Select -first 1)
Write-Output "Found $($sln.FullName)"
Invoke-Item $sln.FullName
}
ALTER DATABASE [AspectoWeb] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
RESTORE DATABASE [AspectoWeb]
FROM DISK = N'C:\Users\RasmusKL\Desktop\www.aspectoweb.com_backup_2011_12_15_030005_0285276\www.aspectoweb.com_backup_2011_12_14_031114_3950159.wbak'
WITH NORECOVERY, REPLACE
RESTORE DATABASE [AspectoWeb]
FROM DISK = N'C:\Users\RasmusKL\Desktop\www.aspectoweb.com_backup_2011_12_15_030005_0285276\www.aspectoweb.com_backup_2011_12_15_030005_0285276.bak'
WITH RECOVERY