Posts

c - Why is the parent process not executing at all? -

following program shared memory implementation parent , child processes use shared memory printing next alphabet given parent. there shared memory , both processes attaching obtain required result. in code, parent process not execute @ all. #include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<string.h> #include<sys/ipc.h> #include<sys/shm.h> #include<sys/types.h> int main(int argc,char *argv[]) { int smid; pid_t x; char *sm; smid=shmget(ipc_private,(size_t)sizeof(char),ipc_creat); x=fork(); if(x>0) { sm=(char *)shmat(smid,null,0); sprintf(sm,"%s",argv[1]); printf("parent wrote:\n"); puts(sm); sleep(4); printf("parent got:\n"); puts(sm); shmdt(sm); shmctl(smid,ipc_rmid,null); } else if(x==0) { sleep(2); sm=(char *)shmat(smid,null,0); printf("child read:\n"); puts(sm); sm[0]++; } retur...

lisp - Clojure: iterate over map of sets -

this pretty follow-up last question ( clojure idiomatic way update multiple values of map ), not quite same. (keep in mind i'm new clojure , functional languages alike) suppose have following data structure, defined map of sets: (def m1 {:1 #{2} :2 #{1 3} :3 #{1}}) and map of maps such: (def m2 {:1 {:1 0 :2 12 :3 23} :2 {:1 23 :2 0 :3 4} :3 {:1 2 :2 4 :3 0}}) what want update registries of m2 have correspondence in m1 value. let's value want x . resulting m2 this: {:1 {:1 0 :2 x :3 23} :2 {:1 x :2 0 :3 x} :3 {:1 x :2 4 :3 0}} assuming v contains every possible key map, y first attempt, (that failed miserably) this: (assume x=1 (for [i v] reduce (fn [m j] (assoc-in m [i j] 1)) d (i m1))) needless failure. so, how idiomatic way this? as understand requirements want to produce number of key-sequences m1 . in m2 associate each of key-sequences particular constant value. the first step simple transformation of m1 . want produce 0 or more ke...

validation - Javascript to validate only Numeric after predefined text in a textbox -

i'm trying use javascript make textbox contains read-only text @ beginning of text box , allows editing following read-only text. need allow 10 digit numeric after readonly text , need validate numeric digits. following javascript code having readonly in textbox var readonlylength = $('#field').val().length; $('#output').text(readonlylength);enter code here $('#field').on('keypress, keydown', function(event) { var $field = $(this); $('#output').text(event.which + '-' + this.selectionstart); if ((event.which != 37 && (event.which != 39)) && ((this.selectionstart < readonlylength) || ((this.selectionstart == readonlylength) && (event.which == 8)))) { return false; } }); if looking solution script here plain js , regexp : var fixedtext = function(textbox, label) { var num = textbox.value.replace(/\d/g, ''); //non numeric num = num.substr(0, 10); //max 10 di...

php - Limit custom taxonomy dropdown by custom post type -

i have 2 custom post types connected same custom taxonomy. on particular page needed filter 1 particular post type using filter created custom taxonomy. able dropdown of custom taxonomy using <?php wp_dropdown_categories( $args ); ?> noticed listed terms atleast 1 of 2 custom post types had post linked it. here's example of i'm trying do: 1. have 2 custom post types: cars , bikes 2. have custom taxonomy (location) 3. on specific page, need filter post type cars using dropdown created taxonomy 4. problem i'm facing dropdown taxonomy location, lists locations posts bikes post type connected to. example, if have posts cars post type connected usa, uk, australia , post bikes post type connected brazil, dropdown custom taxonomy lists 'brazil' term though none of cars posts linked it. is possible restrict dropdown taxonomies 1 custom post type? i asked same question on wordpress stackexchange site , got answer. linking in case else interested i...

sql server - Sql JOIN Performance on Big tables -

Image
i have query following line. select /**/ #customers fia inner join [fia_cmmn_fin_account] fca with(nolock) on (fca.report_oid=fia.oid , fca.status='1') inner join [fia_cmmn_rpt_parameter] pr with(nolock) on (pr.report_oid =fia.oid , pr.status='1') (fca.original_1+fca.original_2+fca.original_3+fca.original_4)!= 0 second table "pr" has 28.000.000 rows , query progressing 2 minutes. how can optimize query.

javascript - Remove checked property through jquery .model value not updated in knockout js -

i used jquery remove checked property of checkbox.the ui value updated.however, model value not updated. same old value there in model. if manually check unchecked checkbox model value updated. have scenario 1 checkbox click other checkbox should unchecked.the required functionality done through below code. need updated value in model. answerclick: function (data, event) { var element = event.target; $(element).parents('.primarycasemain').find("div#" + valuetohide).find('input[type=checkbox]:checked').removeattr('checked'); } here html code <input type="checkbox" data-bind="attr:{id: $data.id , qid: $parent.id , qref: $data.questionrefsetstrings , uid: $data.uid , rel: $data.mutuallyexclusive ? 'true' : 'false'} ,checked: $data.selected, click: $root.answerclick , if: $root.appendqrefquestion($data.questionrefsetstrings, $data.noappendrequiredqref)"> you should use knockout implemented ...

java - JOptionPane: texts message and buttons in the same line -

as title says want achieve pop option message using joptionpane such question , buttons placed on same line. i'm reading following tutorials seems quite difficult: how make dialogs how make dialogs java the definitive guide java swing in sense idea have following confirmation message layout: the products going removed database. are sure want perform it? |yes| |no| where yes , no should buttons. (the text not real one, it's give flavor of message). any comments or hints welcomed. thanks lot in advance. try this joptionpane.showconfirmdialog(null, getcustompanel(), // return panel design on own "joptionpane example : ", joptionpane.ok_cancel_option, joptionpane.plain_message); //and custom panel private jpanel getcustompanel() { jpanel panel = new jpanel(); jlabel label = new jlabel("text message:"); ...