Skip to content

Instantly share code, notes, and snippets.

View margusmartsepp's full-sized avatar
😇
It is that simple

Margus Martsepp margusmartsepp

😇
It is that simple
  • Gunvor SA
  • Tallinn
View GitHub Profile
public static bool Serialize<T>(this T item, string filename)
{
try
{
var ser3 = new XmlSerializer(typeof(T));
using (var writer = XmlWriter.Create(filename))
{
ser3.Serialize(writer, item);
}
return true;
@margusmartsepp
margusmartsepp / gist:5ef859711a8da002e8c7
Last active August 29, 2015 14:07
Change rss encoding using mvc connector
public class RssController : Controller
{
public FileContentResult Index()
{
var doc = new XmlDocument();
doc.Load(ConfigurationManager.AppSettings["feed"]);
var settings = new XmlWriterSettings
{
Encoding = Encoding.GetEncoding(ConfigurationManager.AppSettings["encoding"]),
NewLineHandling = NewLineHandling.Entitize,
[TestMethod]
public void k()
{
var n = 10000000;
var r = new Random();
var listYes = new List<Tuple<double, double>>();
var listNo = new List<Tuple<double, double>>();
for (var i = 0; i < n; i++)
{
var point = Tuple.Create(r.NextDouble(), r.NextDouble());
//PM > Install-Package Selenium.WebDriver
//PM > Install-Package Selenium.Support
//PM > Install-Package Selenium.WebDriver.ChromeDriver
public static bool TestTPilet(out TimeSpan time)
{
DateTime date0 = DateTime.Now;
DateTime date1;
using (var driver = new ChromeDriver())
{
@margusmartsepp
margusmartsepp / call.cs
Last active August 29, 2015 14:27
IB filename
string fullPath = Server.MapPath(FileUploadHelper.formFullPath(id.ToString(), fileUploadType, filename));
public static string formFullPath(Object id, FileUploadType type, Object fileName)
{
return formFullPath(id, type, fileName, false, null);
}
public static string formFullPath(Object id, FileUploadType type, Object fileName, bool needsMapping, HttpServerUtility server)
{
String fullPath = null;
if (specialid == null) {
ado.slave(id, {
myMaster: master
});
} else {
if (specialid != id) {
$(el).attr('id', specialid);
ado.slave(specialid, {
myMaster: master
});
@margusmartsepp
margusmartsepp / isemptyfalse.js
Last active October 28, 2015 07:28
adocean example
function adoceanaripaeevhhngrpfgz() {
if (typeof ado==="object") {var _ado_elem = ado.beginCreative({id:'adoceanaripaeevhhngrpfgz', arg:'', isEmpty:0});}
adocean_break_ooiqqvshdw=function() {
var id=document.getElementById('script_ooiqqvshdw');
if (id) { eval("try { id.src = 'http://'; id.text=''; } catch(exception) { }");}};
if(typeof gao === "undefined") gao = {};
if(typeof gao.bbb !== "object") gao.bbb = [];
bbb = {};
bbb.width = "660";
[%{AdOceanId}
[%{!NoBlock}
<div class="bannerwrap [%{LeftSide=1} col-sm-6 pull-left%|%[%{RightSide=1} col-sm-6 pull-right%]%] [%{Mobile=0}hidden-xs%] [%{Desktop=0} visible-xs-block%][%{Panorama=1}panorama %][%{PageBreak=1}page-break-container %] <%BlockClass%>">
%]
[%{ShowBanners & ShowBanners=0 | nobanners=1}
<div class="banner [%{Mobile=0}hidden-xs%] [%{Desktop=0}visible-xs-block%]" style="[%{Height}height:<%Height%>px!important;line-height:<%Height%>px;%]background-color:#C2D3CD;text-align:center;[%{!Panorama}margin-top:15px;%]width:100%;display:block;">
[%{Mobile=1}M%][%{Desktop=1}D%] BANNER, id:<%AdOceanId%>
</div>
@margusmartsepp
margusmartsepp / Pivot.cs
Created November 6, 2015 15:21
Get data from gist
private static string _pass = "***";
private static string _user = "margus.martsepp@agileworks.eu";
private static string _puri = "https://www.pivotaltracker.com/n/projects/1155920";
[Test]
public void ReadPivot()
{
using (var d = new ChromeDriver())
{
d.Navigate().GoToUrl(_puri);
d.FindElement(By.Id("credentials_username")).SendKeys(_user);
@margusmartsepp
margusmartsepp / gist:bf64cd645fe80e017765
Created November 12, 2015 14:40
fluent nunit tests
[TestFixture]
public class RepresentativeServiceTests
{
public class TestStory
{
public class Fail
{
public static IEnumerable Constructor
{
get