Posts

Showing posts from August, 2012

asp.net mvc - Prevent XSS attacks and still use Html.Raw -

Image
i have cms system using ck editor enter data. if user types in <script>alert('this bad script, data');</script> ckeditor fair job , encodes correctly , passes &lt;script&gt;alert(&#39;this bad script, data&#39;)&lt;/script&gt; server. but if user goes browser developer tools (using inspect element) , adds inside shown in below screen shot when trouble starts. after retrieving db when displayed in browser presents alert box. so far have tried many different things 1 them encode contents using antixssencoder [ httputility.htmlencode(contents) ] , store in database , when displaying in browser decode , display using mvchtmlstring.create [ mvchtmlstring.create(httputility.htmldecode(contents)) ] or html.raw [ html.raw(contents) ] may expect both of them displays javascript alert. i don't want replace <script> manually thru code not comprehensive solution (search "and encoded state:"). so far have referre

sql server - T-SQL Fewest Sets of Common Dates that Includes All Row IDs -

my table (@mytable) list of ids start dates , end dates (inclusive) represent interval of days when id appears in file received once per day: id start_date end_date 1 10/01/2014 12/15/2014 2 11/05/2014 03/03/2015 3 12/07/2014 12/09/2014 4 04/01/2015 04/15/2015 each id appears once, i.e. has 1 associated time interval, , intervals between start_dates , end_dates can (but not necessarily) overlap across different ids. need sql query find sets of dates each id appear @ least once when files these sets of dates merged, in smallest number of dates possible. in table above solution these 2 dates: file_date id(s) 12/07/2015 1,2,3 04/01/2015 4 but example 1 date between id(3)'s start_date , end_date & combined 1 date between id(4)'s start_date , end_date solution. the actual data consists of 10,000 different ids. date range of possible file dates 04/01/2014 - 07/01/2015. each daily file large in size , must downloaded m

asp.net - Cookie not getting created when redirecting? -

i have following in controller: public actionresult login(string email, string password) { /* stuff ... */ httpcookie customercookie = new httpcookie("customer"); customercookie.values.add("firstname", customer.firstname); customercookie.values.add("lastname", customer.lastname); customercookie.values.add("email", email); customercookie.secure = true; response.cookies.add(customercookie); return redirecttoaction("ordertype", "order"); } but reason when cookie found after redirect. based on this question assuming method above work. can see why cookie not being created here? some troubleshooting steps take: remove redirect , return empty view , see if cookie there do not set secure true , see if that's issue force response flush see if there's action filter or post action execution that

javascript - Windows resize event not properly detected -

i have navigation menu should stay fixed @ top of page using sticky.js plugin window-widths equal or larger 992 px. smaller windows, should go flow of site. now, responsive website, implement dynamic window width detection when window resized. the following code not seem correctly detect resize event. have reload page stick / unstick navbar @ correct width: $(document).ready(function() { var currentwindow = $(window); function checkwidth() { var windowsize = currentwindow.width(); if (windowsize >= 992) { // sticky.js $('.navbar').sticky({ topspacing: 0, getwidthfrom: '.upper-header', responsivewidth: true }); } else { alert('window smaller'); } } // execute on load checkwidth(); // bind event listener $(window).resize(checkwidth); }); would appreciate guidance. you need unstick navbar when window shrinks. $(document).ready(function() { var c

How can i split a string by dot, comma and newline with removing whitespaces by using regex in javascript? -

i have string this: what, inclined to, hi . hello i want split this: ["what","be inclined to","hi","hello","where"] currently i'm using regex doesn't work want: input_words.val().replace(/^\s*|\s*$/g, '').split(/\n|\s*,|\./); split function alone enough. below regex split input according 1 or more commas or dots or newline characters along preceding or following 0 or more spaces. var s = "what, inclined to, hi . hello\nwhere"; alert(s.split(/\s*[,\n.]+\s*/))

c - working with pointers struct automatically updated -

i have product sales management program have structure storing product data, store customer data , store sales data. when insert new sale has associated existing product serial number , id of existing customer. how guarantee when data products , customers struct changed sales struct updated? here's have: typedef struct{ char serialnumber[10] char description[100] float price }stproducts; typedef struct{ int id; char name[50] char adress[100] int phonenumber }stcustomers; typedef struct{ int idcustomersale; char serialnumberproductsale[10] float endprice; }stsales; int main() { stproducts pr[1000]; int countproducts =0; stcustomers cust[500]; int countcustomers=0; stsales sal[1000]; int countsales=0; } part of function insert sale: void insertsale(stsales sal[], int *countsales, stproduct pr[], int countproduct,stcustomers cust[], int countcustomers) { char psale[10]; int number; consultproducts(pr, countproducts); consultcustomers(cust,countc

ios - Size Class Customization in UITableViewCell -

Image
i have height constraint in uiimageview contained in uitableviewcell, , want 180 iphone , 300 ipad. but doesn't make effect ipad. it table view automatic dimension. - (void)configuretableview { self.tableview.allowsselection = no; self.tableview.estimatedrowheight = 30.f; self.tableview.rowheight = uitableviewautomaticdimension; } how can customize cell's height ipad? update: fixed implementing delegate method: - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath { cgfloat height = -1; if (indexpath.section == kquizcontrollersection_description && indexpath.row == kdescriptionquizcell_previewimage) { if (ui_user_interface_idiom() == uiuserinterfaceidiompad) { height = 400; } else { height = 180; } } return height; } because other cells resized dynamically (cells multiline labels) method returns negative number every other ce

c++ - Cannot connect signal from base class -

when try connect base class signal, qt tells me signal not exists on derived class. why that? how can tell connect use base class? namespace mynamespace { void register(derived* derived) { // error msg // qobject::connect: no such signal mynamespace::derived::basesignal() qobject::connect( derived, signal(basesignal()), foo, slot(fooslot())); } class base : public qobject { q_object signals: void basesignal(); }; class derived : public qobject, public base { q_object signals: void derivedsignal(); }; } // namespace mynamespace it better in form: namespace mynamespace { class base : public qobject { q_object signals: void basesignal(); }; class derived : public base { q_object signals: void derivedsignal(); }; void registerx( derived* derived ) { qobject::connect( derived, signal(basesignal()), foo, slot(fooslot())); } } // namespace mynamespace as this post s

php - Toggle links for crawler and guest visitors -

i need display 2 different links crawler , guest. example: crawler see normal link - <a href="example.com">example.com</a> guest see link - <a href="other.com/register">register see link</a> // check user agent of current 'visitor' if($detect->iscrawler()) { // true if crawler user agent detected }else{ // false } for part, can determine if site being crawled looking @ 'user-agent' header: function iswebcrawler() { $iscrawler = false; $useragent = $_server['http_user_agent']; if(strlen(strstr($useragent, "google")) <= 0 ) { $iscrawler = true; } return $iscrawler; } here listing of user agent strings of major bots: list of web crawler user agents

sql server - Select row where all records with similar row meet condition -

i have table many records, example.. id | user id | date 1 | 1 | 2014-05-26 2 | 1 | 2015-05-08 3 | 2 | 2014-05-20 i trying select user_id records date more 6 months passed, dont include them if there record same user_id not meet criteria. example, want return record user id 2. my issue can select user_id table datediff(month, date, getdate()) > 6 but still return record user_id 1. sure super easy have not been able make progress on this. just take statement , take other away: userswithyoungerdates ( select user_id table datediff(month, date, getdate()) <= 6 ) select user_id table datediff(month, date, getdate()) > 6 , user_id not in(select user_id userswithyoungerdates)

sitecore - Need a page that shows all articles that are published within a folder -

in sitecore, have folder full of articles. update these every quarter. have go page , manually link of these articles. want know if there way automatically list these articles on page. example, if folder has 10 articles, 9 publishable, main landing page show 9 published articles, not 10th one. make sense? sure can manually this, there has way make more automatic. okay, let's go through in more detailed view - couple of notes mark's answer. in real production environment have @ least 2 servers - authoring (content master or cm) , content delivery (cd). youк sitecore desktop running on cm , publishes items cd database. have copy of website code running on cm (for @ least doing page previews) , on cd in fact website is. items published come cd database having code above var folder = sitecore.context.database.getitem("your-folder"); var children = folder.getchildren(); running on cd iterate through published items there (those 9 of 10). same code runn

c# - Suggestion on deciding the architecture for returning multiple forms from View to Controller ASP.Net MVC -

i want suggestion on how following. in asp.net mvc application have view can accessed unauthorized , view have registration form requirement there can register multiple people. so example if event can have 2 persons registered need show 2 registration form , detaisl should filled , press submit whole data should validated , passed controller. i not understand how this. is possible have viewmodel like: public class regviewmodelcollection{ public list<registerviewmodel> collection{get;set} } ? please suggest. thanks

java - How can i configure deltaSpike data in a EJB module? -

i'm new using deltaspike data, idea work spring-data cdi , ejbs. created example in java web project , test successful, need same thing in ejb module, doesn't work. know if necessary additional configuration make work deltaspike data in ejb module? i used tutorial in link: http://deltaspike.apache.org/documentation/data.html sorry english, i'm still learning.

Converting time efficiently in Python -

i have program parsing , takes in time in microsecond format. however, when reading data, it's not pretty see 10000000000 microseconds. x seconds, or x minutes, looks better. so.. built this: def convert_micro_input(micro_time): t = int(micro_time) if t<1000: #millisecond return str(t) +' us' elif t<1000000: #second return str(int(t/1000)) + ' ms' elif t<60000000: #is second return str(int(t/1000000)) + ' second(s)' elif t<3600000000: return str(int(t/60000000)) + ' minute(s)' elif t<86400000000: return str(int(t/3600000000)) + ' hour(s)' elif t<604800000000: return str(int(t/86400000000)) + ' day(s)' else: print 'exceeded time conversion possibilities' return none now, in eyes, looks fine, however, boss wasn't satisfied. said numbers confusing in terms of readability if

c++11 - I am trying use vlog inside static lamba giving me error: statement-expressions are not allowed outside funstions nor in template-argument lists -

i wrote global static lambda following: static auto x = [] (const std::string& y){ vlog(3) <<" y:" <<y; }; it giving me error on vlog statement.: statement-expressions not allowed outside functions nor in template-argument lists this result of decision made leave room optimizations. relevant bug report here in attempt reopen discussion, , mentions type of use case. compiling without optimizations should work, though know that's lame suggestion. problem lambda being @ global scope, solution brings function should good.

c++ - How to calculate Frame Per Second in opencv? -

here code display video @ high fps. want original fps here don't know how it. watching tutorials , using videocapture , tried use giving me linker error undefined reference 'cv::videocapture::videocapture(std::string const&)'.. though linking libraries error same. using dev-c++ 5.11 (gcc 4.9.2) , idea how use (cv_cap_prop_fps) here - #include <windows.h> #include <opencv/cv.hpp> #include <opencv/highgui.h> using namespace cv; using namespace std; int main( int argc, char** argv ) { double fps=0; cvnamedwindow( "movie", cv_window_normal ); cvcapture* capture = cvcreatefilecapture( "g:\\movie\\journey.2.the.mysterious.island.2012.avi" ); iplimage* frame; //cv::videocapture cap("g:\\movie\\journey.2.the.mysterious.island.2012.avi" ); [giving me error] //fps=cap.get(cv_cap_prop_fps); [how use this] while(1) { frame = cvqueryframe( capture ); if( !frame ) break; cvshowima

javascript - Total table column with jquery function -

i have found on site jquery function updating table row. need total column. anybody? i,m not familiar jquery , tried lot of things don't working. fiddle: http://jsfiddle.net/heliosh/r7dvay4o/ js $(document).ready(function () { function updatearticle1() { var persons = parsefloat($("#dare_price1").val()); var total = (persons) * 2.00; var total = total.tofixed(2); $("#total_price_amount1").val(total); } $(document).on("change, keyup", "#dare_price1", updatearticle1); }); $(document).ready(function () { function updatearticle2() { var animals = parsefloat($("#dare_price2").val()); var total = (animals) * 3.50; var total = total.tofixed(2); $("#total_price_amount2").val(total); } $(document).on("change, keyup", "#dare_price2", updatearticle2); }); $(document).ready(function () { function updateartic

MongoDB Increment or Upsert -

given following document structure: { '_id': objectid("559943fcda2485a66285576e"), 'user': '70gw3', 'data': [ { 'date': isodate("2015-06-29t00:00:00.0z"), 'clicks': 1, }, { 'date': isodate("2015-06-30t00:00:00.0z"), 'clicks': 5, }, ] } how can increment clicks value of 2015-06-30 , increase if doesn't exists [the whole document or specific date], make equals 1 ? unfortunately not possible achieve goal within single query. instead can following var exists = db.yourcollection.find( {'_id': objectid("559943fcda2485a66285576e"), 'data.date': <your date>} ).count() this query return number of documents have specified _id , object specified date in data array. _id field unique, @ 1 result. i

Search for and replace characters in a string in assembly nasm issues -

i've got working copies string another. i'm trying make search term , swap it. reason, if replace function isn't commented, somehow manages delete output in console (literally goes backwards!). if comment replace function out, exact copy. trying change cat dog. bits 64 global main extern printf section .text main: ; function setup push rbp mov rbp, rsp sub rsp, 32 ; lea rdi, [rel message] mov al, 0 call printf ;print source message lea rdi, [rel source] mov al, 0 call printf ;print target message lea rdi, [rel target] mov al, 0 call printf lea rdi, [rel target] lea rsi, [rel source] cld jmp loop loop: lodsb ;load byte @ address rsi al stosb ;store al @ address rdi ;push [rdi] cmp byte rdi, 'c' je replace ;pop [rdi] test al,al ;code jump if al not equ 0 jnz loop

Should debugging code be left in place? -

is leaving debugging code in place discouraged practice? for example, program (written in java) i'm working on can send emails. there various ways emails failed send handled. in method send in email class, pass boolean argument boolean fail which, if true, causes method fail. allows me test whether emails failed send correctly handled. i have other instances of throughout program well. obviously, in final production code program told fail. there harm in leaving these debugging tools in place in case corresponding features ever need changed? rather commenting or uncommenting debugging logic, if can set debugging run based on environment variable, leaving in place practice. come in handy (or else) down road. in future you'd simple set debugging true see debugging logic, , in production, you'd set false.

Python Package Building - importing function for use in class definition -

i'm working on building python package wrapper around request package , designed make variety of api calls set of databases easier. currently, package has following directory structure: package\ - __init__.py - corefunc.py subpackage\ - __init__.py - mod1.py - mod2.py the primary functionality of package lies in mod1.py , mod2.py . mod1.py looks this: import requests _requests package.corefunc import __func1 class datapull: def __init__(self, arg1): self._url = "http://www.somesite.com/info?" self._api_param = {'argument':__func1(arg1)} self._pull = _requests.get(self._url, params = self._api_param) def datatableone(self): _headers = self._pull.json()['resultsets'][0]['headers'] _values = self._pull.json()['resultsets'][0]['rowset'] return [dict(zip(_headers, value)) value in _values] def datatabletwo(self): _headers = self._pull.json()[&#

java - BigDecimal constructor performance - string vs numeric -

new bigdecimal("10000"); new bigdecimal(10000); i know string constructor used if number bigger compiler accept, either of constructors faster other? you can @ source code. public bigdecimal(int val) { intcompact = val; } public bigdecimal(string val) { this(val.tochararray(), 0, val.length()); } public bigdecimal(char[] in, int offset, int len) { ...very long } obviously, faster.

visual studio - VS2013 Crash After Pull with Git from command Line -

hi , tks in advance help! i have web app in vs2013 working fine, everytime make pull gitlab repository, can't open solution anymore. workaround have found delete repository , clone scratch. tried popular solution on google (like running git gc before pulling) can't fix it. problem signature: problem event name: clr20r3 problem signature 01: devenv.exe problem signature 02: 12.0.31101.0 problem signature 03: 54548724 problem signature 04: mscorlib problem signature 05: 4.0.30319.34209 problem signature 06: 534894cc problem signature 07: 254 problem signature 08: 10 problem signature 09: system.argumentexception os version: 6.1.7601.2.1.0.256.1 locale id: 3082 additional information 1: 0a9e additional information 2: 0a9e372d3b4ad19135b953a78882e789 additional information 3: 0a9e additional information 4: 0a9e372d3b4ad19135b953a78882e789 read our privacy statement online: http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0

vaadin - How would a user have multiple `VaadinSession` objects for a single `HttpSession`? -

Image
vaadin 7.2 , later offers static method: vaadinsession.getallsessons( javax.servlet.http.httpsession httpsession ) the doc says: retrieves vaadinsessions stored in given http session how user ever have more 1 vaadinsession per httpsession ? happen action performed user, or me programmatically in vaadin app? the vaadinsession stored inside httpsession . multiple vaadin apps in single .war if deployment (a war file ) contains more 1 vaadin applications ( servlets ), , user uses applications simultaneously, user's httpsession contains more 1 vaadinsession objects. for example, war file contains 2 vaadin applications (servlet mappings), , users using both in chrome browser , httpsession user contains 2 vaadinsession objects. if applications deployed on separate war files, there httpsession both applications , both sessions contains 1 vaadinsession .

rest - Mark discourse private message as read via api -

i building bot discourse takes requests via private messages, each request must read once. way planning using get /topics/private-messages-unread/botusername.json , can't seem able mark message read via api. have tried using get /t/(id).json?trackvisit=true , still stays unread. there api function missing?

bukkit - Replacement for getTypeId() -

i made plugin bukkit 1.2.5 (to used on tekkit server) alerted players when (for example) tried place down tnt why using block ids. now i'm trying use updated version of bukkit (1.7.2-r0.3 exact) seems gettypeid() method no longer working. i've googling/searching in javadoc solution can't find one. // checks if block placed has id of 46 / tnt if (e.getblock().gettypeid() == 46) { e.setcancelled(true); server server = bukkit.getserver(); server.broadcastmessage("someone tried place tnt down"); } how work in 1.7.2 gettypeid() deprecated you can still use gettypeid() method blocks or getid() method block material despite fact deprecated. if add @suppresswarnings("deprecation") annotation listener method ide should not complain using deprecated methods. can alternatively use non-deprecated material enum directly event.getblock().gettype() == material.tnt .

.net - Track an instance in C#? -

this question has answer here: when debugging, there way tell if object different instance? 3 answers is there way track single instace in c#/.net in visual studio while debugging? find useful sometimes. another way @ breakpoints on instances rather code. therefore, every time instance accessed and/or modified execution stops , presented line of code accesses/modifies instance. in c++ equivalence monitoring piece of memory instance located, or pointer instance. approach doesn't work managed code objects in .net moved around, therefore need equivalence pointers in c++. i aware of weakreferences in c# not sure if of use while debugging? edit1: question different "when debugging, there way tell if object different instance? " not interested in comparing 2 references, want access single object. there's nothing i'm aware of out of bo

ruby on rails - send_data - open file in new browser window? -

#in controller (works fine) order = order.find(params[:id]) url = order.receipt.file.url data = open(url).read send_data(data, type: 'application/pdf', filename: "appname-receipt#{order.id}", disposition: 'inline') this takes pdf stored in s3, , renders fine in current window. just wondering if knows slick way open in new browser window? the target attribute on anchor ( <a> ) elements can used open linked pages in new window. <a href="#" target="_blank">i open in new window.</a> _blank: load response new unnamed html4 window or html5 browsing context. https://developer.mozilla.org/en-us/docs/web/html/element/a

How to make Android NOT count ListView's section headers? -

i'm using list: https://github.com/bhavyahmehta/listviewfilter , bu found when have 3 rows in 'a' section , 2 in 'b' section - first row in 'b' section has position 5 instead of 4. how can force not count section headers? public int getrealposition(int position){ int sectionheaders = 0; (integer : mlistsectionpos){ if (position > i){ sectionheaders += 1; } } log.i("asd-truepos", string.valueof(sectionheaders)); return position - sectionheaders; } you try override method getcount() pinnedheaderadapter class: @override public int getcount() { return mlistitems.size(); } you return mlistitems.size() - 1 or calculations in order know if header present or not , return correct value. if override, in moment in instantiate class or add java class extends pinnedheaderadapter .

android - Can parent Activity be terminated before onActivityResult is called -

is possible parent activity terminated before onactivityresult() called? if that's case, whatever local variables maintained in parent activity, may not valid (initialized) when onactivityresult() called. i periodically null pointer exception when onactivityresult() called variables set in parent activity, if parent activity had been destroyed before return child activity, these variables no long valid. is possible parent activity terminated before onactivityresult() called? activities not "terminated". activities destroyed. processes terminated. if activity being started via startactivityforresult() in separate app yours, entirely possible process terminated while app in background. see lot action_image_capture , example. also, configuration change can destroy activity part of coming foreground. suppose start in portrait mode. start other activity. user rotates device landscape, presses back. "parent activity" destroyed , recreated.

java - How to give a default value to a List in Scala? -

i have following part of code gives me java.lang.nullpointerexception , found source , know declared variable set null , later in program initialized don't know how give default value without getting error! list accepts 2 different types, float , rdd . here part of code has problem in it: case class rpn (sc:sparkcontext, vp: volumeproperty, var stack:list[either[rdd[(int, array[float])],float]]) { def this(s:sparkcontext,v:volumeproperty) = this(s,v,null); //think here problem def operand(x: either[rdd[(int, array[float])],float]) = new rpn(sc,vp,stack = x :: stack) //gives error on line and getting following error: exception in thread "main" java.lang.nullpointerexception how can solve it! use nil instead of null . nil empty list.

secure coding - learning assembly for security reasons -

where start if want learn assembly security reasons? think if want avoid mistakes, best thing know you're doing. happens if cast signed int unsigned int. once got strange error message, variable isn't correctly aligned. @ time had no idea alignment is. my 2 cents unless find assembly intriguing , have lot of time i'd suggest learn these things: how signed number represented, how floating point numbers represented , data alignment is. i suggest learn assembly fascinating recognize huge effort beginner purpose. learn assembly not learning list of instructions, there no need remember such list. learning assembly means learning every aspect of how computer works, starting hardware datasheet how os implemented. lot of material it hard make list of it , let alone learn it! i started learning assembly teen because fascinated it, there no purpose knowledge. did (and do) fun, made things easy, had not deadlines. have plenty of time learn pieces of puzzle 1

sh - Shell script to delete znodes(Zookeeper) -

i trying create shell script delete znodes. here command: echo "ls /" | zookeeper-client echo "rmr /collections" | zookeeper-client there many such nodes want delete. whenever execute above commands, delete collections node , sometime throws error. reason found whenever run "zookeeper-client" through shell script, takes time zookeeper shell come up. there way can delete such nodes ? any appreciated. thanks. you can delete zookeeper-client rmr e.g zookeeper-client rmr /test

linux - cross compile c program for android -

i have c program uses -lpcap, -lm, , -lpthread. see libraries in /usr/arm-linuxgnueabi/lib/. however, if compile using command arm-linux-gnueabi-gcc -static *.c -l/usr/arm-linux-gnueabi/lib/ -lpcap -lm -lpthread -o dumps/forandroid it gives following error: /usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/ld: cannot find crt1.o: no such file or directory<br> /usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/ld: cannot find crti.o: no such file or directory<br> /usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/ld: cannot find -lpcap<br> /usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/ld: cannot find -lm<br> /usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/ld: cannot find -lpthread /usr/lib/gcc-cross/arm-linux-gnueabi/4.7/../../../../arm-linux-gnueabi/bin/ld: cannot find -lc<br> collect2: error: ld returned 1 exit status

ios - How to programmatically add a label in a custom subview? -

i'm designing card game (cards against humanity) ios, there 2 types of cards, whites ones, , black ones. i've implemented cardview class inherits uiview, , 2 class, whitecardview , blackcardview both inherit cardview. guess, color change between two, still want 2 different view class 2 (even if same @ moment). so, have 4 questions that. edit : mnage find out answer myself, last one, i'm lost. 1.i need advice on implementation, don't know if i'm doing right set colors of cards stored in cardview set in init of whitecardview. think have override 1 init, don't know one. if can confirm or correct did, great. thanks here cardview code: ib_designable @interface cardview : uiview -(void)customdrawui; -(void)setdata; @property (nonatomic) uicolor* ibinspectable secondarycolor; @property (nonatomic) uicolor* ibinspectable primarycolor; @property(nonatomic) uilabel* txtlabel; @end @implementation cardview -(void)customdrawui{ self.layer.cornerradius=

Compiling against android MNC impossible? -

Image
i have follow instructions on https://developer.android.com/preview/setup-sdk.html can't working below error in android studio (update 1.3rc-2) i have tried "minsdkversion mnc", still doesn't work. you should missed single quotes around "android-mnc", should be: compilesdkversion 'android-mnc ', not compilesdkversion android-mnc

Java for loops not populating array correctly -

i have following code: public class solutionstest { public static void main(string[] args) throws filenotfoundexception, unsupportedencodingexception { int allsolutions[][][][][] = new int[16][16][16][16][16]; (int = 0; <= 15; i++) { (int j = 0; j <= 15; j++) { (int k = 0; k <= 15; k++) { (int l = 0; l <= 15; l++) { allsolutions[i][j][k][l][j] = i; system.out.println("set index " + + " " + j + " " + k + " " + l + " " + j + " equal " + i); } } } } system.out.println(allsolutions[4][2][1][4][5]); system.out.println(allsolutions[5][2][1][4][5]); system.out.println(allsolutions[6][2][1][4][5]); system.out.println(allsolutions[7][2][1][4][5]); system.out.println(allsolutions[8][2][1][4][5]); } } th

android - how to query against array of integer -

i query: select * table field1 in (1, 2 ,3); the field1 integer type. field type string be: select * table field1 in ('1', '2' ,'3'); but in android both use selectionars string[]. string[] filter = new string("1", "2", "3"); cursor altocursor = mcontentresolver.query( uri, projection, "field1 in (?,?,?)" + filter, null); how different field type string , field1 type of string . query same, how know if "1" in string[] integer or string : string[] filter = new string("1", "2", "3"); cursor altocursor = mcontentresolver.query( uri, projection, "field1 in (?,?,?)" + filter, null); confused here, anyone's appreciated! typically data type of column querying defined integer or string. database engine not realize if passing string or integer. momen

ios - Using VTCompressionSession as in WWDC2014 -

the documentation on library non-existent, need here. goal: need h264 encoding (preferably both audio , video, video fine , i'll play around few days audio work too) can pass mpeg transport stream. what have: have camera records , outputs sample buffers. inputs camera , built-in mic. a few questions: a. possible camera output cmsamplebuffers in h264 format?i mean, 2014 has being produced vtcompressionsessions while writing captureoutput, see cmsamplebuffer... b. how set vtcompressionsession? how session used? overarching top-level discussion might people understand what's going on in barely documented library. code here (please ask more if need it; i'm putting captureoutput because don't know how relevant rest of code is): func captureoutput(captureoutput: avcaptureoutput!, didoutputsamplebuffer samplebuffer: cmsamplebuffer!, fromconnection connection: avcaptureconnection!) { println(cmsamplebuffergetformatdescription(samplebuffer)) var imagebuffer

java - Is using more JPanels and the use of the setBounds() method okay? -

i have written many simple guis, worked fine. beginner think way of writing user interfaces not practice. is proper practice if 1 uses more panels desired interface? use of setbounds() method good? the less sub-components use, more responsive ui going be. because has less things deal with. i not recommend using 'setbounds` creates inflexible ui in cases. encourage start using layouts such borderlayout , flowlayout etc. versatile of them miglayout here more general information swing layouts: https://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html

executing functions from windows console - python -

i have implemented logic through python functions , looking way calling functions more efficiently. there way calling these functions windows command prompt or python cmd below? python function: def logic1(args) ... want call function this: logic1(args) import file in python console this: from my_file.py import * or from my_file.py import name1, name2 ... now can use these in python console. out same importing files. for calling functions in windows prompt need separate each function own file , use py2exe convert them executables. may overhead of work though, depending on want achieve.

html - Apply a Draggable Container Above Another Absolutely Positioned Element -

Image
i have page contains , iframe points other pages. iframes parent contain search control changes iframe's url. iframe should display max-screen, search control needs lay atop iframe results. i want "always on top" how can achieve this? for instance, html looks like: i've tried messing z-index...with no success. <style> iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 90; } .search { position: absolute; top: 0; left: 0; height: 100px; width: 100px; z-index: 100;} </style> <div class="search> search controls container </div> <div class="container"> <iframe src="~/tours/_default/index.html" allowfullscreen align="center" /> </div> you have missing double-quote after "search . add in , see if helps. tested locally , works me when adding in missing ".

how to set the search results color of ideavim in pycharm? -

recently switch vim pycharm program, , have installed ideavim plugin. works in cases. when search text, finds result, searching result has no highlighting color. eg: typed 'first_pos' in command line, , result shows, no highlighting color in word. (sorry can not post image...) how change search result color of ideavim? thanks. try in console: :set hls taken related question: phpstorm ideavim highlight , jump search term before hitting enter (like sublime text or vim)

loops - Java: How do I return user to main menu if user input is not a single alphabetic lowercase letter? -

i'm trying run program allow user input both char keycharacter , string thestring. then, using these inputs, mask keycharacter if occurs in thestring "$", remove keycharacter thestring, , finally, count number of times keycharacter occurs in thestring altogether. every method working fine, except method getkeycharacter user has input char: user can enter single letter (e.g. q, or z). if user enters other single letter (which can word, phrase, sentence, special character # or $, blank space or tabs, or pressing enter), program returns user original question asks keycharacter user. should continue looping original question until user enters valid input. since i'm still beginner java , loops weakness far, part causing me lot of trouble. know should using while loop, logic behind nested loops confusing me. from searching possible solutions, know there these things called regex , try-catch exception issue, since haven't gone on explicitly in class, i'd

camera - Measure blood pressure with iphone -

recently came across app "instant blood pressure - monitor blood pressure using phone aura labs, inc." https://appsto.re/us/jwiyx.i claims measure blood pressure using camera of iphone. use meditation app called sattva can measure heart rate pretty accurately placing finger against camera. although 2 applications doing different things (pressure vs heart rate), how technology work? i doubt can measure blood pressure using camera. pulse different. measures amount of red colour in skin , finds rate @ changes. blood pressure different though. the way measured doctors apply pressure blood vessels , decrease point blood can heard pulsing , again when can't. without knowing these pressures cannot measure blood pressure (by definition).

android - PreferenceFragment inflated onto CardView -

i'm having difficulty getting layout_height right inflating preferencefragment onto cardview. everything works well, including nestedscrollview collapse toolbar, reason preferences filling first position of list. it's scrollable, needs fill entire card. any ideas on might going on here? edit: it's nestedscrollview causing problem. if can find workaround.. i might not understand cards, since other layouts, can't seem them entirely fill view, minus little bit of margin. here's preferencefragment xml <android.support.v7.widget.cardview xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/tools" android:id="@+id/cardview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:elevation="100dp" android:layout_gravity="center" android:layout_margin=

java - How to get next button in String Array -

in 1 class got string facts in array this: public class factbook { public string[] mfacts = {"a", "b", "c"}; .... now got random generator this: public string getfact() { string fact = ""; random randomgenerator = new random(); int randomnumber = randomgenerator.nextint(mfacts.length); fact = mfacts[randomnumber]; return fact; } my randombutton in activity class this: final textview factlabel = (textview) findviewbyid(r.id.facttextview); final button showfactbutton = (button) findviewbyid(r.id.showfactbutton); final relativelayout relativelayout = (relativelayout) findviewbyid(r.id.relativelayout); final mediaplayer mmediaplayer = mediaplayer.create(getapplicationcontext(), r.raw.button); view.onclicklistener listener = new view.onclicklistener() { @override public void onclick(view v) { mmediaplayer.start(); string fact = mfactbook.getfact(); //update label our dyn