Posts

go - Golang close net listener -

i having trouble closing listener can reopen on same port. writing proxy server hot-configurable - i.e (redirects/blocks etc) can adjusted on fly. proxy runs in go routine. problem having when reconfigure listener , proxy listener still using port previous configuration. (fyi listener global pointer) i'm trying like: to kill listener: func killproxy() { if listener != nil { log.println(" *** trying stop proxy server") (*listener).close() listener = nil } } before reconfiguring like: log.println("listener (s1): ", listener) if listener == nil { // start listener listen on connection. l, err := net.listen(conn_type, conn_host + ":" + conn_port) if err != nil { log.println("error here: ", err) } listener = &l //set pointer newly created listener } log.println("listener (s2): ", listener) however doesnt seem work - error: listener (s1): err...

ios - CloudKit compound query (query with OR) -

i query cloudkit using or 2 fields. can't find way how this. did is: nspredicate *predicate1 = [nspredicate predicatewithformat:@"(creatoruserrecordid == %@)", userid]; nspredicate *predicate2 = [nspredicate predicatewithformat:@"(touser == %@)", userid]; nscompoundpredicate *comppredicate = [nscompoundpredicate orpredicatewithsubpredicates:@[predicate1, predicate2]]; ckquery *query = [[ckquery alloc] initwithrecordtype:@"message" predicate:comppredicate]; but unfortunately ckquery not support or query (as written in documentation) can achieve effect other way? ckquery supports , and not, imagine use simple boolean algebra create query based on fact not(not , not b) == or b. however, documentation says: "the not compound operator not supported in following cases: you cannot use negate , compound predicate." so must query each of ored predicates separately save them each set , take intersection of 2 sets final result ...

c++ - Implicit this parameter in GDB -

i'm using clion. how see value of this parameter in gdb? isn't in "variables" section now. i've tried print using "evaluate expression", didn't me, printed {void (my_class * const)} 0x7fff5fbff298 . also, can explain why happening? well, technically, this pointer object owns it, should regular pointer address points class. it's nothing special. now, once dereference pointer, referring actual object. should try referencing *this when want print out actual object.

Ruby on rails find an associated objects which has another association too -

i have 3 models, organized way: class task < ar::base has_one :taskable class taskable belongs_to :task has_many :supplies class supply < ar::base belongs_to :taskable how can fetch tasks, taskable has @ least 1 supply? you need join query . # fetch tasks, taskable has @ least 1 supply task.joins(taskable: :supplies)

Use data-* attribute in grails g.link generated in tagLib -

is there way use data- attributes in g.link generated taglib? want store dom info instead of using params in g.link results in query parameters. example: out << g.link(controller: "calendar", action: "info", params: [id: cal_id], data-info: "abc") { "click me " } unfortunately works when using normal g.link syntax view: <g:link controller="calendar" action="info" id="${cal_id}" data-info="abc">click me</g:link> just put quotes around data attributes : out << g.link(controller: "calendar", action: "info", params: [id: cal_id], "data-info": "abc") { "click me " }

php - Custom wordpress function not showing the right number of posts -

i have custom wordpress function shows number of featured recipes. function works fine when showposts=-1 in query. when put 'showposts=5' 2 of posts shown. below function function pika_featured_recipes_shortcode() { ob_start(); echo '<div class="featured-box-heading"> featured recipes </div>'; echo '<div class="featured-box">'; $temp = $wp_query; $wp_query = null; $wp_query = new wp_query(); $wp_query->query('showposts=5&post_type=cp_recipe&order=desc&orderby=date' . '&paged=' . $paged); while ($wp_query->have_posts()): $wp_query->the_post(); $entry_id = get_the_id(); $entry_link = get_permalink($entry_id); $entry_image = get_post_thumbnail_id($entry_id); $entry_title = get_the_title($entry_id); $entry_description = get_post_meta($entry_id, '_cp_recipe_short_description', true); $entry_excerpt = get_post...

php - display validation error message next to the textbox in codeigniter -

Image
i'm newbie codeigniter.i want display error message next text box.my view file create.php contains following code. <?php echo validation_errors(); //validation echo form_open('news/create'); //create form ?> <div class="boxes"> <div class="common"> <div class="lables"> <label for="name">name</label> </div> <div class="text_boxes"> <input type="text" name="uname" /><div id="infomessage"><?php echo $message;?></br> </div> </div>` and below controller model: public function create() { $this->load->helper('form'); $this->load->library('form_validation'); $data['title'] = 'insert items'; $this->form_validation->set_rules('uname','required|min_length[6]|m...