Posts

Showing posts from March, 2012

Highlight each query keyword in different color solr -

i want highlight each query keyword in solr response different color. example query= 'first , second'. want results like: query results: first random text , second //response end background of 'first' should color 1 , of 'second' should color 2. i have tried using hl.fragmentsbuilder unable results highlight. in lucene , fastvectorhighlighter class suport mutil color tag , don't know how implements in solr ,but it's can in lucene : fragmentsbuilder fragmentsbuilder= new scoreorderfragmentsbuilder(basefragmentsbuilder.colored_pre_tags,basefragmentsbuilder.colored_post_tags); fastvectorhighlighter fasthighlighter2=new fastvectorhighlighter(true, true, fraglistbuilder, fragmentsbuilder); maybe useful !

ios - Dynamically Calculate Pace in Swift -

Image
i have code below. how dynamically calculate pace fill in fields instead of having calculate manually tapping on calculate pace button? import uikit class viewcontroller: uiviewcontroller { @iboutlet weak var mintextfield: uitextfield! @iboutlet weak var sectextfield: uitextfield! @iboutlet weak var disttextfield: uitextfield! @iboutlet weak var pacelabel: uilabel! func paceinseconds (minutes:double, seconds: double, distance: double) -> double { return ((minutes*60) + seconds) / distance } @ibaction func pacecalculator(sender: uibutton) { var paceminutes = paceinseconds(((mintextfield.text nsstring).doublevalue, seconds: (sectextfield.text nsstring).doublevalue, distance: (disttextfield.text nsstring).doublevalue)) / 60 var roundedpaceminutes = double(floor(paceminutes)) var decimalpaceseconds = paceminutes - roundedpaceminutes var intpaceminutes = int(floor(roundedpaceminutes)) var paceseconds

What Qualifies as Global Constants in Python -

i trying become familiar proper terminology. what data structures can global constants? have immutable data structures? for example, know global constant: this_constant = 5 but, example, can list constant? provided doesn't change throughout program, though mutable data type? list_constant = [1, 2, 3, 4] another way of asking question is, proper use mutable datatypes global constants? from experience (no sources): yes. long don't change value throughout program, it's allowed global constant. code style message , other programmers saying variable's value never change. edit : as @nightshadequeen noted, using tuple better, because immutable. not (accidentally) change constant's value.

Java Selenium find all links from website? -

i have function checks empty href links on single page. how can edit function go through every link on every page of site? list<webelement> links = driver.findelements(by.tagname("a")); pseudo code (since not know how page formatted) while(links.hasnext()) { function here; } that how people go parsing entire document, , since page lines of code, can parse it. or, if using selenium, coming appium perspective, can try create table contains pointer hrefs, make rows variable populated them driver.findbyclass; , run or while loop.

java - How to restrict a user from selecting more than 10 items from a CheckBox ListView in Android -

i've searched on , cant find solution works situation. have custom checkbox adapter extending arrayadapter holds 'food' objects ('food' contains 2 attributes 1. boolean:selected , 2. string:name). when listview loads have 10 items selected default. need allow user unselect/select options limit them 10 choices. import android.content.context; import android.util.log; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.arrayadapter; import android.widget.checkbox; import android.widget.compoundbutton; import android.widget.textview; import android.widget.toast; import java.util.arraylist; public class checkboxadapter extends arrayadapter<food> { context context; arraylist<food> foodlist; int counter = 0; private static class viewholder { textview txtview; checkbox chkbox; public viewholder(view view) { txtview = (textview) view.fi

Grails error initializing application: null -

when try run "grails run-app", error , small stacktrace: context.grailscontextloaderlistener error initializing application: null java.lang.nullpointerexception @ java.util.concurrent.futuretask.run(futuretask.java:266) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor. java:1142) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor .java:617) @ java.lang.thread.run(thread.java:745) i'm using grails 2.5.0 , java 1.8.0_51. how can more information what's going wrong? edit: i've tried grails clean , grails refresh-dependencies in related projects. our app consists of 2 projects. project 1 has bootstrap files , project 2 domain/view/controller files. branch on project 1 had bootstrap file used domain object on different branch of project 2, commented out bootstrap file. turns out, causing error. fix it, had delete bootstrap file app run. i guess grails doesn't when ther

java - DOM parsing an XML file - "Invalid byte 1 of 1-byte UTF-8 sequence." -

i trying parse xml file in following way: system.out.println(path); file f = new file(path); try { document = builder.parse(f); } catch (saxexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } f path .xml file following header: <?xml version="1.0"?> as understand it, means has utf-8 encoding. error occurs if not have utf-8 encoding. doing wrong?

winforms - Circular Progress Bar in Windows Forms -

i developing windows forms application , need use circular progress bar. did research , found circular progress bar package did not work, knows how use it, or other way of creating circular progress bar? if not want use external libraries, can use animated gif in picture box. progress can shown simple label in center. sure not prettiest, job well, , it's win8 style.

Dynamic Hibernate Mapping Issue -

i have created application using struts2 , hibernate perform other operations. change requirement has come user should able control database schema ui means user should have ability add new columns on fly through user interface. i not sure how can achieve updating database still leave entity class untouched. to illustrate issue consider situation: have employee table 2 columns : name , roll number. create entity class class student{ int id; string name; getters , setters } using entity class can perform crud operations in database. now do if need have new column "age" , and "age" should created inside database. , new column has added dynamically user interface. is there way update entity on fly or there other way achieve it. first of all, cannot on fly, need replace classes on application server. you need add property entity, update daos , actions use new property. the dynamic appearance of form field, has nothing hibernate

eclipse - Is it possible to Pull, Commit, and Push all in one workflow in EGit? -

is possible pull before commit, , push commit remote branch in 1 workflow, instead of going to: team > pull team > commit... commit , push or team > commit team > pull team > push upstream ? if have changes in local want push upstream better add files index commit, pull changes remote , push changes remote there chances when have uncommitted changes , make pull request, changes may lost.

java - ASyncTask with progressdialog and button -

i beginner , had test. did tasks, have problem - public class httptask extends asynctask<integer, string, string> {#### progressdialog dialog; context context; public httptask(activity activity) { //init progress dialog dialog = new progressdialog(context);**** dialog.setprogressstyle(progressdialog.style_horizontal); } protected void onpreexecute() { // show progress dialog dialog.setmessage("loading..."); dialog.setcancelable(false); } protected string doinbackground(integer... params) { //freeze system 5 seconds try { int seconds = params[0]*5;#### timeunit.seconds.sleep(seconds); } catch (interruptedexception e) { e.printstacktrace(); } return null; } @override protected void onpostexecute(final string success) { // if there progress dialog hide dialog.dismiss(); } } it crashes, when try compile (i showed problems * sign): 08-03 10:43:10.873 29441-2944

c# - Connect to sql database -

i'm trying retrieve data database datagridview i'm getting exception, the connectionstring property has not been initialized. using (conn = new sqlconnection(@"data source=(localdb)\v11.0;attachdbfilename=""c:\users\bob\documents\visual studio 2012\projects\login\login\student_marks.mdf"";integrated security=true")); { using (adap = new sqldataadapter("select * tbl_students_marks", conn)) { dataset das = new dataset(); adap.fill(das); datagridview1.datasource = ds.tables[0]; } } i see code , found placed ";" , end of first using statement initiating conn using (conn = new sqlconnection(@"data source=(localdb)\v11.0;attachdbfilename=""c:\users\bob\documents\visual studio 2012\projects\login\login\student_marks.mdf"";integrated security=true"))//; issue { using (adap = new sqldataadapter("select * tbl_students_marks",

Git/gitk shows me unknown/invalid sha1 id for a folder but not from its parent folder. -

i have following folder views/shared/base/ where have been developing parts of layout header.cshtml footer.cshtml mainnav.cshtml so @ point start creating 'base' folder initial commit files (in branch devivated master). initial commit goes our master because in earlier stage, no problem @ all. let's call commit, commit a . then, continue developing files , creating more, more commits them , taking them our master rest of team benefit of changes. @ least idea. let created commit b , c , d . but last week, our team should sync our master, mandatory. continue developing, , create commit e . didn't take e master yet, today sync branch (i'm use branch developed 'base') master have changes team , see if okay. but despite merge fast forward, see surprise folder 'base' seems stay on commit a , not e , recent commit. at first though really, bad merge on team. didn't find nothing that. comments , tree (i checked through gitk) didn'

How to restore all the data from redis? -

i wanted restore data save using redis bgsave command.it saves data default location /var/lib/redis/6379/dump.rdb .the data contains hashmaps,key-value pairs .how data redis dump.rdb file? using restore command not solving purpose! just restart server. on startup read dump. never has read dump during operation, there's no command it. restore can useful, it's per key command. meaning have parse dump yourself, extract key names , serialized values , call restore each key. also, implemented support migrating keys between 2 running servers. not use-case. restarting server easier, isn't it? :)

php - Problems with javascript function onchange -

Image
hello stackoverflow people, i've been coding sometime , got stuck script. because cant find out why im getting console error: typeerror: document.getelementbyid(...) null var nlang = document.getelementbyid('langselect').value; ive tried doing function onchange , ve tried this: document.getelementbyid('langselect').onchange = function() { but didnt worked too. wrong script, here javascript code: function waschanged(){ var nlang = document.getelementbyid('langselect').value; var currentuser = <?php echo json_encode($appui->user_id); ?>; }; and here php code: echo arrayselect($langlist, 'pref_name[locale]', 'onchange="waschanged()" class="text" size="1"', $userlang, true); if document.getelementbyid('langselect') returns null, there must not div id in dom.

ios - GMSMarker Clustering -

does have working example marker clustering google maps on ios? tried find in on official docs google there nothing. have issue many markers on map make map slow , device stuck. i have reviewed "too many markers" article google, there no examples @ all. thanks help

Django 1.8 & Django Crispy Forms: Is there a simple, easy way of implementing a Date Picker? -

there awful lot of date/datetime picker implementations out there. there integrate django , crispy forms particularly well, , how used? i'm looking minimise development effort, maximise simplicity, , make use of django localisation. a django/crispy standard output date field: <input class="dateinput form-control" id="id_birth_date" name="birth_date" type="text" value="21/07/2015"> in model: birth_date = models.datefield(verbose_name='d.o.b', auto_now_add=false, auto_now=false) thanks! edit: profile model: from django.db import models class profile(models.model): birth_date = models.datefield(verbose_name='d.o.b', auto_now_add=false, auto_now=false) profile form: from django import forms profiles.models import profile class profileform(forms.modelform): class meta: model = profile birth_date = forms.datefield( widget=forms.textinput(

php - Odd issue with get_the_ID() -

Image
i have little php script uses get_the_id() , scrubs create button points category page on wp site. issue after couple months of working fine, mysterious colon has showed up. can seem find in wp documentation has changes , why colon being printed page. the code generating follows: <?php $simplecats= tribe_get_event_categories( get_the_id(), array( 'before' => '', 'sep' => '', 'after' => '', 'label' => '', 'label_before' => '', 'label_after' => '', 'wrap_before' => '<div class="avia-button-wrap avia-button-left eventcatbtn">', 'wrap_after' => '</div>' ) ); $simplecats= preg_replace("/events\/

java - Alligning an ArrayList of Strings into a (custom)Box won't get in proper position [solved] -

Image
i've got little problem alligning group of strings bottom of box in java. note: box class i'm using not default > javax.swing box! it's simple costum box x, y position, , width , height! what have? - message class can individually alligned allign class. - messagelist object containing arraylist of message objects can alligned allign class. - box object contains position , dimension of box. allign class uses box allign objects in. - allign class can allign different types of objects, , use box object allign in. how code should work: (code snippets further down page) the message object can use different font settings. allign class can allign these messages objects. message class contains method called obtainfontdimension() , gets bounds of object's string in preferred font settings. when want apply allignment message object, create box object contains x,y position , width , height. calling allign.applyallignment(params) ca

eclipse - EclipseFP for Haskell not working -

i've installed eclipsefp plugin can work haskell in eclipse. running eclipse on mac. have recent jre, found somewhere that may issue. plugin not in windows --> open perspective --> other should be. using eclipse luna. i relatively new , learn haskell

Drupal db_update not working, unless intentional error through batch API -

i'm submitting form view through drupal batch api update row in db. statement use is: db_update('scores') ->fields(['status' => 0]) ->condition('sid', $score->sid) ->execute(); the batch returns , gives me feedback of performed undo publishing on 1 item. however, row in db not updated. when using following code: $result = db_update('scores') ->fields(['status' => 0]) ->condition('sid', $score->sid) ->execute(); drq($result); the batch api returns error due unexpected output, , after refreshing page manually, row in question is updated! i can't life of me figure out what's going on nor how query batch api log somewhere can see what's going on. any appreciated. it seems there's 2 queries being executed. 1 db_update statement described earlier, , 1 entity.controller.inc::save() in entity module. latter started transaction negated

node.js - NodeJs: external javascript with dependencies -

we trying use nodejs minimal dependencies other packages, challenge encounter handelbarsjs. found package, assemble can generate html us. only, very slow, 3 seconds each time, of these 3 seconds, there 2,5 / 2,7 seconds of next line: var assemble = require('assemble'); our package.json script section: "scripts": { "build:handlebars": "node scripts/handlebars.js", "watch:handlebars": "nodemon --watch assets --exec \"npm run build:handlebars\"" } the script/handlebars.js file #! /usr/bin/env node var assemble = require('assemble'); var extname = require('gulp-extname'); console.log(date.now() - start); assemble.data('assets/templates/data/*.json'); assemble.layouts('assets/templates/layouts/*.hbs'); assemble.partials('assets/templates/partials/*.hbs'); assemble.src('assets/templates/*.hbs', { layout: 'default' }) .pipe(extname()) .pipe

c# - How to change button text on page load based on listview value on Visual Studio -

i want change button text on page load after retrieving list view values. for example, <asp:label id="favouritelabel" runat="server" text='<%# eval("favourite") %>' /> if label value 1, button change favourited. i have retrieved list view values binding listview protected void listview1_itemdatabound(object sender, listviewitemeventargs e) { if (e.item.itemtype == listviewitemtype.dataitem) { label activity = (label)e.item.findcontrol("favouritelabel"); activityid = activity.text; } } then, activityid , simple if-else check on page load protected void page_load(object sender, eventargs e) { if (activityid == "1") { button4.text = "favourited"; } else { button4.text = "favourite"; } } however not work. anybody?

babeljs - Is there any practical difference between using babel-runtime and the babel-polyfill when *not* developing a library? (e.g. web application) -

it's in title, really. in babel documentation, there following line on page describing babel-runtime another purpose of transformer create sandboxed environment code. built-ins such promise, set , map aliased core-js can use them seamlessly without having require globally polluting polyfill . the polyfill that, separate javascript file included shims missing things. i've tested polyfill vs. using babel-runtime build tools (webpack), , files slightly smaller when use babel-runtime. i'm not developing library or plugin, web application, , not care global scope being polluted. knowing this, other smaller final filesize, there other practical benefits or points in using runtime on polyfill? if don't care polluting global scope, polyfill better option: runtime not work instance methods such [0, 1, 2].includes(1) , while polyfill will. the main difference between 2 polyfill pollutes global scope, , works instance methods, while runtime not poll

java - Hashtable of type <String,String> is storing <String, Integer> type value as I see in the log cat and debugger. Is it possible? -

this first question posting here. since guys have answered many question , find answers, stackoverflow. being specific problem- have static hastable type <string,string> . when setting values , key other activity, in specific case(i not sure of case) hastable having data of type <string, integer> . checked in debugger showing same. mistake have made can please me pointing issues? thanks. edit code- hashtable<string,string> details; details= new hashtable<>(); hashtable temp; temp = details; temp.put("key1", new integer("1")); temp.put("key2", "1"); log.d("details", details.get("key1"));//causes classcastexception: java.lang.integer cannot cast java.lang.string log.d("temp",temp.get("key1").tostring());//no issue ,worked can hashtable of type <string,string> contains value of type <string,

printing - PigLatin and print a message -

i'm using grunt shell of piglatin , trying print simple message, in shell echo "result :" , result given pig script . have done searches , no luck far. echo returns error , same print. i can't use udfs... you can dump alias or store alias in file see alias values. refer : http://chimera.labs.oreilly.com/books/1234000001811/ch05.html#pl_dump http://chimera.labs.oreilly.com/books/1234000001811/ch05.html#pl_store

sorting - Displaying content of an array + taking input -

what in world, matter here: #include <stdio.h> int main(int argc, char const *argv[]) { int array[20]; int *parray = array; int count; int = 0; while(1) { scanf("%d", array+i ); if(*(parray+i) == -1) break; i++; } printf("contents: "); while(1){ if (*(parray + i) != -1) { printf("%d ", *(parray + i) ); i++; } } return 0; } thank you. trying take input user , display contents of array. going arrange them in order using pointers, i'll wait till replies. here rewrite attempt: #include <stdio.h> int main(void) { int array[20]; int = 0; while(1) { scanf("%d", &array[i] ); if(array[i] == -1) break; i++; } printf("contents: "); = 0; // reset counter zero. while(1) { if (array[i] != -1)

java - Retrieve value from database in drop-down(<s:select>) using Struts 2 and Hibernate -

i want use dropdown , getting value in drop down database, dropdown should contain company code saving purpose & company description display purpose. below code: bean class: package com.ims.master.company.bean; public class companybean { private string id; private string cmpcode; private string cmpdes; private string cmpstatus; private string cmpcreated; public companybean(string cmpcode, string cmpdes) { super(); this.cmpcode = cmpcode; this.cmpdes = cmpdes; } public string getid() { return id; } public void setid(string id) { this.id = id; } public string getcmpcreated() { return cmpcreated; } public void setcmpcreated(string cmpcreated) { this.cmpcreated = cmpcreated; } public string getcmpcode() { return cmpcode; } public void s

javascript - validate url without https:// http:// means also can accpet if url is www accpets both (http and www) -

hi trying build regex using javascript url can accepts https:// ( http://) or without http url starts www. like http://www.google.com https://www.google.com www.google.com here regex /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/|www\.)[a-z0-9]+([\-\.]{1}[a-z0-9]+)+\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/ but wrong here times accpet not accept www.abc.com it accpets www.acbc , http://www.google https://www.google kindy me out in advance try this: ((http|ftp|https)://)?([a-za-z0-9\._-]+\.[a-za-z]{2,6})(:[0-9]{1,4})*(/[a-za-z0-9\&%_\./-~-]*)? update: if want use in javascript, should be: var re = /((http|ftp|https):\/\/)?([a-za-z0-9\._-]+\.[a-za-z]{2,6})(:[0-9]{1,4})*(\/[a-za-z0-9\&%_\.\/-~-]*)?/; console.log(re.test('http://www.google.com')); console.log(re.test('https://www.google.com')); console.log(re.test('www.google.com')); console.log(re.test('google')); the definition of url b

github - how to apply a modification to thirdparty git packages across releases? -

there's opensource thirdparty project on github. have internal git repo need maintain change (it won't pushed github). what's best way me maintain change across new releases of thirdparty project? assuming change relatively localized, there way go through series of error-prone steps make same changes same code every time need update thirdparty project latest release?

c# - HttpClient is adding it's own cookie header -

i have rather strange problem. questions on internet how add , cookies, want opposite ;) when try send request via httphandler adding it's own cookie header. have rid of it. without digging details - when added, server trying request giving me wrong answer. works without cookie (tried in fiddler). but problem, code: string domain = "somemysteriousdomain"; var handler = new httpclienthandler(); handler.usedefaultcredentials = false; handler.allowautoredirect = true; handler.clientcertificateoptions = clientcertificateoption.manual; handler.usecookies = false; var httpclient = new httpclient(handler); var request = new httprequestmessage(httpmethod.get, domain); request.headers.useragent.add(new productinfoheadervalue("mozilla", "5.0")); request.headers.acceptencoding.add(new stringwithqualityheadervalue("gzip")); var response = await httpclient.sendasync(request); raw request seen in f

android - LibGDX : Deploying to iOS device : ApplicationVerificationFailed -

so, have been trying couple of days deploy phone. paid ios developer. have made demo ios app test bundle id works. cant libgdx deploy. phone running ios 9 beta 3 so bundle id com.burfdevelopment.hackworld (first thing came mind) in xcode, can deploy dummy hackworld app device. in robotvm.properties have app.id=com.burfdevelopment.hackworld in main bunild.gradle have robovm { iosprovisioningprofile = "iosteam provisioning profile: com.burfdevelopment.hackworld" } i have tried new hackworld profile, still did not work. full output failure: build failed exception. * went wrong: execution failed task ':ios:launchiosdevice'. > failed launch ios device * try: run --info or --debug option more log output. * exception is: org.gradle.api.tasks.taskexecutionexception: execution failed task ':ios:launchiosdevice'. @ org.gradle.api.internal.tasks.execution.executeactionstaskexecuter.executeactions(executeactionstaskexecuter.jav

visual c++ - Using c++, how do I get the value of the stack pointer in msvc X64 -

using c++, fastest way either stack pointer or rough estimate of maximum value of stack pointer in msvc++ on x64? i'm going use write inline function: static __forceinline bool isonstack(const void *p) { return uint_ptr(p) < __esp; } i use macro if better #define isonstack(a) thanks! edit i need know if on stack other code won't free it. suffice legacy implementation of smart pointers making faster. have work address of object smart pointer referring to. making change smart pointer can refer item on stack, eliminate superflous heap allocations. 64 bit stack appears relatively low virtual address. our allocator uses predefined virtual base address (16gb right now). assume below on stack. method might accidentally assume allocated malloc or ::new on stack, wouldn't end of world, since aren't supposed ever use those. thought i'd see if there better way idea stack was. performance more important accuracy long don't false negatives.

php - How can I count the total number of duplicate values between 2 tables on an inner join -

i have following query select fixtures.fixture_id, fixtures.home_score, fixtures.away_score, predict.fixture_id, predict.phome_score, predict.paway_score fixtures inner join predict on fixtures.fixture_id=predict.fixture_id i want count number of times following condition met fixtures.home_score=predict.phome_score , fixtures.away_score=predict.paway_score , fixtures.fixture_id=predict.fixture_id i tried using 'count( )' 'having count( )>1' cant syntax work i have tried count number of times if condition met in following php. i'm not sure if possible, thought count might have done within sql statement <?php $current = $user->data()->id; $sql2 = "select fixtures.home_team, fixtures.away_team, fixtures.home_score, fixtures.away_score, predict.phome_score, predict.paway_score fixtures inner join predict on fixtures.fixture_id=predict.fixture_id predict.id='".$current."'

paypal - Recurring in Authorization & Capture -

i managed make authorized payment using authorization & capture api. setexpresscheckout paymentrequest_n_paymentaction=authorization getexpresscheckoutdetails payerid , other information doexpresscheckoutpayment paymentrequest_n_paymentaction=authorization docapture authorizationid={transactionid_from_step_3} everything works fine. but, unable perform doauthorization , doreauthorization next time. wish charge subscribers recurring every month. few attempts have been tried. know how perform authorization & capture recurring? suggestions appreciated. ps: sorry broken english. an authorization agreement pay 1 bundle of goods. once authorized transaction completed authorization consumed/used up. cannot use (alone) multiple transaction payments. you need use reference transaction product, how paypal collects user's agreement make (current and) future transactions: https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ecreference

php - How to change multiple values with SQL? -

is possible change multiple table values 1 sql query? instance, table named "newsletter" has column named "received" has enum value defaults 0. when send newsletter out, value gets changed 1, recipient doesn't receive same email twice. want make script when parsed change of received values 0, can send newsletter. provide php code far, , have tested links , database connection file connecting database no issue. php include_once "connect_to_mysql.php"; $rec_value = mysql_query("select * newsletter received='1'"); $numrows = mysql_num_rows($rec_value); while($row = mysql_fetch_array($rec_value)){ $email = $row["email"]; if ($numrows == 1) { mysql_query("update newsletter set received='0' email='$email'"); } } can me change code sets received values 0 when script executed? thanks! you mean simply: update newsletter set received='0' mysql won't u

Creating a 301 redirect with regEx till forward slash -

i'm rebuilding website , changing cms. former cms had weird url structure - adding post id in end of url forward slash. example: www.mydomain/category/someurl/54 i'd create 301 redirects in .htaccess regex new cms (wordpress). how create pattern match old cms url new url removing last forward slash , id in url? basically should this: 301, www.mydomain/category/someurl/54 www.mydomain/category/someurl you can place rule very first rule below rewriteengine line. rewriteengine on rewriterule ^(.+?)/[^/]+/?$ /$1 [l,r=301]

Extract data (likes) from JSON API using Python -

i want pull number of likes project. here's code: import facepy facepy import graphapi bs4 import beautifulsoup import json access = 'caacedeose0cbae3il99iredeafqavzboje8zcqihf6tpaf7hspf3j9dyrwi3yustf0hxqwr2lmagczdbwbsdnfzhrejxzkbq9hbzcyc1fb2z1qyhs5beazcv3zyu8jhecbsiib5bf73gzafq1rua2pdx9u24duzcx0qmdzvxhlhv9jprizbbyb2b2uehgk22m4zd' graph = graphapi(access) page_id= 'walkers' datas= graph.get(page_id+'/', page=true, retry=5) data in datas: print data and here's output: { u'category': u'product/service', u'username': u'walkers', u'about': u"welcome home of walkers crisps. when comes making brits smile, we\u2019ve got in bag (yeah, went there.) we're here mon-fri, 9am-6pm!", u'talking_about_count': 3076, u'description': u'to find out more walkers, visit:\nhttp://twitter.com/walkers_crisps\nhttp://www.youtube.com/walkerscrisps', u'has_ad

c++ - Save what's inside of a circle detected by a Hough Circle on OpenCV -

i'm using hough circle transform opencv detect circles images passed command line parameter. need save information inside determined circle (shape , colors), defined specific color. actual code following: // read image while(*argv){ images_read[i] = cv::imread(*argv, 1); if(!images_read[i].data){ std::cout << "image " << *argv << " couldn't read!\n"; exit(-1); } ++argv; ++i; } array_size = i; /// convert gray for(i = 0; < array_size; ++i){ cv::cvtcolor(images_read[i], images_gray[i], cv_bgr2gray); /// reduce noise avoid false circle detection cv::gaussianblur(images_gray[i], images_gray[i], cv::size(9, 9), 2, 2); //cvsmooth(images_gray[i], images_gray[i], cv_gaussian, 7, 7); /// apply hough transform find circles cv::houghcircles(images_gray[i], circles[i], cv_hough_gradient, 1, images_gray[i].rows / 8, 200, 100, 0, 0); } how can that? thanks. i don't

codeigniter - I cannot update by inserting details from a popup form -

when click insert link in second row passes id of first. first row updated. my controller: money_c : function addrow() { $this->load->view('header'); $this->load->view('manualupdate',$result); $this->load->view('footer'); } my view page: manualupdate.php : <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> </style>--> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>popup contact form using css - demo | codingcrazy</title> <link href="<?php echo base_url();?>assets/css/styleform.css" rel="stylesheet" type="text/css"/> <link href='http://fonts.googleapis.com/css?family=electrolize' rel

azure - Unable to publish node.js app from VS2015 using VS publish -

i’ve got node.js project i’m using publish azure. worked fine first couple of times i’ve published, when try , publish fails no error message. output in azure service activity window in vs2015 simply: auto connectionstring transformed web.config obj\release\csautoparameterize\transformed\web.config. copying files temporary location below package/publish: obj\release\package\packagetmp. and output ouput/build window is: ------ publish started: project: node, configuration: release cpu ------ auto connectionstring transformed web.config obj\release\csautoparameterize\transformed\web.config. copying files temporary location below package/publish: obj\release\package\packagetmp. ========== build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ========== ========== publish: 0 succeeded, 1 failed, 0 skipped ========== i don’t know start diagnosing there no error message per se. things i’ve tried far: full clean and/or rebuild deleted folders bin directory deleted folders ob

Ruby: Use string interpolation to access ActiveRecord properties -

is possible me use string interpolation build activerecord query so: query = '.owner.name' widget = widget.first name = "#{widget" + query + "}" this doesn't work, i'm looking acceptable alternative. query = '.owner.name' widget = widget.first name = eval "widget#{query}" not idea, work. is 'eval' supposed nasty? with great power comes great responsibility (and risk). since rails uses hashes map columns methods, , hashes "hashes indifferent access" can use either string or symbol. thus: widget = widget.first widget[:owner] # => returns same widget.owner widget['owner'] # => returns widget.owner. the problem above code, owner foreign key column, method name actually: widget['owner_id'] which returns integer rails uses id in owners table. if stringing columns return columns in widget table, can use above code. when stringing query methods because looking relati

c# - Caliburn.Micro view resolution for ViewModel<T> -

i have come across problem cm, in cannot resolve view when matching viewmodel contains generic type parameters. for example, convention fooviewmodel resolves display fooview ; experiments, fooviewmodel<t> not. is supported scenario , i'm missing obvious? if not, know if there way coax cm using existing conventions or have add or override default convention somehow? for might see in future, seems had been awake far, far long when tackling problem last night. looking again @ (after bit of kip , coffee) can confirm when cm encounters generic viewmodel class such fooviewmodel<t> , resolve display fooview . the reason why couldn't cm resolve due fooviewmodel<t> class being located in wrong namespace!! changed namespace 'viewmodels' per convention , viola! works.

Read open graph image through Facebook API -

here's stackoverflow.com's og:image meta tag: <meta property="og:image" itemprop="image primaryimageofpage" content="http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon@2.png?v=ea71a5211a91&a" /> is possible read information through facebook's open graph api, rather scraping page manually? https://graph.facebook.com/?id=http://stackoveflow.com returns: { "og_object": { "id": "10150180465825637", "description": "q&a professional , enthusiast programmers", "title": "stack overflow", "type": "website", "updated_time": "2015-07-21t12:33:38+0000", "url": "http://stackoverflow.com/" }, "share": { "comment_count": 4, "share_count": 32367 }, "id": "http://stackoverflow.com" } if additionally r