Thursday, 15 April 2010

What does `impl TraitX for TraitY` mean in Rust? -



What does `impl TraitX for TraitY` mean in Rust? -

for example:

trait traitx { } trait traity { } impl traitx traity { }

i figured mean same as

impl<a: traity> traitx { }

but error message suggests otherwise:

$ rustc --version rustc 0.12.0-nightly (a70a0374e 2014-10-01 21:27:19 +0000) $ rustc test.rs test.rs:3:17: 3:23 error: explicit lifetime bound required test.rs:3 impl traitx traity { } ^~~~~~

does impl traitx traity (or variant of explicit lifetime) mean in rust? if so, illustration of use?

impl traitx traity using traity a dynamically sized type (dst). if add together required lifetime bound (see e.g. this more info necessity of lifetime bound), compiler complain in manner:

trait traitx { } trait traity { } impl<'a> traitx traity+'a { } fn main() {}

<anon>:3:1: 3:34 error: trait `core::kinds::sized` not implemented type `traity+'a` <anon>:3 impl<'a> traitx traity+'a { } ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <anon>:3:1: 3:34 note: trait `core::kinds::sized` must implemented because required `traitx` <anon>:3 impl<'a> traitx traity+'a { } ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

playpen

the errors saying traity+'a not sized, is, doesn't have size known @ compile time (e.g. u8 has size 1, vec<t> size of 3 pointers).

the syntax implementing traitx traity trait objects (these covered in "object types" section of reference), allowing handled (behind pointer) in places value implementing traitx expected. working usage involves sized? annotations, these whatever they're attached optionally (?) sized (the default things assumed sized).

#![allow(dead_code)] // indicate it's ok implement trait dsts trait traitx sized? { } trait traity { } trait traitz { } impl<'a> traitx traity+'a { } // sized? allow dsts passed this. fn example<sized? t: traitx>(_: &t) {} fn call_it(x: &traity, _y: &traitz) { example::<traity>(x); // possible if `traity` impls `traitx`. // error: // example::<traitz>(_y); // `traitz` doesn't impl `traitx`. } fn main() {}

playpen

the explicit ::<traity> type hint required when calling function unsized type now, bug #17178. moment, there's still quite few bugs dst it's not easy utilize in practice, improve.

the major motivation dst making handling trait objects more consistent other pointer types, e.g. back upwards &trait , box<trait> trait objects, dst designed allow other pointer types rc<trait>, arc<trait>. dst allows treating real pointers, e.g. if obj: box<trait> &*obj possible dst, illegal because trait objects fat pointers, not normal pointers.

rust

database - Auto-generate UUID in Slick -



database - Auto-generate UUID in Slick -

wonder if slick supports auto-generation of primary key of table uuid?

i have table has primary key (long format) beingness autogenerated each time insert table auto-incrementing. now, want alter uuid autogenerated id.

slick doesn't back upwards auto-generating uuids, database might. why not in db?

database primary-key uuid slick auto-generate

javascript - Uploading a file from a web app with dropzone.js -



javascript - Uploading a file from a web app with dropzone.js -

i building web app. have allow user upload image or drag-and-drop 1 browser. help this, i'm using dropzone.js. challenge is, need customize appearance bit.

my customization requires features seem pretty forwards in dropzone.js. basically, need: 1 file can uploaded @ once. while file beingness uploaded, need show progress bar. 1 time uploaded, need allow user either a) remove existing image or b) replace image one. in effort this, have next html:

<div id="mydropzone" style="cursor:pointer;"> <div class="files" id="previews"> <div id="template" class="file-row"> <ul class="list-inline"> <li> <span class="preview" style="width:300px;"><img data-dz-thumbnail /></span> <p class="size" data-dz-size></p> </li> <li style="vertical-align:top;"> <ul id="pictureactions" class="list-unstyled"> <li> <button class="btn btn-default dz-clickable file-input-button"> <i class="glyphicon glyphicon-picture"></i> <span>pick...</span> </button> </li> <li> <button data-dz-remove class="btn btn-danger btn-block" style="margin-top:8px;"> <i class="glyphicon glyphicon-trash pull-left"></i> <span>delete</span> </button> </li> </ul> </li> </ul> <div id="uploadprogress" class="progress" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"> <div class="progress-bar progress-bar-warning" style="width:0%;" data-dz-uploadprogress> <span>please wait...</span> </div> </div> </div> </div> <div id="uploadprompt">drag-and-drop image here</div> </div>

i initializing code dropzone using next javascript:

$(function () { var previewnode = document.queryselector("#template"); previewnode.id = ""; var previewtemplate = previewnode.parentnode.innerhtml; previewnode.parentnode.removechild(previewnode); var picturedropzone = new dropzone("div#mydropzone", { url: "/pictures/upload", clickable: true, uploadmultiple: false, autoprocessqueue: true, previewtemplate: previewtemplate, previewscontainer: "#previews", init: function () { this.on("complete", function (data) { $('#pictureactions').show(); $('#uploadprogress').hide(); $('#uploadprompt').hide(); }); }, uploadprogress: function (e, progress) { $('#uploadprogress').css('width', progress); }, removedfile: function () { $('#previews').hide(); $('#uploadprompt').show(); } }); });

there several problems though. if click text drag-and-drop image here, file picker not open. if click outside of text, file picker opens. also, code works initial process of choosing file. however, if click "pick..." button, page post back. in reality, expecting file picker appear again. if click "delete" button, , take file 1 time again file picker, picture, upload progress , action buttons never appear.

i sense i'm screwing initialization of dropzone somehow. doing wrong? why can't take image or delete image , take 1 or open file picker if click prompt text?

i have changed code

this.on("complete", function (data) { $("#previews").show(); //this line added ... , it's worked... $('#pictureactions').show(); $('#uploadprogress').hide(); $('#uploadprompt').hide(); });

i think line: $('#previews').hide(); have hidden preview element, , not alter status when append new image. :).

and word but, can see old image added, think it's new bug... trying solute it... have thought it.

http://jsfiddle.net/qek0xw1x/15/

javascript dropzone.js

jquery - How to add class to html elements in layout [ASP.NET MVC] -



jquery - How to add class to html elements in layout [ASP.NET MVC] -

i have next problem.

in layout have menu

<!-- collect nav links, forms, , other content toggling --> <div class="collapse navbar-collapse navbar-responsive-collapse"> <ul class="nav navbar-nav"> <li class="active"> @html.actionlink("blog","posts","blog",null,null) </li> <li> @html.actionlink("książki", "books", "books", null,null) </li> <li> @html.actionlink("o mnie", "aboutme", "blog", null,null) </li> </ul> </div> <!--/navbar-collapse-->

i want set class='active' element clicked, wrote script below (ignore can written better) in layout page.

<!-- js global compulsory --> <script type="text/javascript" src="~/scripts/assets/plugins/jquery-1.10.2.min.js"></script> <script type="text/javascript" src="~/scripts/assets/plugins/jquery-migrate-1.2.1.min.js"></script> <script type="text/javascript" src="~/scripts/assets/plugins/bootstrap/js/bootstrap.min.js"></script> <!-- js implementing plugins --> <script type="text/javascript" src="~/scripts/assets/plugins/back-to-top.js"></script> <!-- js page level --> <script type="text/javascript" src="~/scripts/assets/plugins/countdown/jquery.countdown.js"></script> <script type="text/javascript" src="~/scripts/assets/plugins/backstretch/jquery.backstretch.min.js"></script> @rendersection("scripts", required: false) <script type="text/javascript" src="~/scripts/assets/js/app.js"></script> <script type="text/javascript"> jquery(document).ready(function () { app.init(); $('.navbar-nav li').click(function () { var lis = $('.navbar-nav li'); lis[0].classlist.remove('active'); lis[1].classlist.remove('active'); lis[2].classlist.remove('active'); this.classlist.add('active'); }); }); </script>

but after click on link doesn't change. mean changes when step on script, after seems whole page requested 1 time again , changes overriden. how solve this?

thanks replies.

paweł

it seems confused how javascript works respect separate http requests , loading of page. javascript code part of current page , executes in client's browser. 1 time navigate different page, whole process starts on again. page loads, , javascript code executed.

your javascript code may doing intend do, after runs, page left , page loaded server, client-side state lost.

this code should set on server, instead of in javascript on client. when render html in views, should set active class on appropriate element @ point. when user clicks link, request different page server, , when render html page, set active class accordingly. no javascript code required.

jquery html asp.net asp.net-mvc

asp.net mvc - C# Entity Framework SQL Error -



asp.net mvc - C# Entity Framework SQL Error -

i have emailhistorymodel :

public class emailhistory { public guid id { get; set; } public string companyid { get; set; } public guid? userid { get; set; } public datetime createddate { get; set; } public datetime sentdate { get; set; } public datetime updatedate { get; set; } public string outcome { get; set; } public datetime emaildelivereddate { get; set; } public datetime emailopened { get; set; } public string emailaddress { get; set; } public string htmlemail { get; set; } public string integrationdocumentid { get; set; } public rules rulesid { get; set; } public int transactionid { get; set; } }

i maintain getting error when trying access model. @ moment trying run next :

var emailhistorytotal = !emailhistory.any() ? 1 : emailhistory.count();

this keeps giving me error : "entityframework.dll not handled in user code

additional information: conversion failed when converting character string uniqueidentifier"

i'm not sure has changed working ok.....

if run next in sql, returns ok!?: select * [dbo].[emailhistory]

in sql columns set unique identifier id, rulesid_id , userid.

the emailhistory comming repository (see below method)

public iqueryable<emailhistory> getemailhistorybyuser(string userid) { homecoming _autosendcontext.emailhistory.asqueryable(); }

the _autosendcontext global variable interact db

any help or guidance great!

ok... nil email history table. error due info migrations, auto migration trying alter field in database nvarchar unique identifier.

this statement scheme trying run : alter table [dbo].[transactions] alter column [companyid] [uniqueidentifier] null

c# asp.net-mvc entity-framework

css - Efficient way to set 100% height for all the parents -



css - Efficient way to set 100% height for all the parents -

i want div 100% height of viewport. basic code this:

http://jsfiddle.net/c247opd6/

now, in real web page situation more this:

http://jsfiddle.net/akrv5cgm/ div nested within other divs.

i know code of sec illustration doesn't work because in order element have 100% of height of parent, parent must either have explicitly defined height or 100% of height of parent. fix:

.four, .three, .two { height: 100%; }

however start adding code solution becomes harder , harder mantain. there shorter css rule allow me set 100% height parent divs? nth-child, except parents.

i want div 100% height of viewport.

you utilize viewport relative units:

5.1.2. viewport-percentage lengths: ‘vw’, ‘vh’, ‘vmin’, ‘vmax’ units

the viewport-percentage lengths relative size of initial containing block. when height or width of initial containing block changed, scaled accordingly.

in case utilize height: 100vh, 1vh equivalent 1% of viewport.

updated example

.one { height: 100vh; background-color: reddish }

browser back upwards these units can found here.

it's worth pointing out element won't take height of direct parent consideration.

css

asp.net mvc - MVC - AJAX Post - Open Partial View in Dialog Box -



asp.net mvc - MVC - AJAX Post - Open Partial View in Dialog Box -

in bootstrap dialog box, have ajax form :-

@using (ajax.beginform("method", "settings", formmethod.post, null)) { <div class="container"> <div class="row form-horizontal" id="fieldslist"> .... <button type="submit" class="btn">back</button> } [httppost] public actionresult method(formcollection form) { .... homecoming partialview("pagepartial",model); }

when nail submit button, dialog box closes & see new page.

how open partialview in dialog itself?

try as

@using (ajax.beginform("method", "settings", new ajaxoption{httpmethod="post", onsuccess="onsuccess"})) { <div class="container"> <div class="row form-horizontal" id="fieldslist"> .... <button type="submit" class="btn">back</button> } <script> function onsuccess(result){ //your code } </script>

ajax asp.net-mvc