Posts

Showing posts from July, 2014

c - SDL2.0 Alternative for SDL_Overlay -

so i've been trying go through following tutorial on ffmpeg: http://dranger.com/ffmpeg/tutorial02.html however, when try compile using gcc, following output: root:/users/mbrodeur/downloads/hackathon content/tutorials-> gcc -o tutorial02 tutorial02.c -lavutil -lavformat -lavcodec -lz -lavutil -lm -lswscale -d_thread_safe -lsdl2 tutorial02.c: in function ‘main’: tutorial02.c:41: error: ‘sdl_overlay’ undeclared (first use in function) tutorial02.c:41: error: (each undeclared identifier reported once tutorial02.c:41: error: each function appears in.) tutorial02.c:41: error: ‘bmp’ undeclared (first use in function) tutorial02.c:98: warning: assignment makes pointer integer without cast tutorial02.c:110: error: ‘sdl_yv12_overlay’ undeclared (first use in function) now, read sdl_overlay no longer used in sdl2, therein lies problem. i've been poking around, can't seem find helpful. there replacement sdl_overlay? necessary? sdl_overlay used in following context: sdl

javascript - Backbone Custom Events -

let's have 2 views (paginationview , postsview) , collection (postscollection). whenever .next button clicked in paginationview calling next function in postscollection , post collection fetching new page's posts server (code simplified). in post view, want display posts in last page. don't want bind view 'add' event in collection because there more cases 'added' collection. want 'renderlist' function in postsview called when 'nextpage' function called in postscollection. how connect these functions together? // paginationview var paginationview = backbone.view.extend({ events:{ 'click a.next' : 'next', }, next: function() { this.collection.nextpage(); return false; } }); // collection var postscollection = backbone.collection.extend({ model: model, initialize: function() { _.bindall(this, 'parse', 'url', 'pageinfo', 'nextpage'

visual studio 2012 - LNK1120 error - VS2012 project using a VS2010 DLL -

i have third party dll compiled vc10 (vs2010). exports following function: bool mydll_exports_api myfunction(std::vector<int>::const_iterator c) { return true; } my exe uses dll. trying compile exe vc11 (vs2012). #include "stdafx.h" #include <vector> #include "mydll_vc10\mydll_vc10.h" int _tmain(int argc, _tchar* argv[]) { std::vector<int>::const_iterator c; myfunction(c); return 0; } i following linker error: 1>usingdllvc10.obj : error lnk2019: unresolved external symbol "__declspec(dllimport) bool __cdecl >myfunction(class std::_vector_const_iterator > >)" (_ imp ?myfunction@@ya_nv?$_vector_const_iterator@v?$_vector_val@u?>$_simple_types@h@std@@@std@@@std@@@z) referenced in function _wmain 1>c:\work\training\vectorreproducebug\usingdllvc10\debug\usingdllvc10.exe : fatal error lnk1120: 1 >unresolved externals note: code compiles , links if exe compiled vc10 (vs2010). how fix

c# - How to sanitize input from MCE in ASP.NET? -

is there utility/function in c# sanitize source code of tinymce rich text. remove dangerous tags whitelist safe html tags. i don't think there built-in sanitizer c# can use here did when had same issue. used htmlagilitypacksanitizerprovider comes ajaxcontroltoolkit. code looks this: private static ajaxcontroltoolkit.sanitizer.htmlagilitypacksanitizerprovider sanitizer = new ajaxcontroltoolkit.sanitizer.htmlagilitypacksanitizerprovider(); private static dictionary<string, string[]> elementwhitelist = new dictionary<string, string[]> { {"b" , new string[] { "style" }}, {"strong" , new string[] { "style" }}, {"i" , new string[] { "style" }}, {"em" , new string[] { "style" }}, {"u" , new string[] { "style" }}, {"strike" , new string[] { "style" }}, {"sub

Memory error in recursive function (Python 2.7.3) -

i'm running memory error in 1 of recursive function. def allpaths(self, adjmat, start, stop, flag=[0], walks=[]): walks = walks + [start] if start == stop: return [walks] loc = 0 flag=flag*len(adjmat) output = [] value in adjmat[start]: if value > 0.0: if flag[loc] < 3: flag[loc]+=1 paths = self.allpaths(adjmat, loc, stop, flag, walks) k in paths: output.append(k) loc += 1 return output one example input fine memory error different matrix. >>>print test.allpaths([[0.0, 0.9, 0.0, 0.0, 0.0, 0.0, 0.1, 0.0], [0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.8, .15, .05, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], [0.0, 0

instruments - iOS UIAutomation - Unable to record script -

i facing strange problem. unable record script while running instrument ui automation. based on article http://www.verious.com/article/test-automation-uiautomation-example-with-xcode-instruments/ i tried record user action device simulator instrument don't generate script replay. i've restarted machine, x-code, instrument etc multiple times. on x code 4.6.3 instrument version 4.6, mac os version: 10.8.4 any help!!! thanks- if you're new should follow official tutorial. http://developer.apple.com/library/ios/#documentation/developertools/conceptual/instrumentsuserguide/usingtheautomationinstrument/usingtheautomationinstrument.html#//apple_ref/doc/uid/tp40004652-ch20-sw83 also idea @ first runs yours app in iphone xcode, , after open instruments , record script, in way target determined, app on iphone.

Force CodeBlocks To Build Unchanged (Up-to-date) codes -

i know how make codeblock, when press build button, compile hole code, if code has not changed. right now, when try build, shows following message: target date. nothing done (all items up-to-date). i force build again, if resulting .exe same. on codeblocks 12.11, there a "rebuild" (ctrl-f11) option under build menu or when right-clicking on project. forces recompilation , averts "up date" message.

perl - Deleting items from an array and collapsing it after -

using perl, have array of ip addresses i'm storing in array. there many operations done on elements in array , 1 of them delete ip address. know can use delete function, leaves empty spot in array. there function/way delete item array , collapse/shift elements there no empty spots. for example, there 10 elements in array. delete 3rd element. there 9 elements , 4th element becomes 3rd, 5th becomes 4th, etc. thank help! lets have 10-element array: my @arr = (0..9); then want remove element 3, or offset 2: my $third_element = splice @arr, 2, 1; @arr 0, 1, 3, 4, 5, 6, 7, 8, 9.

xml - php SoapClient, __soapCall and __getLastRequest / __getLastResponse -

i used downloaded tool auto-create wrapper web service (fedex rate service) creates handy code base accessing service auto-generates class map , builds auto-loading data structure asking web service it's requirements , capabilities. creates wrapper 'extend' of soapclient itself. the problem is, makes separate service calls using abstract wrapper utilizes __soapcall method. problem i've noticed apparently doesn't populate can retrieve xml calls themselves. whenever call __getlastrequest or __getlastresponse , return null though __soapcall('getrates', $args) returns php object response service. short of re-writing auto-generated code call $this->getrates($args) or similar, there trick seeing xml used in request , returned in response when using __soapcall ? nevermind - thought had trace defaulted true, , reason getting 'null' was defaulting false. as long create interface instance second argument array('trace'=>1)

database - Sqlite3 Adding Columns -

i'm working django , added new model variable meaning need column in sqlite3 data base. i have heard i'm supposed use sqlite> , confused when start use it. so, if part of solution, can specific on do? thanks more info: my app called "livestream" & , class "stream" added model "channel" returns ----> databaseerror: table livestream_stream has no column named channel you can alter table add new column in sqlite3 not rename nor drop it. sqlite3 useful database bootstrapping app. sooner or later, need change more robust/flexible database engine, mysql or postgresql. every time add new column models using sqlite, need recreate schema (as far know, when migrations sqlite add new columns, south complaints. see below). approach more use mysql django-south beginning, i'm not sure every aspect of database. django south app doing database migrations. it's useful , the docs starting point beginners. every tim

ruby - How do I compare two text files with rspec? -

i have method compares if 2 text files have same content. how compare if 2 text files have same content using rspec? on trivial level: io.read(file1).should == io.read(file2) if want nicer, you're going need write new matcher, have_same_content_as defined check above condition. " up , running custom rspec matchers " nice tutorial on writing custom matchers.

java - Connecting two Android applications -

i developing dictionary app accessed in third party app. basic idea whenever using app(say viewing webpage or messaging) , want know meaning of word have select word , share app. have developed of code thing not able mechanism share word third party app(say messenger app)into app. whenever select word should give option called "share dictionary" , should redirect dictionary(my app) , display meaning of selected word. wanted mechanism share option appear in third party application after selecting word ,similar "cut","copy" options appear on selecting word. any appreciated guys. thank you. yes can in following manner 1-: can use sharedprference public global place save data in application level. 2-: create file in internal storage 1 application write , read or vise versa. 3-: store data in web , make set , api. and more information can read storage option in android

iterating over in a python dictionary -

sorry simple question, guess getting basic looping wrong. not sure why not geting expected result. comp = {'red':100, 'blue':101, 'green':102 ,'ivory':103, 'white':104} comp ['black'] = 99 def value_for_value(d, mynumber): key, value in d.iteritems(): print key,value,type(value),mynumber,type(mynumber) mykey = 'aaa' if value == mynumber: mykey = key return mykey print value_for_value(comp,99) expected result : black actual results : aaa ps: make sure comparing correct data types, have printed data types well. the problem every time through loop, set mykey = 'aaa' . so, unless str happens last value, overwrite right answer wrong one. let's add more prints see better: def value_for_value(d, str): key, value in d.iteritems(): mykey = 'aaa' if value == str: mykey = key print key,value,type(value),str,type

Sum up elements in matrix arraylist -

i trying sum each arraylist within arraylist. assuming use method. not sure how exactly. have far. indicated arrows trying add arraylist before starts on new arraylist. ideas????? public void sparsecounttimer(arraylist arraylist) { double totalrowscount = 0.0; long totaltime = 0; (int x = 0; x < iteration; x++) { long starttime2 = 0, estimatedtime2 = 0; double rowtotal = 0.0, lastrowtotal = 0.0; for( int = 0; < matrixdimension; ++i) { if (lastrowtotal < rowtotal) { lastrowtotal = rowtotal; starttime2 = system.nanotime(); } rowtotal = 0.0; (int j = 0; j < matrixdimension; ++j) { >>>>>>>>> rowtotal += arraylist.get(j).get(i); <<<<<

mysql - SQL statement Max(Count(*)) -

basically have review table product. attributes reviewid, reviewcustname, reviewtext, productid. wonder there ways count product reviews? here sql statement: select productid, count(*) mostreviews, max(mostreviews) sm_review group productid; i wonder possible write such sql statement? or there better way? thanks in advance. you can use following result. gets total count each product when order count in descending order , apply limit 1 returns product reviews: select count(*) total sm_review group productid order total desc limit 1

date - matlab - only keep days where 24 values exist -

say have dataset: jday = datenum('2009-01-01 00:00','yyyy-mm-dd hh:mm'):1/24:... datenum('2009-01-05 23:00','yyyy-mm-dd hh:mm'); datev = datevec(jday); datev(4,:) = []; datev(15,:) = []; datev(95,:) = []; dat = rand(length(jday),1) how possible remove of days have less 24 measurements. example, in first day there 23 measurements need remove entire day, how repeat of array? a quick solution group year, month, day unique() , count observation per day accumarray() , exclude less 24 obs 2 steps of logical indexing : % count observations per day [undate,~,subs] = unique(datev(:,1:3),'rows'); counts = [undate accumarray(subs,1)] counts = 2009 1 1 22 2009 1 2 24 2009 1 3 24 2009 1 4 24 2009 1 5 23 then, apply criteria counts , retrieve logical i

visual studio - Why is #region a directive and not a comment? -

i assume #region ignored , dropped compiler, why preprocessor directive rather kind of comment structure (like //region name: stuff(); //endregion name or something.) there particular reason decision make directive made? i know it's not direct answer that's how it's laid out in c# language spec (§2.5). the pre-processing directives provide ability conditionally skip sections of source files, report error , warning conditions, , delineate distinct regions of source code. i don't think it's ignored compiler, doesn't have effect. it's still considered conditional compilation lexical processing point of view and, therefore, in line of other pre-processing directives. spec: the lexical processing of region: #region ... #endregion corresponds lexical processing of conditional compilation directive of form: #if true ... #endif

ruby - How do I write a unit test for a method which removes characters from a text file? -

i need unit test method removes special characters , , : , blank spaces. the method under test stores each line of file in separate array position. how test if method removed special characters of text file? write file after method call , use regex ensure there no special characters don't want. or compare file contents against file contains result wish achieve.

sql - Summing up columns from two different tables -

i have 2 different tables firewalllog , proxylog. there no relation between these 2 tables. have 4 common fields : logtime     clientip     bytessent     bytesrec i need calculate total usage of particular clientip each day on period of time (like last month) , display below: date        totalusage 2/12         125 2/13         145 2/14         0 .               . .               . 3/11         150 3/12         125 totalusage sum(firewalllog.bytessent + firewalllog.bytesrec) + sum(proxylog.bytessent + proxylog.bytesrec) ip. have show 0 if there no usage (no record) day. need find fastest solution problem. ideas? first, create calendar table. 1 has, @ least, id column , calendar_date column, , fill dates covering every day of every year can ever interested in . (you'll find you'll add flags weekends, bankholidays , sorts of other useful meta-data dates.) then can left join on table, after combining 2 tables union. select calendar.calend

How to communicate real-time data between Java and C++ code? -

my application includes 2 devices - phone , cpu. phone transferring data laptop @ low latencies (milliseconds). both can assumed have wifi. what existing software should accomplishing task? example applications should at? cheers something rabbitmq or zeromq worth look. think looking messaging layer / protocol provides native client both java , c++, , can handle (or let handle in client code) serialisation issues correctly related platforms (endian-ness primary issue at).

java - Do I need to override hashCode when using a Set with a Hibernate many-to-many relationship? -

if have many-to-many relationship hibernate, , both sides store collection in set, , set initialized hashset, need override hashcode types stored in set? my gut says no, since hibernate replace initial hashset own set. sometimes/always/never correct? i think should override hashcode() , equals() cause it's set , , don't break contract. sortedset use comparable instead . overriding equals , hashcode in hibernate

Can you use older version of MySQL with Heroku? -

is possible use older version of mysql heroku? specifically server version: 5.0.88-community-nt thanks! you may have install mysql2psql reference migrated data, believe, no (on older version). heroku deems best use postgre. thing think of heroku add-on mysql. https://devcenter.heroku.com/articles/heroku-mysql

symfony - Class Not found in AppKernel.php -

i'm trying deploy symfony2 project. when run command php app/console cache:clear --env=prod --no-debug i following error: php fatal error: class 'acme\mainbundle\acmemainbundle' not found in /var/www/html/app/appkernal.php on line 24 this in appkernal.php public function registerbundles() { $bundles = array( ... new acme\mainbundle\acmemainbundle(), ); ... } it seems there's problem namespace? if getting bundle not found error in symfony, in composer.json, modify psr-4 section under autoload section this. "autoload": { "psr-4": { "": "src/" }, }, by doing so, don't have explicitly add new bundle namespaces when create new bundle.

xml - Show apk version before installation in Android -

i want show android application version user before installation. can suggest way can show application version user before installation? the way have displayed on play store page app.

html - is horizontal scolling website a good idea?, -

might not legal question here on stack.i googled it,even ask bing .. there's no response .. making website horizontally scrolled .. idea?? worried because websites navigated vertically. moreover basic code making navigation thought be <div id="hori_canvas" style="width:auto;height:800px;overflow:scroll"> // here ajaxly insert divs float left , width(auto) </div> as user not.....:)

Time increase when offline SetInterval jquery -

i have scenario according when user user online @ every 3 or 4 sec request sent server, problem start when user go offline scenario want increase time of setinterval method of jquery have written code it, no success yet:- my code this var interval= function(){ if(hasinternets()){ var inter= 15000; return inter; } else { var inter= 15000; inter+= 15000; return inter; } }; setinterval( function(){ if (hasinternets()) { // here doing } }, interval()); hasinternet method check internet connection. so if guys can me, in advance. since function in javascript objects, can assign inter field object stored between function calls: var interval = function(inter) { if (!interval.inter) { interval.inter = 15000; } if (hasinternets()) { return interval.inter; } else { interval.inter += 15000;

java - Running matlab in background with an interface -

i have matlab script , build interface using other programming language, user enter 2 numbers using interface , chose operation wants perform, want matlab run , perform operation on input user input , give output of operation on interface not want build gui using matlab since want use program in devices not have matlab ( i'll using matlab running engine ) there anyway can using c++, python or java ? a matlab command can executed in background following line: matlab -nosplash -nodisplay -nodesktop -minimize -r "run [your_script_path]; exit" with configuration, can run script without display , console closed. however, option has opening/closing time overhead , 2 more feasible options can be: using scripting language light weight python or implementing gui directly in matlab.

jpa - It is possible to override properties in a persistence.xml that is located in a jar dependency -

i have java-ee web application uses persistence unit packaged jar dependency (entity classes, ejb repositories, persistence.xml). in order acceptance tests running web application need override property in packaged persistence.xml. specific need disable default active eclipselink shared object cache setting following property. <property name="eclipselink.cache.shared.default" value="false"/> this necessary because acceptance tests directly prepare/cleanup database dbunit. these modifications put eclipselink cache in stale state (because persistence unit not involved in these modifications). is there way in java-ee (or glassfish specific) override properties in persistence.xml located in jar (starting web application war file, deployed when running tests)? there may other ways, example building jar dependency specific test deployment, route seems complicated me override 1 property in persistence.xml. you can pass properties map persisten

Is there a CSS property which acts like android XML "wrap content"? -

in particular have gwt project textarea element want conform set width , expand as needed bottom. listbox element want conform set width , expand vertically show entirety of displayed list item. those 2 widgets using replaced elements : <textarea> , <select> respectively. for textarea , there's no way make "resize automatically" other listening events , computing new size (there's no need compute new size, can let browser it; see http://phaistonian.pblogs.gr/expanding-textareas-the-easy-and-clean-way.html ) for listbox , it's impossible have items' text wrap. see word wrap options in select list similar question in pure js.

java - Servlet Excel Download not working in IE8 -

i using code site http://www.java-forums.org/blogs/servlet/668-how-write-servlet-sends-file-user-download.html for downloading excel file server. working fine firefox,chrome not working in ie8. can 1 me fix? note: not showing error in ie8.

jquery mobile - Background color of body using CSS not reflecting on html page -

i trying change background color of html page not reflecting. using jquerymobile, marionette pages. in css have written body { background-color:rgb(44,2,4); } even had tried html, body { background-color:rgb(44,2,4); } what happens background color being set, can see on html page flash when pages loads after default jquerymobile theme gets set. can please me solution? in advance. when working jquery mobile must change class .ui-page if want change background color. if change body background !important still stay hidden because class .ui-page acts overlay on whole page. even more must done overriding, this: .ui-page { background:rgb(44,2,4) !important; } working example: http://jsfiddle.net/6wd7v/ edit : found it. using panel uses additional overlay div on .ui-page . this css work now: .ui-page, .ui-panel-content-wrap { background:rgb(44,2,4) !important; }

how can I know how many time take my google script to run -

i have multiples script running spreadsheet. want know how many time take script finish in sec. i needs information find way tunned these script. i know question simple don't know how ? take @ execution transcript after running script. click view -- execution transcript in script editor

Buy & try in windows Phone 8? -

is possible make buy & try options in windows phone 8 in windows store apps. one of game in windows store full access 1 week day of download. after windows store locks game(if give 1 week in dashboard). like that, windows phone 8 having of features. . http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh286402(v=vs.105).aspx#bkmk_runningtheapplication even tried buy & try using above link. i changed checklicense() below. private void checklicense() { if debug string message = "this sample demonstrates implementation of trial mode in application." + "press 'ok' simulate trial mode. press 'cancel' run application in normal mode."; if (messagebox.show(message, "debug trial", messageboxbutton.okcancel) == messageboxresult.ok) { _istrial = true; } else { _istrial = false; }

php - How to join 3 tables in codeigniter -

i have 3 tables: tbl_events --> primary key = event_id tbl_event_bids --> (event_id in no primary key) tbl_users --> primary key = u_id i want these fields: tbl_events --> added_date tbl_events --> bid_end_date tbl_events --> event_date tbl_event_bids --> bid_amount tbl_users --> u_fname tbl_users --> u_lname there no error array empty. there error in code? please help... public function get_confirmed_events($loged_user_id){ $this->db->select(' tbl_events.event_name, tbl_events.added_date, tbl_events.bid_end_date, tbl_events.event_date, tbl_event_bids.bid_amount, tbl_users.u_fname, tbl_users.u_lname'); $this->db->where('tbl_events.u_id', $l

php - How to handle a 1:n relation in smyfony2 forms? -

i need project translated entities , easy way maintain content. 1 "myentity" can have many "myentity_trans". this easy far, need dynamic form in easy way without changing in symfony2 default behaviour. when create/edit "myentity", need "myentity_trans" subform every language. there common way handle this? my entities example: myentity - id - status myentity_trans - id - myentity_id - language_id - ... language - id - name edit 1: here form configuration works on edit, if got related entities: $builder ->add('name') ->add('trans', 'collection', array( 'type' => new retailertranstype(), 'allow_add' => true, 'allow_delete' => true )); now empty forms every possible language, user can easy create translations. tried use query builder, don't work collection type. you should either use gemo\doctrineextensions\transla

python - is it possible to change working directory when executing a .py file in different folder? -

for example,here directory tree: +--- test.py | +--- [subdir] | +--- another.py test.py: import os os.system('python subdir/another.py') another.py: import os os.mkdir('whatever') after running test.py ,i expected have folder whatever in subdir ,but got is: +--- test.py | +--- [subdir] | | | +--- another.py | +--- whatever the reason quite obvious:working directory hadn't been changed subdir .so possible change working directory when executing .py file in different folder? note: any function allowed, os.system example os.system('cd xxx') , os.chdir not allowed edit: decide use context manager,following answer in https://stackoverflow.com/posts/17589236/edit import os import subprocess # call arbitrary command e.g. 'ls' class cd: def __init__(self, newpath): self.newpath = newpath def __enter__(self): self.savedpath = os.getcwd() os.chdir(self.newpath) def __

java - Multiple akka system in a single pc -

how can run multiple akka nodes in single pc? currently, i've following in application.conf file. each system, added different port numbers, but, can't start more 1 instance. error says, address in use failed bind . application.conf file remotelookup { include "common" akka { remote.server.port = 2500 cluster.nodename = "n1" } } update : multiple akka nodes means, have different different stand alone server application, communicate remote master node using akka. the approach using is: create different settings in application.conf each of systems: systemone { akka { remote { enabled-transports = ["akka.remote.netty.tcp"] netty.tcp { hostname = ${public-hostname} port = 2552 } } } } systemtwo { akka { remote { enabled-transports = ["akka.remote.netty.tcp"] netty.tcp { hostname = ${public-hostname} port = 2553 }

entity framework - How to use stored procedure in Linq-to-Entities -

i working entity framework i want know how can use stored procedures in linq-to-entities. stored procedure called selectemployee , table name employee for added code this databaseentity entities = new databaseentity(); var selectdata = entities.executestorequery<employee>("selectemployee").tolist(); but not supported executestorequery so please guide me how can use stored procedures in linq-to-entities in simple steps: add stored procedure edmx. you find sp in model browser right click on stored procedure , add function import use entities.selectemployee()

vb.net - Applying a .docm template to existing .doc/.docx files in MS Word, is it possible? -

i have vb.net program opens word documents, performs mail merge , saves them different location. attempting allow user decide when want save document via adding button ribbon in word calls macro this. i've created docm template adds button ribbon in word 2007/2010/2013. on attempting open doc/docx file word open in new window lacks ribbon modification imposed template. i wondering if knew of way programmatically apply template existing document short of opening docm file , pasting in text doc/docx file? if understand correctly, macro (button) part of template , visible far open document using/based on template. so, opening existing document based on template (that doesn't define macro) not show macro button. "applying new template existing documents" doesn't makes sense because templates have role when new document born. @ moment styles, content gets copied template new document , after connection template lost . i not see other solution other c

openaccess - Setting ID from related table in Telerik Open Access ORM -

i'm quite new using openaccess please bear me. i have table called messages has column called messagetypeid, available ids in table called messagetypes, how can programmatically obtain id specific messagetype , assign new message object i'm creating. there 2 possible solutions getting existing messagetype object associated new message 1 - please find them below: 1) associate them directly whole object using navigation property recommended approach - please find example below: using (entitiesmodel db = new entitiesmodel()) { message message = new message(); // existing messagetype database e.g. first 1 or // db.messagetypes.first(mt => mt.name == "thenameyouarelookingfor"); messagetype messagetype = db.messagetypes.first(); message.messagetype = messagetype; db.add(message); db.savechanges(); } 2) associate them using id of existing object below: using (entitiesmodel db = new entitiesmodel()) { message messa

android - Why is category HOME required? -

this question has answer here: purpose of using category_home in android manifest? 2 answers i have these categories defined in application manifest file: <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.home"/> <category android:name="android.intent.category.launcher" /> </intent-filter> if remove line - <category android:name="android.intent.category.home"/> it not affect part of application functionality , can see application in home screen launcher list of android device. however, if remove last line - <category android:name="android.intent.category.launcher" /> i see change application gets disappeared home screen launcher list of android device. so question what's purpose of

pom.xml - dom4j maven missing artifact -

i'm having problem dom4j in pom.xml. <dependency> <groupid>org.dom4j</groupid> <artifactid>dom4j-1.4</artifactid> <version>1.4</version> <type>jar</type> <scope>compile</scope> </dependency> is annotated "missing artifact org.dom4j:dom4j-1.4:jar:1.4". here's pom: <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>com.netline.edu</groupid> <artifactid>eduruleschange</artifactid> <version>1.0-snapshot</version> <packaging>war</packaging> <name>eduruleschange</name> <properties> <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>

java - Getting an error when connecting from android to PHP server -

i have android application project connect php server write in codeigniter. my jsonparser is: package com.example.com.tourism; import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstream; import java.io.inputstreamreader; import java.io.unsupportedencodingexception; import java.util.list; import org.apache.http.httpentity; import org.apache.http.httpresponse; import org.apache.http.namevaluepair; import org.apache.http.client.clientprotocolexception; import org.apache.http.client.entity.urlencodedformentity; import org.apache.http.client.methods.httpget; import org.apache.http.client.methods.httppost; import org.apache.http.client.utils.urlencodedutils; import org.apache.http.impl.client.defaulthttpclient; import org.json.jsonexception; import org.json.jsonobject; import android.util.log; public class jsonparser { static inputstream = null; static jsonobject jobj = null; static string json = ""; // constructo

javascript - Is there any JS library to obscure string manipulation? -

i'd make string manipulation obscured possible. now wrote small function made hex string original string (the length of result twice length of original). after uglification code simple understood hacker. is there library convert string self (= not made changes or made minor changes original) obscured code? may these tools might you: javascript obfuscator javascript encoder javascript & jquery obfuscator tool

php - My android app does not receive json object -

i have been developing android application retrieve data mysql database wrote php script extract data database , encoded results json , when tested php script generated clear json array objects in it. in android app wrote codes grab json array , extract data failed different trials, started grab errors , discovered content being received application text/html , not application/json should expect. magic comes when check content type of php script google chrome browser clicking menu>tool>developer tools, shows content type application/json set. so stuck in mate , final year project, don't know out of mess. here log shows content type being received text/html 03-21 09:29:18.187: d/connection success(791): content type: content-type: text/html here php script <?php $connection = connect(); function connect() { $dbhost = 'localhost'; $dbuser = 'user'; $dbpassword = 'password'; $con = mysql_connect($dbhost, $dbuser, $dbpassword); if

mutex - Mutual Exclusion case -

hi have following question: i have multi-threaded server can receive multiple requests @ same time. server manages session list. when request received, thread handling request has identify if session open (in session list) demanding client, or open new 1 in case client hasn't session open yet. far good. protect session list mutex when request comes in, list locked, browsed till according connection found , unlocked , pointer session returned (in order). now question: considering multiple requests can received same client (and of them have treated), best practice protect sessions (knowing operations possible on sessions modify session info session can deleted request)? example: 2 incoming requests. first request locks list, finds session, unlocks list , gets session. second request same after list has been unlocked. both have handle same session. problem: if 1 of request meant close session? other request have handle session not aware has been closed (and deleted).

oop - Convert IList<Interface> to List<Class> -

list<currentelectionservice> result = new list<currentelectionservice>(); result = oelectionsmanager.getcurrentelectionsbyeid( employeeid.stringtoguid(), planyear) list<currentelectionservice>; public class currentelectionservice : icurentelection { // implement interface fields here } the method getcurrentelectionsbyeid returns me ilist<icurentelection> , want cast interface class currentelectionservice , returns null. please help. why not use linq perform cast list<currentelectionservice> result = oelectionsmanager.getcurrentelectionsbyeid( employeeid.stringtoguid(), planyear).cast<currentelectionservice>().tolist(); i hope helps.

git alias - Git config file local variables -

i have set of aliases different type of logs, like: lg = log --graph --pretty=format:'%c(cyan)%h%creset -%c(yellow)%d%creset %s %cgreen(%cr) %c(red)<%an>%creset' --abbrev-commit --date=relative unreleased = !git --no-pager log --graph --pretty=format:'%c(cyan)%h%creset -%c(yellow)%d%creset %s %cgreen(%cr) %c(red)<%an>%creset' --abbrev-commit --date=relative release..master there many type of log aliases, of them share same format. how can define local variable content of common parts? ideally, avoid using environment variable that as per this question , git-config doesn’t support expansion of variables. can do, however, define alias common parts: lg = log --graph --pretty=format:'%c(cyan)%h%creset -%c(yellow)%d%creset %s %cgreen(%cr) %c(red)<%an>%creset' --abbrev-commit --date=relative then define further aliases shell commands use common alias: unreleased = !git --no-pager lg release..master incidentally, specifyi

c# - Reporting product fulfillment with Windows Phone 8 -

my wp8 app has in-app purchase consumable item. it's understanding must report fulfillment of product marketplace upon delivery of item. so question is, happens if can't? if there's no internet connection example. any example code i've seen retrieve product listing, call requestproductpurchaseasync , straight after reportproductfulfillment basically want both succeed or neither... if requestproductpurchaseasync succeeds mean customer charged, if don't report fulfillment? or should checking currentapp.licenseinformation relevant license, , if isactive true i'm safe assume purchase successful , should report fulfillment. need way of knowing if fulfillment successful can try again if need be. hope makes sense, if has ideas or can point me in direction of material read i'd appreciate it. thanks. this how it: if there no network, u won't proceed purchase experience or user cancels purchase requestproductpurchaseasync throw excepti

c++ - Object Instantiation in c ++ with a protected constructor -

i have c++ class , want initialize object of type: class myclass { public: /** * creates instance of class. * @return pointer created object. */ static myclass * create (); protected: // explicit protected constructor //and copy-constructor, use create() create instance of object. myclass(); } to create instance, did this: static myclass * m_object = myclass.create(); but got warnings , errors: warning c4832: token '.' illegal after udt 'myclass' error c2275: 'myclass' : illegal use of type expression error c2228: left of '.create' must have class/struct/union how instantiate object? in c++, static variables/methods access using scope resolution (::) operator. change code to static myclass * m_object = myclass::create();

access vba - Make middle of Word sentence BOLD only -

i have access 2010 database within need create letters (word docs). parts of letter in bold, when try set makes preceding text on same line bold well. don't think find work in situation (i've found plenty of examples of formatting using find!), data changes; might possible, fiddly determining starts , ends. can, however, capture data in distinct blocks process have tried this... with oparagraph .range.text = scontent .range.insertafter (spreviewletter) .range.insertafter (sectext1) .range.collapse (wdcollapseend) end with oparagraph .range.insertafter (sectext2) .range.bold = true end with oparagraph .range.insertafter (sectext3) end with nothing seems working correctly me i'm hoping quite simple in reality. in snippet above, i'd sectext2 bold, not sectext1 or sectext3. help! ok, maybe bit of bodge or better programming, i'm afraid don't know gave me needed... oparagraph.range.select selection.typ

javascript - Dynamic CSS with SQL and PHP -

i have hit wall one, here scenario: user 1 clicks not available, div backgrounds gets set red , updates on elses screen. css: #user1 { background-color: green; <--the 1 need change. height: 40px; width: 40px; margin-left:-8px; margin-top:-8px; } html: <!doctype html> <html> <head><link href="css/html.css" rel="stylesheet"><meta http-equiv="refresh" content="5"></head> <body> <div id="user1"></div> </body> </html> so question how can go reading css value sql database? can write fine, thats not problem, how update value read everyone. thanks help. you can use dynamic php-css file , use cache store temporary (so request count can saved) create php file , set header content type text/css header("content-type: text/css; charset: utf-8"); //your sql queries goes here