Posts

Showing posts from August, 2014

php - How do I insert a row when MySQL database table is empty? -

i hope isn't repeat question. have searched on find answer no avail. i want insert row of table. sounds simple enough, if table empty, not work. can't figure out why. long there 1 row in table, works fine. appreciated. thanks. my code: <?php $fname = $_post['fname']; $mi = $_post['mi']; $lname = $_post['lname']; $phone = $_post['phone']; $email = $_post['email']; $add1 = $_post['add1']; $add2 = $_post['add2']; $city = $_post['city']; $state = $_post['state']; $zip = $_post['zip']; $con = mysqli_connect("localhost","database_username","database_password","database"); $sql1 = "insert employee (fname, mi, lname, phone, email, add1, add2, city, state, zip) values ('$fname', '$mi', '$lname', '$phone', '$email', '$add1', '$add2', '$city', '$state', '$zip')";

android - Issue with spacing using TableLayout and TableRow -

Image
i have following setup in xml file: <tablelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/table_more_features" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/background_blue" > ... <tablerow android:id="@+id/tablerow7" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/cell_top" android:padding="5dip" > <textview android:id="@+id/txt_foo" android:background="@android:color/transparent" android:layout_weight=".3" android:text="foo" /> <textview android:id="@+id/txt_bar" android:background="@android:color/transparent"

cakephp data from multiple tables join query -

i working on cakephp 2.x. have query this: $this->bindmodel(array( 'belongsto' => array( 'contact' => array( 'classname' => 'contact', 'foreignkey' => false, 'conditions' => array( 'message.user_id = contact.user_id', array('message.mobileno' => array('contact.mobileno', 'contact.workno', 'contact.homeno', 'contact.other')), ), 'order'=>'message.idtextmessage desc', ) ) ), false); return $this->find('all', array('conditions' => array('message.user_id' => $userid), 'contain' => array('contact' ), 'fields' => arr

c++ - Why do I get an exception when I pass a std::string to printf? -

this question has answer here: c++ printf std::string? 6 answers #include<iostream> #include<string.h> #include<stdio.h> using namespace std; int main() { char a[10] = "asd asd"; char b[10] ="bsd bsd"; string str(a); str.append(b); printf("\n--------%s--------\n", str); return 0; } i can't understand why produces exception? program tries append strings. desired output when using std::cout not when using printf . because std::string not same char const * , %s format specifies. need use c_str() method return pointer expected printf() : printf("\n--------%s--------\n", str.c_str()); to more technical, printf() function imported c world , expects "c-style string" (a pointer sequence of characters terminated null character). std::string::c_str() returns

java - Camel not recognizing ?lock=false as valid -

i've got camel route reading file , it's not deleting .camellock file after route finishes wanted turn lock off. documentation camel-file says attribute "lock" yet when <from uri="file:///data/in/?lock=false" /> get: caused by: org.apache.camel.resolveendpointfailedexception: failed resolve endpoint: file:///data/in/?lock=false due to: failed resolve endpoint: file:///data/in/?lock=false due to: there 1 parameters couldn't set on endpoint. check uri if parameters spelt correctly , properties of endpoint. unknown parameters=[{lock=false}] camel 2.11.0 the file component documentation camel 2.x here: http://camel.apache.org/file2 read old camel 1.x documentation at: http://camel.apache.org/file notice on top of page, says camel 1.x! there readlock option default uses markerfile (and hence why see .camellock files). can turn off setting readlock option none, eg readlock=none

web - convert a 960 grid based site to responsive -

the website designed (www.aim.ca) using nathan smith's 960 grid. wanted convert site responsive , i've looked 996 grid (responsive) system. http://996grid.com/ in process of implementing css scripts , javascript, had encountered setbacks... first time using responsive grid system. my questions are: - should modify div classes , ids of separate stylesheet responsive well? when resize browser, elements out of proportion, see random numbers think generated js "389" , on can modify 960.css using media queries? how hard be? what best way convert 960 grid based site responsive layout? your thoughts appreciated! thank in advance. there few websites out there part solve you: first, add meta viewport tag head of html file/template: <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" /> best 1 960 grid responsiveness this github project i used 1 on website my photography club just

javascript - Code from other sites shows up in my page.- Is this a security Issue -

i working on new web page site behind firewall. using firebug debug script. have small error on 1 of dropdown boxes, if have been on page in recent history, instead of error showing in .js file, show error in domain's script. doesn't can load images, try best discribe looks like. go page reddit , around. console box firebug onfirefox open @ bottom of page , empty. go test web site , navigate new page, time console empty. when change selection in dropdown box, strange error message. there normal error:syntax error, unrecognized expression in red. under in green code haven't seen before , in lower right url domain. example get: www.redditstatic.com/reddit-init.eniy9padp1eos.js can see 147 lines of reddit code , 4 pages own web site. tried setting headders didn't seem either. is security issue since reddit (or other) code trying run on page? help. brita this sounds bug in firebug's error-logging code (it pretty terrifying things try figure out

Jenkins share build number across jobs? -

we developing app multiple parallel streams of development. have jenkins job build each stream/release. job-a may building release 1.1, , job-b may building release 1.2. i think best have build number shared across each release, such if job-a runs build number 125, if job-b runs next run build number 126. reason think best strategy android app, requires versioncode parameter incremented each time it's submitted google play. use jenkins build number versioncode value. is there way configure jenkins share build number across multiple jobs? or, has come better solution problem? short answer use timestamps or manually set versioncodes, keep things out of ci server when not necessary. or force jenkins build numbers. long answer jenkins responsible automating works on own. if don't need jenkins setup, happy well. also if use 2 branches, commit in random orders them. trying tie jobs in ways seems unnecessary trouble problem later on. e.g. if version 2.0 built ,

iphone - Need to enable UITextField in row of UITableView when cell is selected in iOS -

i have created custom cell places uitextfield in each row of uitableview. enable uitextfield particular row (i.e. activate cursor in textfield), when user presses on anywhere inside cell. i have following method try this: - (void) tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { [_cell.textfield setuserinteractionenabled:true]; } however, not working. can see i'm doing wrong? you're on right track placing inside didselectrowatindexpath:. however, setting user interaction enabled on textfield means user allowed interact object if tried. you're looking becomefirstresponder. - (void) tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { uitableviewcell *cell = [self.tableview cellforrowatindexpath:indexpath]; [cell.textfield becomefirstresponder]; }

matlab - Delete cells from cell array without replacing that by NULL -

this question has answer here: delete cell array column 3 answers i have cell contains cells, want delete specific cell cell array 'delete' function getting error "argument must contain string". example have cell a= { ['a'] ['b'] ['c'] [1 2 3]} want delete 3rd value of a(3)='c' such new cell after deleting a(3) a={ ['a'] ['b'] [1 2 3]}, means there should not null value @ place of deleted value a={['a'] ['b'] [] [1 2 3]} . please solve problem. use parenthesis instead of braces: a(1) = [];

css - Stretch / shrink parent div to fit content's width -

i trying trying make div's width wide it's content. here's fidle show mean: http://jsfiddle.net/djxpu/ i want blue area wide white. tried float:left , display:inline-block , won't work position:absolute; . workarounds? if want white area fit blue parent, you'd set width of white 100% #x{ width:100%; }

c# - String Substring is not working - Error starting index can not be larger than the length -

Image
the error keeps saying "startindex cannot larger length of string. parameter name: startindex" intializedports[i] = int.parse(ports[i].tostring().substring(105, 106)); //i tried intializedports[i] = int.parse(ports[i].tostring().substring(105, 1)); //this works, gets first number in string 5 intializedports[i] = int.parse(ports[i].tostring().substring(0, 1)); //the string i'm trying substring, im trying number 7 @ end of ipaddress in string 5b5bfdfe-6eb1-4b10-80af-cf4d9f1010fe3fc8ffa1-c16b-4d7b-9e55-1e88dfe15277fasttrackvirussoftware192.168.6.17tcp/ipyesready8/4/2013 1:07:43 pm9/1/2013 1:07:43 pm it character before "tcp/ip" string line = "5b5bfdfe-6eb1-4b10-80af-cf4d9f1010fe3fc8ffa1-c16b-4d7b-9e55-1e88dfe15277fasttrackvirussoftware192.168.6.17tcp/ipyesready8/4/2013 1:07:43 pm9/1/2013 1:07:43 pm"; var num = line.substring(line.indexof("tcp/ip") - 1, 1);

javascript - To stop ClickJacking, which one is more secure? breaking out of iframe vs X-Frame-Options to Deny or Same Origin -

to prevent clickjacking happenning website, have noticed several different methods. use javascript have website break out of iframe, other soltution set x-frame-options header deny or sameorigin. 1 of 2 method mentioned think more secure? here sample page using test clickjacking. <html> <body> <h1>clickjacking test</h1> <iframe src="http://www.google.com/" height="500" width="500"></iframe> </body> </html> with iframe break code see firefox , safari slow out of iframe, meaning see clickjacking test , break out of iframe , show original website. ie , chrome fast not noticeable. x-frame-optiions solution not see website @ all. blocked. google in above example. questions 1 of solution better? blocking or breaking out of iframe(slow in 2 browsers) in experience, setting x-frame-options (xfo) rules works better breaking out of iframes. when comes rules, depends on if absolutely have use iframes

java - Effects of Try/Catch against Throwing Exceptions in a constructing class' constructor -

i playing around of code , came across didn't understand. have class called sentimentclassifier, constructor of looks this: public sentimentclassifier(final int ngramtobeused) { try { classifier = (dynamiclmclassifier<?>) abstractexternalizable.readobject(new file(etc)); } catch (classnotfoundexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } } i have class creates one, so: public twittermanager(final int ngramtobeused) { sentimentclassifier = new sentimentclassifier(ngramtobeused); } if run code this, works fine. if change first class using try/catch throw exception, so: public sentimentclassifier(final int ngramtobeused) throws classnotfoundexception, ioexception { classifier = (dynamiclmclassifier<?>) abstractexternalizable.readobject(new file(etc)); } suddenly second class complains ioexception isn't being handled. why thrown thrown exception , not try/catch ?

stream - WCF IEnumerable - Streamed Transport Net Tcp -

i need streaming large content wcf , deferred execution (using nettcpbinding), in other words, return list of person (can anything) database through wcf service without consume memory in server side. i have tried solution in post: streaming large content wcf , deferred execution using basichttpbinding works charm, when using nettcpbinding....well...not working. can me this?? tks! project here: wcf streaming ienumerable here guidance on transferring large data streaming. http://msdn.microsoft.com/en-us/library/ms733742.aspx at bottom of page link samples, 1 of shows using tcp. http://msdn.microsoft.com/en-us/library/ms789010.aspx if doesn't help, perhaps provide more detail on how failing (error message)?

How to use css blur Filter? -

i want build blog should use modern look. i'm interested blur effect ios 7. i've read filters applied items. well, want use filter in menu bar (that fixed on top) content below appears blurred. there's way css? or other code lenguage? you can create blur effect with: <style type="text/css"> #thediv { -webkit-filter: blur(18px); } </style> <div id="thediv"></div> but it's not reliably supported (i think in chrome). there isn't inset value aware of, need event trigger (i.e. when element lays on top of div , has transparent, opacity, or other funky alpha channel attribute) blur not confined overlaying elements boundaries.

javascript - Google maps polygon not updating color after setOptions? -

i'm using google maps api alongside angularjs. have following function change polygon's color using setoptions : desk.modcolor = function (color) { desk.setoptions({ fillcolor: color }); } i'm calling within angularjs code following: $scope.focuseddesk.modcolor('#0592fa'); however, working 75% of time. after enough scope manipulation in angularjs, stops working. if console.log desk object after modcolor call, has correct fillcolor , polygon on map hasn't updated visually. any ideas why happening? there way ensure setoptions updates map/polygon visually? thanks. condition 1 if manipulating dom in form within angularjs should use directives in case should write directive you: angular.module('mymodule',[]) .directive('mydirective',function(){ return { scope: { focuseddesk:'=' }, link: function(scope, ielement, iattrs){ scope.$watch('your-whatever-object-or-property-you-wan

html - Redirect to mobile site using htaccess only on Mobile devices -

i using following code in htaccess file detect mobile devices , redirect them mobile site. but problem redirecting mobile site on tablets , ipad too. how can modify code loads full site on tablets , ipad. # check if noredirect query string rewritecond %{query_string} (^|&)m=0(&|$) # set cookie, , skip next rule rewriterule ^ - [co=mredir:0:www.mysite.com] rewritecond %{http:x-wap-profile} !^$ [or] rewritecond %{http:profile} !^$ [or] rewritecond %{http_user_agent} "acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-" [nc,or] rewritecond %{http_user_agent} "dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-" [nc,or] rewritecond %{http_user_agent} "maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [nc,or] rewritecond %{http_user_agent} "palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany" [nc,or] rewritecond %{http_user_agent} "sch-|sec-|

phpstorm - Regex to find strings not encapsulated with __("") -

i trying find instance of string in our code needs sent __() function. i have following regex: (\[|__\()[\'\"][\w\s\\\:]+[\'\"] that matches: ['valid string' ["valid::str::ing" __('valid\string' __(" v l d s t r n g " but not: 'hel\lo there ' "he::he" i need reverse match. have tried various methods negate ([|__() section have not had success. how can write the expression match strings not preceded [ or __(? thank you. you might able use negative lookbehind. please see: http://www.regular-expressions.info/lookaround.html

android - google cloud messaging receiver error -

when send message app, message: 08-12 22:17:12.932: w/gtalkservice(475): [datamsgmgr] broadcast intent callback: result=cancelled forintent { act=com.google.android.c2dm.intent.receive pkg=com.example.databasetest (has extras) } 08-12 22:17:12.932: w/gtalkservice(475): receiver package not found, unregister application com.example.databasetest sender it seems message must sending ok if app picks on trying receive something. manifest sensitive values omitted: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.databasetest" android:versioncode="1" android:versionname="1.0" > <uses-permission android:name="android.permission.internet"/> <uses-permission android:name="android.permission.access_fine_location" /> <uses-permission android:name="android.permission

dataimporthandler - Retrieving raw status output from solr admin -

i want write script compare results dataimporthandler earlier results in etl process. url use in solr is: http://hostname:port/solr/#/corename/dataimport//dataimport the raw status-output has nice json output information need (documents fetched, etc) can't find anyway return json output. there argument can give url or something? can't parse page info need. you can with: http://<host>:<port>/solr/dataimport?command=status&wt=json if want pretty-printed output, pipe body of response python -mjson.tool

vbscript - Importing to Notepad -

i have problem exporting texts notepad. used adwriteline denote each files when file has text new line or "¶", code went wrong. problem @ computer, new line imported invisibly notepad (not mention exported invisible new line imported) when tried on other pc, new line visible. thus, producing error. thanks , regards. edit: the error occurs when exported text has new line in sentence export: adostreamexport.writetext filepath &"' '" & child.height & "' '" & child.width, adwriteline import: filein = split(replace(adostreamimport.readtext, vbcrlf, "' '"), "' '") scantext filein(indexcount), filein(indexcount + 2), filein(indexcount + 3) case "text" setvalue value, value2, value3

ruby on rails 3 - ActionController::RoutingError when js => true -

none of tests have error, except 1 i'm adding js => true. oddly enough test pass if not routing error. my test: context 'javascript', :js => true visit careers_path page.should have_content("your recommendations") end i can actual puts page.body , see content there, still comes routing error. notice while running actual server , comes get request assets folder. don't understand why or doing this, seems cause of failure. the errors: while running rails s started "/assets/" 127.0.0.1 @ 2013-08-12 19:11:02 -0400 served asset / - 404 not found (5ms) while running rspec failure/error: unable find matching line backtrace actioncontroller::routingerror: no route matches [get] "/assets" # /users/tom/.rvm/gems/ruby-1.9.3-p429/gems/actionpack-3.2.14/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' # /users/tom/.rvm/gems/ruby-1.9.3-p429/gems/actionpack-3.2.14/lib/action_dispatch/middleware/show

javascript - Null prototype, Object.prototype and Object.create -

why setting prototype property of constructor function null not prevent objects created function calling through methods on object.prototype , in same way setting prototype object.create(null) does? that is, why case: function foo(){} foo.prototype = null; console.log(new foo().tostring); //outputs function tostring() { [native code] } (or whatever) function foo(){} foo.prototype = object.create(null); console.log(new foo().tostring); //output undefined in short yes , observation correct - function constructed new operator always have object prototype in case object.prototype , indeed unlike function created object.create. on why one can see behavior specified in es5 language specification on javascript based on. let's see this. in new : quoting specification of [[construct]] method of functions indicates how object creation using new operator performed can see following specified: if type(proto) not object, set [[prototype]] internal prop

php - How many, of a given weekday there has been since the beginning of this month? -

i have date, , find out how many, of weekday, there has been since beginning of month. (should 1-5) the reason need number because telling customers deliver on "the 4rd wednesday of month" example. i not need returns number of weeks has been starting predefined beginning day of week (every example can find that). it may know have implemented reverse of code follows: echo date('y-m-d', strtotime("2013-08 4 wednesday")); //returns 4th wednesday of month namely "2013-08-28" how can "4" starting "2013-08-28"? an expression should work minimal changes code. <?php $d = date('d', strtotime("2013-08-28")); echo ceil($d/7).php_eol; ?> outputs '4'. i'm sure can wrap in function. ceil()

ruby - Mongoid returns inconsistent doc id after multiple upserts of the same document -

i'm using mongoid gem in ruby. each time upsert, save or insert same unique document in collection, ruby instance shows different id. example, have script so: class user include mongoid::document field :email, type: string field :name, type: string index({ email: 1}, { unique: true }) create_indexes end u=user.new(email: 'test@testers.edu', name: "mr. testy") u.upsert puts u.to_json the first time run against empty or non-existent collection, output {"_id":"52097dee5feea8384a000001","email":"test@testers.edu","name":"mr. testy"} if run again, this: {"_id":"52097e805feea8575a000001","email":"test@testers.edu","name":"mr. testy"} but document in mongodb still shows first id (52097dee5feea8384a000001), know operating on same record. if follow upsert find_by operation, right id consistently, feels inefficient have run upser

php - Count instances in table and capture the id of every instance -

what i'm trying search through table , count instances of letter, , store id of each instance in mysql , php (pdo). what had been messing around this: $user = 'john'; $stmt = $pdo->prepare("select id, substr(surname, 1, 1) surname_init,count(*) count first_table user = :user group surname_init order count desc"); $stmt->bindvalue(":user", $user); $stmt->execute(); $row = $stmt->fetchall(pdo::fetch_assoc); var_dump($row); this result: array (size=2) 0 => array (size=3) 'id' => string '3' (length=1) 'surname_init' => string 'b' (length=1) 'count' => string '2' (length=1) 1 => array (size=3) 'id' => string '7' (length=1) 'surname_init' => string 'd' (length=1) 'count' => string '1' (length=1) so have 2 results: b has 2 instances, d has one. "b" has 1 re

ruby on rails - Can't extend core Class -

i'm trying extend core classes , have no idea why following fails when being called through rails 4 console: # config/application.rb config.autoload_paths += dir["#{config.root}/lib/**/"] # lib/core_ext/string.rb class string def test self + " test" end end # lib/core_ext/array.rb class array def mean sum / size if sum && size end end # lib/core_ext/test.rb class test def test "some test" end end rails console output: 1] pry(main)> test = test.new #<test:0x007ff63971b588> [2] pry(main)> test.test "some test" [3] pry(main)> "string".test nomethoderror: private method `test' called "string":string (pry):3:in `__pry__' [4] pry(main)> [1,2,3].mean nomethoderror: undefined method `mean' [1, 2, 3]:array (pry):4:in `__pry__' you should add following line require files project dir[file.join(rails.root, "lib", "core_ext", &

class - Defining classes: difference between var, val and leaving it out? -

this question has answer here: do scala constructor parameters default private val? 2 answers what difference between following 3 scala declarations? understand general distinction between val , var . class a(x: t){ ... } class b(val x: t){ ... } class c(var x: t){ ... } difference between a , b (both val , var create accessor): class a(a: int) {} // doesn't compile (value not member of) // (new a(1)).a class b(val b: int) {} (new b(1)).b //> res0: int = 1

uiimageview - iOS 7 status bar transparent -

Image
in storyboard, in view controller tried add navigation bar under status bar, running it, transparent , shows label that's supposed blurred, navigation bar. but when placing same view controller embedded in navigation view controller, underneath background image blurred, intention. what these 2 way different results? need firs method make status bar blur? thanks! in ios 7 status bar transparent default. blurring you're seeing when there's navigation bar created navigation bar. create effect you're looking without navigation bar, need position view produces blurring effect beneath status bar. for reference, add view frame provided by: cgrect statusbarframe = [[uiapplication sharedapplication] statusbarframe];

tkinter - Get global mouse position and use in python program? -

as part of larger project, trying create snapshot tool works similar mac os x snapshot. should take first click, second click, , return image of area created square. i have python functions take first point (x, y) , second point (x, y) , create snapshot of square points create on screenshot. missing piece getting mouse locations of initial click , second click, passing data python program create snapshot. in other words, flow of program should be: first click (save x, y) second click (save x2, y2) run snapshot.py using saved clicked data return screenshot i've found solutions can return position of pointer within frame. if helps, i'm using "import gtk" , "from xlib import display" edit: have tried use tkinter make invisible frame covers whole screen. idea use invisible frame exact coordinates of 2 mouse clicks, , invisible frame disappear, pass coordinates on screenshot function, , done. however, code i've been writing doesn't keep

dom - Add an ID to first tr in jquery datatables -

var row = [teams[i].team_id, teams[i].team_name,...]; var = otable.fnadddata(row); i'm using jquery datatables , adding teams data datatables in above mentioned way, need first column auto increment one(i'll use loop), want add team_id id tr element carries auto-incremented value in first column. how add "id" tr while datatable populated. i need output <tr id="[team_id]">1</tr> by including dt_rowid property on data source object, automatically create table row id without code whatsoever for example, ajax source: { "secho": 1, "itotalrecords": "57", "itotaldisplayrecords": "57", "aadata": [ { "dt_rowid": "row_7", "dt_rowclass": "gradea", "0": "gecko", "1": "firefox 1.0", "2": "win 98+ / osx.2+", "3": &quo

simplexml - simplexml_load_file vs Third party RSS parsing libraries.(PHP) -

i wish parse rss feed in php. first found various third party libraries same namely: magpie , simplepie. but since rss files in xml format, php has native functions of simplexml_load_file parse xml file. so why should 1 required external libraries , not use native function? using third party lib specialized in reading rss feeds, have methods , properties simplexml has not, because there implemented library. but if want read simple xml feed, using simplexml sufficient. magpie example implemented functions cache data, example.

Impersonation in SQL Server Views? -

is possible create views impersonation, similar "execute as" in stored procedures? i create views in separate schema. users should select , update access these views, able change underlying tables, without having direct update access table. is possible view ? no, not possible. execute used sp's, can use them bit more widely. from technet : in sql server can define execution context of following user-defined modules: functions (except inline table-valued functions), procedures, queues, , triggers. ... functions (except inline table-valued functions), stored procedures, , dml triggers { exec | execute } { caller | self | owner | 'user_name' } ddl triggers database scope { exec | execute } { caller | self | 'user_name' } ddl triggers server scope , logon triggers { exec | execute } { caller | self | 'login_name' } queues { exec | execute } { self | owner | 'user_name' } ho

Facebook like button doesnt show my images -

i have added 2 like-buttons images on website when click , want share them, room picture blank. how can picture show in share box , display on facebook? my website www.firamedmariamontazami.se documentation : href - url like. xfbml version defaults current page. note: after july 2013 migration, href should absolute url can confirm href absolute url? if yes, try include opengraph metas on targeted pages (page specified in href ) like: <meta property="og:image" content="http://website.com/image.jpg" /> do not forget check size of image, can find more details in discussion edit: copy link on facebook object debugger page , check facebook says image, more details. update: question: can use different metas different pictures? want ten different pictures on page can share. look @ this paragraph in documentation , can specify many images , first image tag given preference during conflicts. keep in mind when share on

php - Treating & as normal character with $_GET -

i have application posts content mysql db via php. php uses $_get pull content url , inserts db. this works great, have discovered issue. if user enters characters (", &, , others), $_get method not separate content url. let's user posts content: love blue & green in situation, & symbol cuts string after word blue. is there way me edit php file ignore & symbol , treat part of variable supposed $_get? great! you can use $_server['query_string'] from http://php.net/manual/en/reserved.variables.server.php

ruby on rails - How should I manage the path to unicorn pid file on production? -

i trying rails 4+ ruby 2.0 depployment vps on digitalocean. using unicorn + capistrano stack. in local setup have file in config/unicorn.rb: app_root = file.expand_path("../..", __file__) working_directory app_root pid "#{app_root}/tmp/unicorn.pid" worker_processes 2 preload_app true listen "/tmp/unicorn.sock" timeout 30 stdout_path "#{app_root}/log/unicorn.log" stderr_path "#{app_root}/log/unicorn.log" now questions are: should checking file git version control? or should have separate unicorn.rb on production server pointing pid path say, /home/deploy/#{myapp}/tmp/unicorn.pid ? i confused how manage consistent paths, guess. please the simplest way manage paths differ between environments via environment variables. eg: env['pids'] ... from unicorn config file above, pids going dumped #{app_root}/tmp , no matter environment... check out foreman , in particular upstart export (if you're on

javascript - Is it possible to put 'number of chosen checkboxes limitation' in multiple forms into the loop? -

i'am creating page on user fill form consisting of multiple forms. each of these forms has different maximal number of possible answers. how minimize number of lines of code , put code loop? tried loop based on array, still don't know how change $("input[name='pytanie1']") every time loop goes through it. javascript put loop: $(document).ready(function () { $("input[name='question1']").change(function () { var maxallowed = 2; var cnt = $("input[name='question1']:checked").length; if (cnt > maxallowed) { $(this).prop("checked", ""); alert('choose max. ' + maxallowed + ' answers!'); } }); }); $(document).ready(function () { $("input[name='question2']").change(function () { var maxallow

debugging - See which method is being called – xcode -

i have imagepickercontroller , imageview . when orientation changes imageview changes position. when imagepickercontroller loaded landscape mode, orientation changes portrait (since imagepicker supports portrait mode). then when imagepicker dismissed imageview changes position place dont want to. i want see method being called. is there way see method being called while app runs? you can use break point or can track debug navigator.

c++ - why a lot of login logout actions in one sqlserver session? -

i created ole db connection sqlserver 2008r2 using atl::cdatasource, opened session using atl::csession, run different sql queries using open , close rowsets ccommand. in end closed session , connection. and created audit log , add login/logout actions log. see lot of login/logout actions 1 session id. looks each query program makes login/logout. incorrectly?

ruby on rails - How to generate RABL instead of ERB file -

how generate rabl view instead of html.erb am using following command rails generate controller users new create update edit destroy index show am getting .erb views. need rabl view. rabl included in gemfile gem 'rabl' i think you're asking generator creates 'rabl' files scaffolding? as far know, nope. there isn't generator inside rabl gem. as ckruse said; file -> new -> show.rabl

producer - consumer multithreading in Java -

i want write program using multithreading wait , notify methods in java. program has stack (max-length = 5). producer generate number forever , put in stack, , consumer pick stack. when stack full producer must wait , when stack empty consumers must wait. problem runs once, mean once produce 5 number stops put run methods in while(true) block run nonstop able doesn't. here tried far. producer class: package trail; import java.util.random; import java.util.stack; public class thread1 implements runnable { int result; random rand = new random(); stack<integer> = new stack<>(); public thread1(stack<integer> a) { this.a = a; } public synchronized void produce() { while (a.size() >= 5) { system.out.println("list full"); try { wait(); } catch (interruptedexception e) { e.printstacktrace(); } } result =

merge - Use another Branch in a project in TFS -

i have solution these projects : dal - bll - ihm my "bll" project using "dal" project. i need modify "dal" project. for that, i've create branch "dal" , call "dal-patch01". how can tell "bll" project use "dal-patch01" , not "dal" until made merge? is possible that?

jquery - select dynamic tab immediately upon new tab creation -

demo : http://jsfiddle.net/axrwkr/ujuu2/ var num_tabs = $("div#tabs ul li").length + 1; $("div#tabs ul").append( "<li><a href='#tab" + num_tabs + "'>#" + num_tabs + "</a></li>" ); $("div#tabs").append( "<div id='tab" + num_tabs + "'>#" + num_tabs + "</div>" ); $("div#tabs").tabs("refresh"); the new tabs syntax complicated (after 1.9 upgrade).. one more question, 1.9 onward remove method had been depreceated, if want remove particular tab, should use remove() remove tab element , appended div (content)? sound un-practical.. add in end of $("button#add-tab").click(function() demo $('a[href=#tab'+num_tabs+']').click(); //click new tab link make active or can use active option demo $("div#tabs").tabs("ref

Counting unique elements in sections of .csv columns (Python) -

i have .csv file of geological formations , occurrences of fossil species @ each formation. each fossil has own row in .csv file, formation name included in row. the code wrote below printed out number of formation occurrences fine. import csv collections import counter out=open("bivalviagrdwis.csv", "rb") data=csv.reader(out) data.next() data=[row row in data] out.close() formations = [] row in data: if row[13]=='': continue else: formations.append(row[13]) print counter(formations) however, there may duplicate fossil names ruin count; want number of unique fossils @ each formation. can add count unique elements in section of single column .csv file, rather elements? you need keep track of fossils have seen, per formation. collections.defaultdict() object makes coding easiest; keeps set per formation can test against: import csv collections import counter, defaultdict fossil = 0 # fossil name fi

asp.net - IIS 7.5 Canonical URL Rewrite rules for multiple domains -

in context of url rewrite 2.0 in iis 7.5 , want able enforce canonical domain names multiple domains multi-country site, in few rules possible. this: <rule name="uk host name"> <match url="(.*)" /> <conditions logicalgrouping="matchall"> <add input="{http_host}" pattern="^company\.co\.uk$" /> <add input="{http_host}" pattern="^company\.co$" /> <add input="{http_host}" pattern="^company\.org$" /> <add input="{http_host}" pattern="^company\.net$" /> <add input="{http_host}" pattern="^company\.uk\.com$" /> <add input="{http_host}" pattern="^www\.company\.co\.uk$" negate="true" /> </conditions> <action type="redirect" url="http://www.company.co.uk/{r:1}" /> </rule> <rul

java - Displaying pdf in JavaFX -

developing desktop application in javafx requires display pdf. read there no support pdf viewing/displaying in javafx (current version), read jpedal too. now, questions: is there external component or library view pdf in javafx? should freeware. (if have use jpedal ) how can embed in application. jpedalfx sample code , usage sample code on using jpedalfx provided jpedalfx download . kind of lame on part, i'll paste snippets sample code here have been copied sample viewer provided jpedalfx library. code relies on jpedal_lgpl.jar file included jpedalfx distribution being on classpath (or library path referenced in manifest of application jar). should have further questions regarding usage of jpedalfx, suggest contact idr solutions directly (they have been responsive me in past). // file path. filechooser fc = new filechooser(); fc.settitle("open pdf file..."); fc.getextensionfilters().add(new filechooser.extensionfilter("pdf files&quo

php - editing image by using input file type -

i made simple editing edit data in mysql, works fine except when want edit input file type image doesn't work, doesn't give error message doesn't edit , when remove input file type image works. , editing image mean entering new image replace old image. here code: <?php require("db.php"); $id = $_request['theid']; $result = mysql_query("select * table id = '$id'"); $test = mysql_fetch_array($result); $name = $test['name'] ; $email = $test['email'] ; $image = $test['image'] ; if (isset($_post['submit'])) { $name_save = $_post['name']; $email_save = $_post['email']; if (isset($_files['image']['tmp_name'])) { $file = $_files['image']['tmp_name']; $image = addslashes(file_get_contents($_files['image']['tmp_name'])); $image_name = addslashes($_files[&

javascript - Fire jquery event from Java -

i have few elements generated dynamically jquery click event on each element defined follows: $(".addtocart").live("click", function(e) { <!-- function body goes here --> }); now need implement button adds elements if used clicked on each 1 of them. have implemented logic in servlet after click "add all" button need refresh page ui refreshed. wonder if can fire jquery event servlet in order update gui. you need update ui within javascript. java , jquery separate beasts , cannot call functions between them. e.g. java cannot call javascript, javascript cannot call java. instead should add jquery function "add all" similar 1 have shown: $(".addall").live("click", function(e) { <!-- send ajax request tell server user has added items cart -->l <!-- if there no errors, update ui reflect add button being pressed --> }); if need function update server side, function need make ajax cal

java - Implementing Read-Write Locks with Double-Checked Locking -

i've written java readwritelock readers use double-checked locking acquire write-lock. unsafe (as case dcl lazy-instantiation)? import java.util.concurrent.atomic.atomicinteger; public class dclrwlock { private boolean readeracquiringwritelock = false; private boolean writerlock = false; private atomicinteger numreaders = new atomicinteger(); public void readeracquire() throws interruptedexception { while (!nzandincrement(numreaders)) { synchronized (this) { if (numreaders.get() != 0) continue; if (readeracquiringwritelock) { { wait(); } while (readeracquiringwritelock); } else { readeracquiringwritelock = true; writeracquire(); readeracquiringwritelock = false; assert numreaders.get() == 0; numreaders.set(1);