Posts

Showing posts from August, 2011

c# - Dynamic JsonIgnore for properties within a list -

i using json.net library. have json looks this: "templates": [ { "name": "default fields 1", "fields": [16, 10, 0, 4, 5, 11, 12, 7, 15, 17, 9, 25, 3], "formats": [ "string", "datetime", "leftzeropaddedstring13", "2dp", "2dp", "2dp", "2dp", "int", "int", "string", "int", "int", "int", "int" ] }, { "name": "default fields 2", "fields": [3, 25, 9, 17, 15, 7, 12, 11, 5, 4, 0, 10, 16], "formats": [ "int", "int", "int", "int", "string", "int", "int", "2dp", "2dp", "2dp", "2dp", "leftzeropaddedstring13", "datetime", ...

php - Group by 'column name' doesn't seem to work -

i trying fetch category name has been saved multiple times before. fetch name need group name doesn't display multiple times, tried doing in way mentioned before , have failed far. i'm sure doing horribly wrong here , not able find why not able group it. appreciated. thanks. $valsubcat=mysqli_query($conn,"select categoryid subcategorymaster subcatid=$valitem1[0]"); while($valsubcat1=mysqli_fetch_array($valsubcat)) { $valcat=mysqli_query($conn,"select categoryname categorymaster categoryid=$valsubcat1[0] group categoryname"); while($valcat1=mysqli_fetch_array($valcat)) { echo "<tr><td>".$valcat1[0]."</td></tr>"; } } you can reduce 1 query using join $sql = "select distinct scm.categoryid, cm.categoryname...

mysql - Compatibility issue between H2 DB queries and Sql Server -

i'm developing application uses h2 db . queries in h2 supported grammar not supported sql server , vice versa . there way make application work common query structure supports both h2 , sql server ? here queries .. 1st query sql server syntax - select columns table_1 table_2 conditions h2 db equivalent create table table_1 select columns table_2 conditions *the above h2 query wasnt supported sql server 2nd query sql server syntax update set columns table_1 join table_2 b on keys conditions insert table_1(columns) select columns table_2 conditions h2 db equivalent 1st part update table_1 set column=(select column table_2 b conditions) 2nd part insert table_1(columns) select columns table_2 conditions yes, rewrite queries. the proper way create target table , say: insert table2 select ... table1

asp.net mvc - MVC Controller return RedirectToAction Id + #id -

hello im trying redirect user blog section , works fine want user land on bottom of site section ( #section-variants ) cant figure out im doing wrong there other way of passing along public actionresult blogcomment_delete(int? id, int? postid) { if (id.hasvalue) { notification model = db.notifications.find(id.value); if (model != null) { db.notifications.remove(model); db.savechanges(); } } return redirecttoaction("blogpost", "blog", new { id = postid + "#section-variants" }); } you should use method - redirectresult : return new redirectresult(url.action("blogpost", "blog", new { id = postid }) + "#section-variants");

java - Spring boot creating configuration files when it should not -

i have excluded db related autoconfiguration in spring boot application. still trying create jdbctemplateconfiguration , failing not not finding datasources. @enableautoconfiguration(exclude = {datasourceautoconfiguration.class, jmsautoconfiguration.class, mongoautoconfiguration.class, mongodataautoconfiguration.class, datasourcetransactionmanagerautoconfiguration.class, hibernatejpaautoconfiguration.class}) stacktrace error - org.springframework.beans.factory.beancreationexception: error creating bean name 'jdbctemplate' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/datasourceautoconfiguration$jdbctemplateconfiguration.class]: bean instantiation via factory method failed; nested exception org.springframework.beans.beaninstantiationexception: failed instantiate [org.springframework.jdbc.core.jdbctemplate]: factory method 'jdbctemplate' threw exception; nested exception java.lang.illegalargumentexception: property 'datasource...

java - Customising Default Navigation Drawer Activity Vector Icons -

Image
i'm trying customise , colourise default navigation drawer activity on android studio 2.1.2. i've changed color of ic_menu_camera.xml file in following way-- <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportheight="24.0" android:viewportwidth="24.0"> <path android:fillcolor="#f73a3a" //changed colour android:pathdata="m12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0" /> <path android:fillcolor="#f73a3a" //changed colour android:pathdata="m9,2l7.17,4h4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2v6c0,-1.1 -0.9,-2 -2,-2h-3.17l15,2h9zm3,15c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z" /> </vector> the colour changes in preview window per screenshot below- however, colour changed again defa...

Drupal 8 - LDAP / Active Directory working? -

i'm new drupal , installed 8.1.2 , ldap module. i've been trying 2 days connect our local active directory. however, every time tried run server test got error: " failed bind server. ldap error #49 invalid credentials ". i'm sure settings correct , credentials (i tested direct in active directory , in php). tried online ldap connection , failed same error too. thought maybe it's test doesn't work tried logging in known ad account didn't work. final test installed drupal 7 (and modules that) instead , same settings worked first time (tests ran expected , logged in ad account). i know ldap module 8 in development mode seems imply working. has got working though? please can let me know whether overlooking simple settings in 8 or if bug. don't want use drupal 7, need our users able log in using network details.

c# - Change slider bar color -

Image
it should easy haven't fount information need. want simple changing color of slider bar: i'm using modernui , default bar color similar background , want make bit lighter. i found 2 approaches: you can customize slider insert corresponding brushes in appropriate slider.resources section. you can add brushes separate xaml file dictionary , merge corresponding slider in slider.resources . in cases fits better because can change colors of few controls @ once. any not need changing of control's template. both approaches presented below: page1.xaml <grid style="{staticresource contentroot}"> <stackpanel> <!-- slider default theme , colors modernui --> <slider/> <!-- slider custom colors approach 1 --> <slider> <slider.resources> <solidcolorbrush x:key="sliderselectionbackground" color="green" /> ...

html - PHP form validation (creating a dynamic link) -

stuck on part of lab, asking create dynamic link 'uncheck' values database. how go doing this? reads following: "revise last program there dynamic link @ end of each record says, "cancel". when clicked, should "uncheck" both monday , tuesday (that is, change values store in db represent "unchecked" both monday , tuesday" (how represent variable?) i receiving undefined variable warnings when page loads. appreciated in pointing me in right direction. thank you! my code .php file: <?php if ($_post){ $checkerr = $firsterr = $lasterr = $orgerr = $emailerr = $phoneerr = ""; $title=$_post['title']; $firstname=$_post['firstname']; $lname=$_post['lastname']; $organization=$_post['organization']; $email=$_post['email']; $phone=$_post['phone']; $monday=$_post['monday']; $tuesday=$_post['tuesday']; $size = $_post['t-shirt']; if (empty($_post["...

How to parse JSON in Android -

where can find step-by-step instructions on how parse json feed in android? i'm android beginner wanting learn. android has tools need parse json built-in. example follows, no need gson or that. get json: defaulthttpclient httpclient = new defaulthttpclient(new basichttpparams()); httppost httppost = new httppost(http://somejsonurl/jsonwebservice); // depends on web service httppost.setheader("content-type", "application/json"); inputstream inputstream = null; string result = null; try { httpresponse response = httpclient.execute(httppost); httpentity entity = response.getentity(); inputstream = entity.getcontent(); // json utf-8 default bufferedreader reader = new bufferedreader(new inputstreamreader(inputstream, "utf-8"), 8); stringbuilder sb = new stringbuilder(); string line = null; while ((line = reader.readline()) != null) { sb.append(line + "\n"); } re...

javascript - open window and run function on that window -

i'd open new window, window has list of objects, , these objects should filtered based on selection previous window. figured can filter list through function, how run said function? this able do: var popup = window.open('pageurl'); $(popup.document).ready(function() { // function should popup.alert('helloworld'); }); but how change alert function? if have function on other app , function test() { alert('helloworld'}; how run function first app? swapping popup.alert('helloworld'); popup.test(); did not work. you need reference window opened call functions in new window, like: var onewwindow = window.open("new.window.url", "mywindow"); onewwindow.onload = function(){onewwindow.window.newwindowfunction();};

java - Spark Dynamic Allocation in Standalone Cluster Failing My Application -

i running spark 1.5.2 build on scala 2.11 on windows 7 cluster on standalone mode , two spark applications cores allocated both application . dynamic allocation enabled configuration when run 2 instances of application none of application completes. here application - package com.cleartrail.clearinsight.spark; import java.util.arrays; import java.util.list; import org.apache.spark.sparkconf; import org.apache.spark.sparkcontext; import org.apache.spark.api.java.javapairrdd; import org.apache.spark.api.java.javardd; import org.apache.spark.api.java.javasparkcontext; public class main { public static void main(string[] args) { sparkconf conf = new sparkconf().setappname("sparkpoc").setmaster("spark://172.50.33.159:7077").set("spark.dynamicallocation.enabled", "true") .set("spark.shuffle.service.enabled", "true").set("spark.dynamicallocation.executoridletimeout", "...

Sessions don't work in PHP -

this test script: <?php ob_start(); // or without same $session = session_start(); $path = session_save_path(); if (headers_sent()) die ("headers have been sent"); if((isset($_get["set"]))) { $_session["var"] = " - testing - "; } echo $_session["var"]; echo $session; echo $path; print_r($_session); print_r($_cookie); setcookie("cookie", "value"); $session outputs 1 . cookies being set successfully. have phpsessid cookie set. sessions (from phpinfo) enabled. session_start() there. when set session variable (by setting set parameter), session variable echoes directly $_session array. when remove set parameter, print_r-ing $_session outputs empty array. i've gone far set chmod 777 on /var/lib/php5 , , chown -ed same user runs php. tried different domain name, defining in local /etc/hosts , setting new virtual host it. i found 1 answer on stackoverflow said disable register_globals in ...

java - JPA query not returning expected result set -

in project i'm working have ejb persistence unit multiple entitys have update entities complex id (2 fields forming id) , change query not behave in way expect. have entity correspond intermediate table relationship many 1 one of entities changed. publicic class bapeconvcatezonas implements serializable { private static final long serialversionuid = 1l; @size(max = 1) @column(name = "b_interinidad") private string binterinidad; @size(max = 1) @column(name = "b_sustit_larga") private string bsustitlarga; @size(max = 1) @column(name = "b_sustit_corta") private string bsustitcorta; @id @basic(optional = false) @notnull @column(name = "c_codigo") private long ccodigo; @joincolumns({ @joincolumn(name = "c_cod_gsa", referencedcolumnname = "c_cod_gsa", updatable=false,insertable=false), @joincolumn(name = "c_cod_centro", referencedcolumnname = "c_codigo", updatable=false,insertable=false)}) @ma...

javascript - How to make a certain DIV first child and anything before it append to the end -

fiddle: https://jsfiddle.net/xkdm52gs/3/ jquery: $(function() { var vhtml = ""; var u5 = new array(); var $divs = $(".chold"); var alphabeticallyordereddivs = $divs.sort(function (a, b) { return $(a).find("span").text() > $(b).find("span").text(); }); $(".dcon").html(alphabeticallyordereddivs); $("#arrow-left").click(function() { //alert("left"); $(".dcon div:first-child").appendto(".dcon"); $(".dcon").remove(".dcon div:first-child"); }); $("#arrow-right").click(function() { //alert("right"); $(".dcon div:last-child").prependto(".dcon"); $(".dcon").remove(".dcon div:last-child"); }); $(".chold").each(function() { var k = $(this).text().trim(); console.log(k.charat(0)); u5.push(k.charat(0)); }); console.log(unique(u5).length); u5...

excel - How can I give the "Font Color" button in the HOME ribbon a keyborad shortcut? -

what want keyboard shortcut, can use change color of selected characters in cell. i have got code snippets recorded macro: with activecell.characters(start:=3, length:=2).font .color = -16776961 end now don't know how start , length activecell.characters . , because want change of characters in cell, selected mouse, arbitrarily, required, need can't pass start , length parameter activecell.characters . i got stuck @ place, don't know how go on. or, there way set keyboard shortcut font color button? or, there way achieve function want? ps: it's not difficult function want, think. i want map ctrl-q function change color (simply toggle black , red selected characters) , default ctrl-5 can apply or remove strikethrough selected characters. more precisely, wrote everyday's progress in given excel book. teacher check content , grammar me. has switch between mouse , keyboard, want map keyboard shortcut (of course i'm trying ...

Django - Calling .object on a SearchQuerySet() returns None -

i've hit dead end django 1.9.5 project. im running haystack 2.4.1 , whoosh 2.7.4 search-engine. here poblem: when accessing followng view: def search_titles(request): resources = searchqueryset().autocomplete(content_auto=request.post.get('search_text', '')) return render_to_response('ajax_search.html', {'resources' : resources}) with ajax_search.html looking follows: {% if resources.count > 0 %} {% resource in resources %} <li>{{resource.object.title}} _ {{resource.object}}</li> {% endfor %} {% else %} <li>none show</li> {% endif %} the search works fine. depending on search exact amount of results should getting, @ line <li>{{resource.object.title}} _ {{resource.object}}</li> they show as _ none (.object.title being blank , .object being none). in case helps, here search_indexes.py: class resourceindex(indexes.searchindex, indexes.indexable): text = indexes.charfield...

How do I implement bootstrap dropdown in rails with categories -

i'm wanting implement bootstrap's dropdowns in rails project similar code below provided on bootstrap's website: <div class="dropdown"> <button class="btn btn-default dropdown-toggle" type="button" id="dropdownmenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> dropdown <span class="caret"></span> </button> <ul class="dropdown-menu" aria-labelledby="dropdownmenu1"> <li><a href="#">action</a></li> <li><a href="#">another action</a></li> <li><a href="#">something else here</a></li> <li role="separator" class="divider"></li> <li><a href="#">separated link</a></li> </ul> </div> i have section in project can ...

css - How to make an image responsive on PS4? -

i on console viewing site working on , noticed banners looked off. <div class="blog-post-featured-banner"> <img width="1600" height="900" src="#"> </div> .blog-post-featured-banner { height: 50vh; overflow: hidden; display: -webkit-flex; display: -ms-flexbox; display: flex; justify-content: center; align-items: center; position: relative; } .blog-post-featured-banner img { width: 100%; height: auto; } it looks fine on desktop, when view on ps4 looks img had height:100%; , looked squished. expected behave way on desktop, takes 100% width of screen , height hidden in overflow. given i'm viewing on tv expected bit pixelated. needing large image? tv 55". sort of side question, in div holds image, trying make image vertically , horizontally centered in "frame", how adjust css so, if possible. the browser playstation use might not support viewport u...

How to add search box with icon in custom wordpress theme without plugins -

i new wordpress . have developed theme in wordpress in header.php want add search box navigation bar . have tried alot not able add search box icon in header.php of developed custom theme of wordpress. please me solve issue. try download font-awesome fonts , stylesheet here , use class need specific icon :) you'll find more instructions on site. edit1 in header section try add get_search_form () 2.add following code searchform.php file (or create if don't have one) <form method="get" id="searchform" action="<?php bloginfo('home'); ?>/"> <div> <input type="text" size="18" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" /> <input type="submit" id="searchsubmit" value="search" class="btn" /> </div> </form>

Django query set filter over relationship with concat -

i filter users based on concat(first_name, last_name) accessible on userprofile. if user.profile.first_name + ' ' + user.profile.last_name query all have user.objects.all() i tried stuff extra(), complexquery,annotation() none of them working... any ideas how it? here go: from django.contrib.auth.models import user django.db.models import value, func, f, charfield user.objects.annotate(full_name=func(f('first_name'), value(' '), f('last_name'), function='concat', output_field=charfield())).filter(full_name__icontains='dusan plavak') update #1: user.objects.annotate(full_name=func(f('profile__first_name'), value(' '), f('profile__last_name'), function='concat', output_field=charfield())).filter(full_name__icontains='dusan plavak')

list - Reduce indentation when using Python nested loops -

this question has answer here: how can make for-loop pyramid more concise in python? [duplicate] 4 answers is there way reduce indentation when using nested loops, per below? for source_i in sources: source_j in sources: ni in source_i.nodes: nj in source_j.nodes: if ni != nj: do_thing(ni, nj) for source_i in sources: source_j in sources: pass this same thing iterating through pairs in cartesian product of sources , itself. can written in 1 line importing itertools : import itertools (i,j) in itertools.product(sources, repeat=2): pass same pattern here: for ni in i.nodes: nj in j.nodes: pass this can rewritten as: for (ni, nj) in itertools.product(i.nodes, j.nodes): pass so can nest them: import itertools (i,j) in itertools.product(sources, repeat=2...

android gradle copy task not work -

i have project structure as: -main project --subject a in subject build.gradle add copy task task makedebugjar(type: copy) { def dist = new file("livenesslib/build/outputs","jars") if (!dist.exists()) { dist.mkdir() } println "++++++debug mylib task invoke ++++++: " def sourcedir = new file("build/intermediates/bundles/debug/") if (sourcedir.exists()) { from(sourcedir) { include('classes.jar') } into(dist) println "++++++copy doaane ++++++: " rename('classes.jar', 'zaliveness-debug.jar') println "++++++rename done ++++++: " } } makedebugjar.dependson build then build main project ,the log show every step invoke,and dir jars created,but no jar in dir . anyone can me resolve problem ? much task copyfiles(type: copy) copyfiles { description = 'copies html5 files common library...' '../.....

json - Deploying a Rails API on either Heroku/AWS Elastic Beanstalk -

i'm trying pair mobile client rest api json data can display in app. i'm following apis on rails abraham kuri vargas. in api have created subdomain versioning, controller files in app/controllers/api/v1. api returns desired json data when run locally. problem i'm facing whenever deploy api onto heroku/aws show "application not found". remote server isn't finding way app/controllers/api/v1? there fix problem because in book author has written "due structure of application not going deploy app server". i'm stuck on problem long time , love suggestions! app/controllers/api/v1/users_controller.rb class api::v1::userscontroller < applicationcontroller respond_to :json def show respond_with user.find(params[:id]) end def create user = user.new(user_params) if user.save render json: user, status: 201, location: [ :api,user ] else render json: { errors: user.errors }, status: 422 ...

javascript - How to turn Cheerio DOM nodes back into html? -

using html below, i'm attempting extract html of each paragraph. cannot find way turn nodes html or query objects. the below string var html = ... <article> <p> p1 </p> <p> p2 </p> </article> the html loaded such var $ = require('cheerio').load(html) var paragraphs = $('p').toarray().map(p => /* want html @ point */ ) how html of these paragraphs? note: clarity i'm calling return value of cheerio.load "query object" , return of toarray method dom nodes; lack of better phrase. you can use $.html : var paragraphs = $('p').toarray().map(p => { console.log($.html(p)); return $.html(p); }); the documentation shows example using selector, cheerio dom elements work expected: if want return outerhtml can use $.html(selector): $.html('.pear') //=> <li class="pear">pear</li>

Excel - Pivot Table - Formula Sum a cell only if other cell fulfill an specific value -

Image
i trying create pivot table on excel formulas. 1 of them should sum(montant emission) if off/online = 'offline' for example if group code agent , want sum(montant emission) if 'off/online' = 'offline' in case sum code agent = cho should 0 , code agent = jgr should 137.5 i need create formula calculation. formula should use on "calculated field" use =sumif(i:i,"offline",e:e) assuming off/online column, e column value want sum up. you can make "offline" dynamic , refer cell.

php - Check for first post using wp_query -

i new wordpress. inside loop want check if post first result query. this code. <?php $args = array('post_type' => 'home-slider', 'posts_per_page' => 6, 'order' => 'asc'); $query = new wp_query( $args ); while ($query->have_posts()) : $query->the_post(); ?> <?php if ( ) { ?> // check if first post <p>test</p> <?php } else { ?> <p>test123</p> <?php } ?> <?php endwhile; ?> thanks in advance. instead of doing check inside loop, move outside , query first post after if() statement: <?php $args = array('post_type' => 'home-slider', 'posts_per_page' => 6, 'order' => 'asc'); $query = new wp_query( $args ); ?> <?php if ($query->have_posts()) : $query->the_post(); ?> <p>test</p> <?php endif; while ($query->have_posts()) : $query->t...

fluentd - fluent-plugin-grep: grep A or B than -

we using fluent-plugin-grep: how filter looks like <filter **> @type grep regexp1 level error </filter> how have change filter when want filter on level error or fatal? (so not error)? you can use or pattern in regeular expression. try following configuration. <filter test.**> @type grep regexp1 level (error|fatal) </filter>

go - Looping over a map using range, only iterate once -

i need iterate on loop once in golang template, looping on keys want stop after single iteration. how can this? {{range .users}} <div> {{.name}} </div> {{end}} two solutions; either check index 0 when looping: {{range $index, $element := . }}{{if eq $index 0 -}} item: {{$element}} {{end}}{{end -}} or define "first" function takes slice , truncates length 1. {{range first .}} item: {{.}} {{end}} here's complete code demonstrates both, can try on playground. package main import ( "fmt" "os" "text/template" ) var t = template.must(template.new("x").parse( "[{{range $index, $element := . }}{{if eq $index 0 -}}{{$element}}{{end}}{{end -}}]")) var funcs = map[string]interface{}{ "first": func(arg []string) []string { if len(arg) > 0 { return arg[:1] } return nil }, } var t2 = template.must(template.new("x...

angular - RouterLink don't adds href at first load from parent page template -

i have root page child pages, root page template has [routerlink] directives route child pages. this: <a [routerlink]="['/home', 'auidiences']"></a> <router-outlet></router-outlet> homecomponуnt has router_directives in directives section.* when navigate page @ first time links don't have hrefs, if update page , work. idias? the reason understand related this bug . , 1 more - user answer . oninit doesn't fire , there no component works fine after router navigation. to solve problem need wrap navigation call zone.run() .

algorithm - Alpha-Beta search truncating my principal variation -

i have implemented alpha-beta search adds results transposition table. then, extracting principal variation transposition table. this appears work alright analysis @ shallow depths. however, when ask analysis @ depth of 7 plies, this: 7 [+1.00] 1.b1c3 a7a6 2.g1f3 a6a5 3.a6a5 at end, move repeated. final move placed in table result of pruning, not legal move white. obviously, there less 7 plies printed. is misunderstanding in alpha-beta search code? int ab_max(board *b, int alpha, int beta, int ply) { if (ply == 0) return evaluate(b); int num_children; move chosen_move = no_move; move *moves = board_moves(b, &num_children); assert(num_children > 0); (int = 0; < num_children; i++) { apply(b, moves[i]); int score = ab_min(b, alpha, beta, ply - 1); if (score >= beta) { tt_put(b, (evaluation){moves[i], score, at_least, ply}); unapply(b, moves[i]); free(moves); return b...