Commits

Cesar Lopez-Nataren  committed 820c52d

Save rating pages program

  • Participants

Comments (0)

Files changed (7)

+bin/
+dist/
+*resharper.user
+[Dd]ebug/
+[Rr]elease/
+Signed Debug/
+Signed Release/
+obj/
+*.ncb
+*.suo
+_ReSharper.*/
+*.pdb
+*.snk
+*.user
+*.log
+App_Data/
+*.pidb
+*.test-cache
+*.userprefs
+*.resources
+*.cache
+*.pidb
+nunit-results.xml
+*.orig
+*.ReSharper
+*.tmp
+*.bak
+LocalSettings.php
+cache/
+attachments/
+.project
+devtools_firephp/
+.idea
+web/deki/javascript/out
+*.dotCover
+*.opensdf
+*.sdf
+web/lang.php

File RatePages.sln

+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RatePages", "RatePages\RatePages.csproj", "{7F741BC1-F29F-4D46-843E-C037BA45D3AE}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|x86 = Debug|x86
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{7F741BC1-F29F-4D46-843E-C037BA45D3AE}.Debug|x86.ActiveCfg = Debug|x86
+		{7F741BC1-F29F-4D46-843E-C037BA45D3AE}.Debug|x86.Build.0 = Debug|x86
+		{7F741BC1-F29F-4D46-843E-C037BA45D3AE}.Release|x86.ActiveCfg = Release|x86
+		{7F741BC1-F29F-4D46-843E-C037BA45D3AE}.Release|x86.Build.0 = Release|x86
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

File RatePages/Program.cs

+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using MindTouch;
+using MindTouch.Dream;
+
+namespace RatePages {
+    class Program {
+        static void Main(string[] args) {
+            var log = LogUtils.CreateLog();
+            var stream = new FileStream("pages-keithstage.txt", FileMode.Open);
+            var bytes = new byte[stream.Length];
+            stream.Read(bytes, 0, bytes.Length);
+            var pages = Encoding.UTF8.GetString(bytes).Split(new string[] { "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries);
+            pages = pages.Select(page => page.TrimStart().TrimEnd()).OrderByDescending(pp => pp).ToArray();
+
+            // Sometimes reverse the order of the pages
+            var orderDecisionMaker = new Random((int)DateTime.Now.Ticks);
+            if(orderDecisionMaker.Next() % 2 == 1) {
+                pages = pages.Reverse().ToArray();
+            }
+
+            // Start rating!
+            var random = new Random((int)DateTime.UtcNow.Ticks);
+            foreach(var page in pages) {
+                var rating =  (random.Next() % 2).ToString();
+                var user = "rater" + random.Next() % 11;
+                var p = Plug.New(string.Format("{0}/@api/deki", args[0])).WithCredentials(user, args[2]);
+                Console.WriteLine("Will post rating '{0}' to page '{1}' as '{2}'", rating, page, user);
+                try {
+                    var resp = p.At("pages", page, "ratings").With("score", rating).Post();
+                    if(resp.Status != DreamStatus.Ok) {
+                        Console.WriteLine("Failed to post to rating '{1}' to page '{0}'", page, rating);
+                    }
+                } catch(Exception e) {
+                    log.WarnFormat("Failed to rate page '{0}'", page);
+                }
+                //Thread.Sleep(100);
+            }
+        }
+    }
+}

File RatePages/Properties/AssemblyInfo.cs

+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("RatePages")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("RatePages")]
+[assembly: AssemblyCopyright("Copyright ©  2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("29638e99-17ff-4e49-ba04-4a8f8a6ea1de")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

File RatePages/RatePages.csproj

+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{7F741BC1-F29F-4D46-843E-C037BA45D3AE}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>RatePages</RootNamespace>
+    <AssemblyName>RatePages</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <TargetFrameworkProfile>
+    </TargetFrameworkProfile>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <PlatformTarget>x86</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <PlatformTarget>x86</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Autofac">
+      <HintPath>..\..\..\..\..\git\Deki\src\redist\Autofac.dll</HintPath>
+    </Reference>
+    <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\..\..\git\Deki\src\redist\log4net.dll</HintPath>
+    </Reference>
+    <Reference Include="mindtouch.dream">
+      <HintPath>..\..\..\..\..\git\Deki\src\redist\mindtouch.dream.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="app.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="pages-keithstage.txt">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

File RatePages/app.config

+<?xml version="1.0"?>
+<configuration>
+<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>