Posts

Showing posts from March, 2015

java - How to sort an ArrayList which contain more than 1000 different Strings on the basis of similairy to another given String -

i have arraylist contains 1000 strings. want sort list on basis of similarity given string outside. strings close string come in top. for eg. have string "beauty , beast". my arraylist contains string like: redwall beauty , beast 3 bluewall beautyqueen i beast of rome ii beauty , beast 1 beast beauty bluewall 2 beautyqueen ii beast of rome i beauty , beast 2 ... so after sorting arraylist, should like.. beauty , beast 1 beauty , beast 2 beauty , beast 3 beast beauty beautyqueen i beautyqueen ii beast of rome i beast of rome ii bluewall bluewall 2 redwall some thing this.. dont know how order going after beauty , beast 3.. should pick string have same string in beginning. i looking algorithm can me in implementing task in java. i have heard using levenstein distance, have no idea on how can used task. any pointers lot of help. i have created custom comparator per need , here's code s search string, matchi

html - enabling/disabling <a> tag through c# code -

i trying enable/disable "a" tag that's in html code through c# code. know if button use, xxx.visible="false/true" guess "a" tag not have features backend code. here have, c#: if (session["sessionusersloginid"] == null) { alreadymemberlabel.visible = true; signinbutton.visible = true; forgotdbutton.visible = true; passwordlabel.visible = true; passwordtextbox.visible = true; right here should disable visibility "login_pop" tags } html: <span style="width:32%; float:right;"> <div class="panel"> <a href="#login_form" id="login_pop">log in</a> <a href= "addusers.aspx" id="login_pop">sign up</a> <span style="width:32%; float:right;"> <asp:button id="forgotdbutton" cssclass

objective c - Correct way to display current date/time in iOS app and keep it up to date -

i'm wondering out of theory/performance side of things, if needed display current date/time in uilabel or something, , keep date (say, down minute), correct way so? i've seen various examples online of "clock" apps have recursive method runs 1 second delay between invocations. option create repeatable timer , add run loop. there variety of other ways well. there 1 way better others? the recursive method not great idea. use nstimer approach. create repeating timer in viewdidappear , invalidate timer in viewdiddisappear (to avoid retain cycle, a.k.a. strong reference cycle). example, assuming have timer property: @property (nonatomic, strong) nstimer *timer; you schedule , invalidate timer follows: - (void)viewdidappear:(bool)animated { [super viewdidappear:animated]; self.timer = [nstimer scheduledtimerwithtimeinterval:1.0 target:self selector:@selector(handletimer:) userinfo:nil repeats:yes]; } - (void)viewdiddisappear:(bool)an

Check if value in input equals a certain value JQuery -

var enter = $('#enter').attr('value'); $('#enterbutton').on("click", function() { if(enter == "enter" || enter == "enter") { $('.loader').fadeout(2000); } }); this code far, tried using: var enter = $('#enter').val(); but still nothing worked, can me fix this? :) edit: html is: <input id="enter" type="text" placeholder="do says..."> <button class="btn" id="enterbutton">go!</button> edit final: the final answer is: $('#enterbutton').on("click", function() { var enter = $('#enter').val(); if(enter == "enter" || enter == "enter") { $('.loader').fadeout(2000); } }); because, variable outside, , not updating button click :) @dystroy you don't update value of enter when click test initial value which, of course, doesn't change.

python - Real world example of using os.plock? -

are there real world usages using os.plock python application? i can't imagine used, not talking real world use cases... the thing use process or memory locking avoid os swapping disk. in case of memlock data used cryptographic purposes shouldn't written (even temporarily) form of more permanent storage. in case of large process, include processes stack, or other "segments" should remain in memory.

json - rails best way to extract values from response hash -

i'm having problems extracting values in response hash call google image search api. i want value url key each result. i figured i'd call deep_symbolize_keys on response , hash.results.url , doesn't work. feel i'm doing stupid, pointers welcome. controller code _url = 'http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=fuzzy%20monkey' _response = net::http.get_response(uri.parse(_url)) @response_hash = json.parse _response.body response hash before keyed stored in @response_hash "responsedata": { "results": [ { "gsearchresultclass": "gimagesearch", "width": "1152", "height": "864", "imageid": "and9gcqqigy-u6ktxke82n5hma5qvfm2uyvnkgtjme6pkzgl_1gym--yb90oqnoj", "tbwidth": "150", "tbheight": "113",

How to call a CUDA file from a C++ header file? -

i know method of calling .cu files .c files. want call .cu files c header file. possible ? if how should make settings of project ? please help..... here's worked example: file1.h: int hello(); file2.h: #include <stdio.h> #include "file1.h" int myfunc(){ hello(); return 0; } file1.cu: #include <stdio.h> #include "file1.h" __global__ void mykernel(){ printf("hello mykernel\n"); } int hello(){ mykernel<<<1,1>>>(); cudadevicesynchronize(); return 0; } file2.cpp: #include "file2.h" int main(){ myfunc(); return 0; } build , test: $ nvcc -arch=sm_20 -c file1.cu $ g++ -c file2.cpp $ g++ -o test file1.o file2.o -l/usr/local/cuda/lib64 -lcudart $ ./test hello mykernel $ assuming intending include file2.h cpp file, cannot call cuda kernel directly header , use in cpp file. must put wrapper around cuda kernel, , call wrapper, have indicated. because cpp file compil

jquery - Click links to load the relevant image into a container -

i have links when click on them, need them load image container, , when click close link, hides again. i have example of here unsure how apply images div link if makes sense: http://jsfiddle.net/sgktv/1/ i assume need along lines of this.... <a class="click" href= "#" src="image/location">click here fadein image in container</a> i going have many links images , container stay same. what best , efficient way start this? thanks! $(function () { $("a.click").click(function (event) { //hide panel in case it's visible because of loaded image $("#hiddenpanel").fadeout(0); //disable default link click event page not change if link has href event.preventdefault(); //set links src src of image in hidden panel $("#hiddenpanel img").attr("src", $(this).attr("src")); $("#hiddenpanel").fadein(1000); });

c++ - How to get an index of a variable from func_interpr entry? -

a function model contains entries of pairs <condition_on_args, return_value> . the return_value expression may refer input arguments, example (f!4 (k!3 (:var 0))) . here (:var 0) refers 0th input argument of function model, , of kind z3_var_ast. i want transform return_value internal program representation, don't know how relate (:var 0) 0th input argument of function model. how index of variable, 0 , expr (:var 0) of kind z3_var_ast via c/c++ api? thanks! you have use following api: /** \brief return index of de-brujin bound variable. \pre z3_get_ast_kind(a) == z3_var_ast def_api('z3_get_index_value', uint, (_in(context), _in(ast))) */ unsigned z3_api z3_get_index_value(__in z3_context c, __in z3_ast a);

html - Div fixed on vertical scroll but absolute on horizontal -

here's want. want top bar , navigation menu attached bar. i've done no problem. want bar , navigation menu follow me if scroll , down.i can position fixed. but, if have fixed position, when scroll left right, follow. i want have both top bar , navigation menu follow user scrolls , down if scroll left right want act absolute position, , become partially or hidden (depending on how user scrolls). is possible? i've seen couple of topics haven't been able work me. here jfiddle http://jsfiddle.net/kyleseitz/rx4vh/11/ i want move down me when scroll down , when scroll up. but, if horizontal scroll bar, want pass viewing window on it. i found javascript on previous question can't work me. .slim {position: absolute;} <div id="phantombar" class="slim"> <!--i technically don't need these if not neccessary--> <div id="phantombar" class="fixed_elem"> <div id="headwrap">

xml - Xpath taking an element comparing others -

i have following xml , i'm not able create correct xpath expression: <previsioni> <previsione data="30/1/2011"> <luogo> <nome>bologna</nome> <periodo t="mattino"> <temp>8</temp> <descrizione>giornata fredda bologna</descrizione> </periodo> <periodo t="sera"> <temp>4</temp> <descrizione>ancora più freddo in serata</descrizione> </periodo> </luogo> <luogo> <nome>firenze</nome> <periodo t="mattino"> <temp>10</temp> <descrizione>giornata fredda e nuvolosa per firenze.</descrizione> </periodo> <periodo t="sera"> <temp>

javascript - align image randomized by function -

this part of code works alright: var cobras=new array(); cobras[0] = '<img src="cobra1.jpg">'; cobras[1] = '<img src="cobra2.jpg">'; cobras[2] = '<img src="cobra3.jpg">'; cobras[3] = '<img src="cobra4.jpg">'; cobras[4] = '<img src="cobra5.jpg">'; cobras[5] = '<img src="cobra6.jpg">'; cobras[6] = '<img src="cobra7.jpg">'; cobras[7] = '<img src="cobra8.jpg">'; cobras[8] = '<img src="cobra9.jpg">'; cobras[9] = '<img src="cobra10.jpg">'; cobras[10] = '<img src="cobra11.jpg">'; cobras[11] = '<img src="cobra12.jpg">'; cobras[12] = '<img src="cobra13.jpg">'; cobras[13] = '<img src="cobra14.jpg">'; cobras[14] = '<img src="cobra15.jpg">&#

jquery - Asp.net mvc 4: $.Get() method call doesn't hit the action inside the controller -

here's jquery code: var url = "@url.action("admin", "editmovie")" + "/" + id; $.get(url, function (data) { alert("data loaded: "); }); and method inside controller public actionresult editmovie(int id) { return partialview("basicmovieinfo", repository.getmoviebyid(id)); } i placed break point inside editmovie action, not being hit. there reason that? you have got parameters in reverse. see urlhelper.action . first parameter action name , second controller name . assuming controller named admincontroller , should : var url = "@url.action("editmovie", "admin")" + "/" + id;

pipe - bash pipestatus in backticked command? -

in bash, if execute couple of commands piped inside of backticks, how can find out exit status of first command? i.e. in case, trying "1". can via pipestatus[0] if not using backticks, doesn't seem work when want saving output: ## pipestatus[0] works give me exit status of 'false': $ false | true; $ echo $? ${pipestatus[0]} ${pipestatus[1]}; 0 1 0 ## doesn't work: $ a=`false | true`; $ echo $? ${pipestatus[0]} ${pipestatus[1]}; 0 0 more generally, trying accomplish: save last line of output of program variable, able tell if program failed: $ myvar=` ./someprogram | tail -1 `; $ if [ "what put here" ]; echo "program failed!"; fi ideally i'd understand going on, not answer is. thanks. try set pipefail option. returns last command of pipeline failed. 1 example: first disable it: set +o pipefail create perl script ( script.pl ) test pipeline: #!/usr/bin/env perl use warnings; use strict; if ( @argv ) {

eclipse - Egit installation path error -

eclipse kepler 4.3.0.v20130530-1801 egit version: 3.0.0.201306101825-r after launching eclipse , checking error log have following warning: egit couldn't detect installation path "gitprefix" of native git. hence egit can't respect system level git settings might configured in ${gitprefix}/etc/gitconfig under native git installation directory. important of these settings core.autocrlf. git windows default sets parameter true in system level configuration. git installation location can configured on team > git > configuration preference page's 'system settings' tab. warning can switched off on team > git > confirmations , warnings preference page. so need entry in file gitconfig core.autocrlf ? this kind of warning message seems related egit commit . this post suggests: solution: go window > preferences > team > git > configuration > system settings tab click on browse , find

Using resources as array indexes in PHP -

i using following method of hashing resource s lookups: $foo = socket_create(...); $bar = socket_create(...); $map[(int)$foo] = 'foo'; $map[(int)$bar] = 'bar'; echo $map[(int)$foo]; // "foo" is integer casting best option this? if not, other hashing method better or more efficient? these lookups performed in collection hundreds, many times per second in tight loop (socket polling), i've ruled out iteration-based solutions. edit: to explain situation little better, socket_select() function takes arrays of socket resources reference , modifies them such after function call, contain resources have changed (e.g. ready read from). use socket class wrapper socket resources, make code more abstract , testable: $socketobject = new socket($socketresource); another of classes keeps list of socket resources need polled every time call socket_select() : $reads = [$socketresource1, $socketresource2, ...]; socket_select($reads, null, null, 0);

javascript - How to change the code tinymce generates when adding images and lists? -

i'm working on site of client. uses tinymce , wordpress's media uploader write blog posts , include images. problem it's adding garbage attributes when try add images , lists. example, adding list generate following code; <ul> <li><span style="font-size: 1rem; line-height: 1.846153846;">item one,</span></li> <li><span style="font-size: 1rem; line-height: 1.846153846;">item two.</span></li> </ul> obviously, don't want "style" attribute. also, when adding images, editor wrap around tags automatically, don't want. my question is, in code of tinymce and/or wordpress's image uploader can change sort of formatting? i guess find kind of behaviour hardcoded in tinymce core file formatter.js (classes directory) , tinymce style plugin.

c# - How to route MVC so that I can post a form with a model.action parameter? -

hopefully easy 1 out there. i trying post form mvc controller happens have "action" property on model. unfortunately, model.action resolving controller action, not posted model's action property. public class postmodel { public string action { get; set; } public string username { get; set; } public string password { get; set; } } public actionresult dosomething(string id, postmodel model) { // id == 98f4 // model.username == "test" // model.password == "test" // model.action == "dosomething" not "test" expecting. } here post: post -> http://localhost:7832/forms/dosomething/98f4?username=test&password=test&action=test please keep in mind have no control on form data being posted, cannot change model's action property. need able address problem on mvc server side. how overwrite setting of action property in model acction of controller? need functionality 1 particular controller i

linux - How to list all the programs that are available to a given account on a cluster? -

at university working under prof ga. gave me access cluster. want know list of tools/softwares can run using account. have no idea tools availble on machine. echo $path | tr ":" "\n" | while read line; echo $line; ls $line; done be prepared tons of output. might better off doing echo $path first , looking interesting-looking directories, or seeing if tab-completion works (just type 'c', tab, see if shows 'cat', 'cd', etc). really tho, ask prof whatever docs you're supposed have, tools you're looking aren't obvious name of command.

Add id to form, rails -

i have problems add id="my-form" form: <tr> <%= form_for([@patient, @patient.treatments.build], :id => "my_form") |f|%> <th><%= f.collection_select :category_id, category.find(:all), :id, :typ %></th> <th><%= f.text_field :content , :id => "inputbox"%></th> <th><%= f.text_field :day, :value => date.today %></th> <th><%= f.submit :class => 'btn btn-small btn-primary searsa'%></th> <% end %> </tr> how that? tried: <%= form_for, :id => "my_form"([@patient, @patient.treatments.build]) |f|%> please try: <%= form_for([@patient, @patient.treatments.build], :html => { :id => "my_form" }) |f|%>

Store Temporary Sensitive Data In Rails 4 -

i'm working on rails app i'm having trouble implementing solution storing temporary data , automatically clearing when user sees it. thought using flash works when user visits via next request. im looking let user browse site , view other things once page such /example/, see temporary sensitive data, next time reload page or go somewhere else , come permanently gone. suggestions? redis fastest , simplest solution (but not such simple flash notices). redis have built in lpop method list , remove after that. think not find solution not require setup (e.g. redis installation)

ios - Core Data Fetch Based on Entity Relationship -

i'm trying call core data, associated specific category. app this: click category click sub-category question view question i have views set up, , had partner set core data, running issue regardless of category pick, still loads questions. i pass category selection category list view, i'm not sure it, , how should calling core data. have (again, returns questions): nsentitydescription *entity = [nsentitydescription entityforname:@"question" inmanagedobjectcontext:[appdelegate managedobjectcontext]]; the categories , questions have inverse relationship in data model. should using predicates, nsrelationshipdescription, or else? can not access nsset of questions? i.e. category.questions to answer question predicate: if looking find questions specific category need specify category in nspredicate something like: (nsarray *)findquestionsforcategory:(category *)category { nsfetchrequest *fetch = [[nsfetchrequest alloc] init]; nsentityde

ios - using pointer to set property rather than sending object message -

here sample scenario: you have view controller "itemsviewcontroller" lists "items" in uitableview. set in navigation controller let change title of uinavigationitem title property. going through book remain nameless accesses property 2 ways on same page , i'm not sure why; using pointer uinavigationitem *n = [self navigationitem]; [n settitle: @"title"]; sending object message directly [[self navigationitem] settitle:[item itemname]]; i understand how both of these work (correct me if i'm wrong) pointer points navigationitem , when change property changes in navigationitem otherwise send navigationitem settitle message updated string. my real question why 1 way vs other way in situation? there time 1 of these ways has advantage? when second, compiler generates hidden temporary variable. in first case define temporary variable compiler. it's best break "daisy chained" operations down sequential temp

c++ - Cannot compile SDL with Makefile -

my makefile consists of following: cc= g++ libs= -lsdl clean: rm -f it won't compile because g++ not take -lsdl parameter though included it. when g++ a.cpp -o -lsdl directly in terminal compiles fine, though. add rule: a: a.cpp $(cc) $< -o $@ $(libs)

c# - What is Difference between ConfigurationManager.GetSection and Configuration.GetSection? -

i'm trying create custom config file section based on appsettings: <configsections> <section name="customconfiguration" type="system.configuration.appsettingssection, system.configuration, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a"/> </configsections> when tried reading via configurationmanager.getsection("customconfiguration") object returned of type system.configuration.keyvalueinternalcollection. unable read values of collection, although see keys, , couldn't cast appsettingssection. this stackoverflow answer suggests should use configuration config = configurationmanager.openexeconfiguration(configurationuserlevel.none); appsettingssection customsettingsection = (appsettingssection)config.getsection("customconfiguration"); this worked. question is: difference between configurationmanager.getsection()

.net - How do I Find the Function I Need in a DLL? -

for functions need in program, have add reference dll. wondering how programmers find dlls required function. for example, if need text of active window, have reference "user32". how figure out dll need import? browse documentation? i using visual basic .net most of time google i'm trying do, eg: https://www.google.com.au/search?q=get+text+from+window+in+c%23 and read top 3 answers. i read few blogs, read few books, , if i'm stuck i'll browse documentation. though i've found msdn documentation not particularly helpful @ times, sometime can good. or i'll pick phone , ring of fellow nerds. if you're having reference user32 , com dll, recommend check out http://www.pinvoke.net/ if you're writing vb.net code , not trying fancy there's easier way of doing you're trying do.

java - Remove fillRect rectangles -

i trying make simple game have squares of random size , color appear @ random location on screen , have click on them. more click higher score. i have working except, have no idea how make when click on square disappears. here rectangle code g.fillrect(cube.cubeposx, cube.cubeposy, cube.cubesize, cube.cubesize); the position, size, , color predetermined , randomly selected in class file. suggestions: don't hard code rectangles you're drawing. instead create collection of rectangles such arraylist<rectangle> drawn in loop in paintcomponent(...) method of drawing jpanel. then remove them arraylist when user clicks on them. this done in mouselistener , again uses loop, but key being loop iterates backwards. reason rectangles on "top" of others last ones drawn. should first ones removed if clicked on. you call repaint() on drawing jpanel (or jcomponent) after removing rectangle.

html - How to make box shadow stay when you add another div below it? -

the navbar on website has box shadow below it, reason when add div below (which giant image), box shadow on navbar dissapears , it's if image overlaps navbar, or @ least box shadowing of it. below 2 images showing mean. without div/image below - http://puu.sh/3iw9f.png div/image below - http://puu.sh/3iwbx.jpg i tried messing around z-index, got no luck. there i'm doing wrong? <div id="navbar"> <a href="#">link</a> <a href="#">link</a> <a href="#">link</a> <a href="#">link</a> <a href="#">link</a> <a href="#">link</a> </div> <div id="images"> <img src="image/image1.jgp" /> </div> #navbar {width:100%;padding:10px 0px;text-align:center;z-index:100;box-shadow: inset 0 1px #fff, 0 1px 3px rgba(34,25,25

django custom manager with filter parameter -

i add custom manager can called template, not affect entire model (e.g. admin views) , listens parameter set in request (user_profile). the following have far: models.py: class currentqueryset(models.query.queryset): def current(self): return self.filter(id=1) ## simplified filter test works.. class currentmanager(models.manager): use_for_related_fields = true def get_query_set(self): return currentqueryset(self.model) def current(self, *args, **kwargs): return self.get_query_set().current(*args, **kwargs) for model b defined: objects = currentmanager() the template calls: {% b in a.b_set.current %} but try pass parameter filter (in case date stored on user-profile) method not return results. e.g.: models.py class currentqueryset(models.query.queryset): def current(self,my_date): return self.filter(valid_from__lte=my_date) showa.html {% b in a.b_set.current(request.user.get_profile.m

Java - Error with an MD5 string check and REGEX -

i don't understand why doesn't work. , problem is. public class md5hash { public static void main(string []args){ string md5hash = "69a329523ce1ec88bf63061863d9cb14"; system.out.println(md5hash); system.out.println(md5hash.matches("[a-f0-9] {32}")); }} in order use md5hash.matches, needed compare char char. perhaps don't understand greedy quantifier {32} does? and appreciated, thanks. spaces in regular expressions significant. first part of regex matches single hex char, , second part asks match 32 spaces. need remove space. might want allow upper-case variant. so, should want: system.out.println(md5hash.matches("[a-fa-f0-9]{32}"));

c# - ListView check for max chat limit tresspassing -

is there anyway can auto check character limit in listview, changing background color orange or other color item violating limit? this goes in event of imported text; after importing, loops through items , checks if items violate limit. if do, should coral background color, it's not working. for (int = 0; < numpntr; i++) { int charlim = encoding.utf8.getbytecount(listview1.items[i].subitems[1].text); if (charlim > bytecnt) { listview1.items[i].backcolor = color.coral; } } change line: int charlim = encoding.utf8.getbytecount(listview1.items[i].subitems[1].text); to: int charlim = encoding.utf8.getbytecount(listview1.items[i].text); it's work me.

ruby - Splitting at Space Between Letter and Digit -

i'm having worst time simple regex. example input: cleveland indians 5, boston redsox 4 i'm trying split @ , , space between letter , number example output: cleveland indians 5 boston redsox 4 here have far, it's including number still. /,|\s[0-9]/ string = "cleveland indians 5, boston redsox 4" string.split /,\s*|\s(?=\d)/ # => ["cleveland indians", "5", "boston redsox", "4"] \s(?=\d) : space followed digit using lookahead .

android - R cannot be resolved to a variable, but R.java is generated -

i've created android application project , getting error "r cannot resolved variable." i've checked directory, , r.java present, xml files don't seem have errors, names don't have capital letters, spaces, or special characters, deleted "import java.r" line, cleaned, , rebuilt project, i've still been getting error. according sdk manager, android sdk tools date. there i've missed? fix errors first clean , run.check api right click project> properties > android >check api 17

iis - Windows Server 301 redirect -

i have .net site on shared host environment don't have access other solutions require access server. if put following code in current web.config, enough 301 redirect my-new-site.com? thanks. <system.webserver> <httpredirect enabled="true" destination="http://www.my-new-site.com/" /> </system.webserver> http redirection not available on default installation of iis 7. have add in common http features web server role. enabled on shared host ? the correct way permanent 301 redirect : <system.webserver> <httpredirect enabled="true" destination="http://www.my-new-site.com/" httpresponsestatus="permanent" /> </system.webserver> the default response status 302 (found). more infos here .

c# - Custom string class equality -

i'm making custom string class. (mainly self-edification purposes - know i'm not going come better regular string class couldn't extension methods.) i'm running weird problem testing equality in unit tests. works in every respect except one. here's unit tests: mystring mystr = "mynewstring"; assert.areequal("mynewstring", mystr); //fails assert.areequal(mystr, "mynewstring"); assert.istrue(mystr.equals("mynewstring")); assert.istrue(("mynewstring").equals(mystr)); assert.istrue(mystr == "mynewstring"); assert.istrue("mynewstring" == mystr); string realstring = "mynewstring"; assert.areequal(realstring, mystr); //fails assert.areequal(mystr, realstring); assert.istrue(mystr.equals(realstring)); assert.istrue(realstring.equals(mystr)); assert.istrue(mystr == realstring); assert.istrue(realstring == mystr); in both cases fails, succeed if add .tostring() after mystr , not requ

security - Possible to give view and download access to a document (.pdf) without revealing the full URL? -

is possible give user access .pdf file - meaning allow them download example clicking button - without revealing full url in process? so have file @ www.mydomain.com/content/pdf/valuable_ebook.pdf i want give link triggers download, shows valuable_ebook.pdf , rather full path (which shared, leading unpaid downloads). i consider create copy of file , temporarily place in location specific download link. wonder if there easier way this. as far viewing goes, thinking make iframe, doesn't give full url away... "view source" not make easy determine full url above. way achieve this? of course there might java or flash applications allow viewing of pdfs (speaking of - have example one?). would possible such app have download feature, not reveal full url? how communicate browser? or possible restrict access url above maybe through .htaccess , put server sided logic in place grant access if registered/paid member or something? i wondering if there remote possib

slidetoggle - jQuery Slide Inner div from right to left -

here's i've got far: jsfiddle css: #button-top { width: 100px; position: absolute; left: 75%; top: 40px; padding-left: 100px;overflow: hidden;} #button-top:hover, #button-bottom:hover {cursor: pointer;} .slide { position: relative; height: 100px; overflow: hidden; width: 350px; } .slide img {position: relative; z-index: 100;} .slide p {width: 80px; padding:8px 16px; color: #fff; margin: 0; } .innertop, .innerbottom { position: absolute; left: 0; top: 10px; width: 200px; height: 90px; padding: 6px; background: url(http://i39.tinypic.com/nz4ldw.png) 0 0 no-repeat; z-index: 50; display: none; } #button-bottom { width: 100px; position: absolute; left: 75%; top: 240px; padding-left: 100px;overflow: hidden;} script: $('#button-top').click(function() { $('.innertop').toggle('slide'); }); $('#button-bottom').click(function() { $('.innerbottom').toggle('slide'); }); html: <div class="hide-mobile" i

c# - MVC Razor open a new link not opening -

Image
i using mvc4 , , in razor engine have typed view. have lot of validation , figured have link open newly spawned browser page, not happening. what doing wrong? <a target="_blank" href="http://fedgov.dnb.com/webform/displayhomepage.do">@html.labelfor(m=>m.duns)</a> edit: showing view source code <form action="/account/register" method="post"><input name="__requestverificationtoken" type="hidden" value="oef9gvp__m0yxnceshixskbit1oegj3ks5bogarw-rhsegxkdmujjery3dkivf48uzllvlfi9bvfxgiljgq4ymi_uhza1klqx8yv2x3lazm1" /> <div class="box-content nopadding"> <tr> <td class="width30"> <a target="_new" href="http://fedgov.dnb.com/webform/displayhomepage.do"><label for="duns">duns #:</label></a> <span class="

c# - Cannot convert from 'System.Type' to myself defined interface -

i defined own iexportable interface, , use as public static someaction<b>(ilist<t> data) t : iexportable { var ttype = typeof(t); ilist<b> blists = somemethod(ttype); //... } that somemethod is: list<b> somemethod(iexportable exportdata) { // somethings } but when run application error: the best overloaded method match somemethod(iexportable)has invalid arguments cannot convert 'system.type' 'ifileexport' mistake? typeof(t) returns type object has meta information class represented t . somemethod looking object extends iexportable , want create object t extends iexportable . have few options this. straight forward option may add new constraint on generic paramter , use t 's default constructor. //notice i've added generic paramters , t. looks may //have missed adding parameters or have specified many types. public static someaction<a, b, t>(ilist<t> data) t : iexportable,

c# - Refresh an asp.net page on button click -

i need refresh page on button click without increasing hit counter. create class maintain hit counters public static class counter { private static long hit; public static void hitcounter() { hit++; } public static long getcounter() { return hit; } } increment value of counter @ page load event protected void page_load(object sender, eventargs e) { counter.hitcounter(); // call static function of static class counter increment counter value } redirect page on , display counter value on button click protected void button1_click(object sender, eventargs e) { response.write(request.rawurl.tostring()); // redirect on response.write("<br /> counter =" + counter.getcounter() ); // display counter value }

android - Stop a running app you just started -

have trouble stopping app start startactivity. here how start it: intent theapp = new intent(); theapp = getpackagemanager().getlaunchintentforpackage(thepackagename); theapp.addcategory(intent.category_launcher); theapp.addflags(intent.flag_activity_new_task); getapplicationcontext().startactivity(theapp); after has ran awhile, im trying stop this: if(stopservice(theapp)) log.d(tag,"stopped app successfully!"); else log.d(tag,"failed stop app!"); any ideas why isnt working? in advance help it seems starting activity. , trying stop service, not work. if want stop whole application. can use system.exit().

c# - Interaction.CreateObject creating the old Object -

i converting vb6 application c#.net , working on shared add ins. on clicking button in ms word want open application, creating object of class this. objapp = interaction.createobject("docsys.application"); but line of code return old vb6 application instace while adding refrance of .net project. should .net object. there more 1 way fumble this. forgetting make interface , classes [comvisible(true)] example. or forgetting register com server, explicitly done regasm.exe /codebase /tlb. or using wrong version of regasm.exe, 64-bit version write wrong registry keys. more relevant createobject(), [progid] attribute on c# class essential ensure create exact substitute vb6 server. if client code ever uses binding essential [guid] attribute on interfaces , classes exact match guids used vb6 server. , of course methods , properties must exactly match ones used vb6 server, order important. the best way compare orange apple use oleview.exe utility. run vi

c++ - SendMessage WM_KEYDOWN doesn't always work -

i'm trying make program sending keypresses window of game. bot if like. i'm using sendmessage/postmessage wm_keydown , wm_keyup proper lparam window. other method i've tried use sendinput. , send/post setkeyboardstate. the problem methods work same way - not always. mean i'm trying send vk_f9 window every 10 seconds using timer. can work 3 times, or 5 times, or 0 times. means after random sends or posts stops working. if press f9 on keyboard next send works! what can problem there? may there state i'm not aware of? thanks in advance! in c++ i've tried one: void generatekey(int vk, bool bextended) { keybdinput kb = {0}; input input = {0}; /* generate "key down" */ if (bextended) { kb.dwflags = keyeventf_extendedkey; } kb.wvk = vk; input.type = input_keyboard; input.ki = kb; sendinput(1, &input, sizeof(input)); sleep(300); /* generate "key up" */ zeromemory(&kb, sizeof(keybdinput)); zeromemory(&input, siz

wpf - Facing an issue while rendering PPTs of Powerpoint 2013 through poweroint API in my application -

i facing issue while rendering slides of presentations made in powerpoint 2013. actual scenario: i have presentation let's "test.pptx", created in powerpoint 2013 & let's there 4 slides. while rendering slides in output window moves fine next slide while trigger on window. when click move last slide after showing last slide shows message "do want save presentation or not". , suppose click on don't save hangs. just fyi application running in vs-2010 wpf. so please me out if have faced issue earlier or if have solution or alternative this. looking help!!! guys. don't recall exact details off top of head, think 1 of options on open dialog read only. marking active presentation .saved = true real answer problem, here vb.net sample using dynamic binding (not interop assemblies): pp = powerpoint application object dim ppa object = pp.activepresentation ppa.saved = true

html - Bootstrap: Striped div table -

i'm using bootstrap css lib. know how make striped table lib how make striped div's? for ex: <table id="newtable" class="table table-bordered table-striped fixedtable"> <thead> <th>date</th> <th>info</th> <th>price</th> </thead> <tbody> <tr> <td colspan="3"> <div>text 1</div> <div>text 2</div> <div>text 3</div> <div>text 4</div> </td> </tr> </tbody> </table> question is: how make: <div>text 1</div>, <div>text 2</div>, <div>text 3</div>, <div>text 4</div> striped? twitter bootstrap's striping works table rows. in order stripe divs need

Chrome does not make additional request for seeking video file -

i try achieve pseudo streaming, have html so: <video src="getvideo.ashx?id=mp4" controls></video> after loading page chrome 28.0.1500.72 m sends request (even before clicking play): get /getvideo.ashx?id=mp4 http/1.1 host: localhost connection: keep-alive accept-encoding: identity;q=1, *;q=0 user-agent: mozilla/5.0 (windows nt 6.2; wow64) applewebkit/537.36 (khtml, gecko) chrome/28.0.1500.72 safari/537.36 accept: */* referer: http://localhost/jwplayertestmp4proper.aspx accept-language: ru-ru,ru;q=0.8,en-us;q=0.6,en;q=0.4 cookie: jwplayer.volume=12 range: bytes=0- and server responds http/1.1 206 partial content cache-control: private content-length: 5186931 content-type: video/mp4 content-range: bytes 0-5186930/5186931 accept-ranges: bytes server: microsoft-iis/8.0 x-aspnet-version: 4.0.30319 x-powered-by: asp.net date: mon, 22 jul 2013 08:13:28 gmt file starts play after clicking play, problem if try seek yet not downloaded part, not send addition

php - HTML Purifier Symfony2.3 -

i'd add html purifier symfony application, i'm using symfony2.3. found 2 ways have problems on both. the first 1 directly add html purifier library symfony don't know realy how that, tried find tutorials don't understand. the second way use bundle: https://github.com/exercise/htmlpurifierbundle don't know how install composer, , think documentation symfony 2.0 no higher. so have solution install html purifier, don't need twig module given bundle. thanks help the bundle has composer.json file, can add requirements: require: "exercise/htmlpurifier-bundle": "1.0.*@dev" if don't need bundle. can add htmlpurifier package: require: "ezyang/htmlpurifier": "dev-master" if see composer.json file in repository on github, can search on packagist: https://packagist.org/packages/ezyang/htmlpurifier https://packagist.org/packages/exercise/htmlpurifier-bundle

google maps - Check if point is in polygon or not -

there region on map, , have check user placed marker on region. problem how declare "rectangular", how declare bounds lat , lng.. maybe wants know details: developing web application taxi company. so, user declare original , destinatoin putting 2 markers. , center of city, square 12x12 km. has constant tarif 10$. , tarif other destinations (outside square) calculated tarif km. db. there may many ways, 1 possible: create google.maps.circle center set center of city , radius of 12000. all have check if destination placed within bounds of circle. definedcircle.getbounds().contains(destinationlatlng)

php - facebook app doesn't connect to local server -

i have ready web application @ local server http://192.168.100.1/public/mayur/fbtest/ now have created fb app , want display local server app via fb. have set on fb . click on play game link on app page gives following error message- the webpage @ https://192.168.100.1/public/mayur/fbtest/?fb_source=appcenter&fb_appcenter=1 might temporarily down or may have moved permanently new web address. error 501 (net::err_insecure_response): unknown error. i have following app settings- site url - http://192.168.100.1/public/mayur/fbtest/index.php canvas url - https://192.168.100.1/public/mayur/fbtest/ secure canvas url - https://192.168.100.1/public/mayur/fbtest/ i read in tutorials doesn't matter if the site hosted locally or online iframe can source contents locally too. any idea reason issue? first fb app. have enabled ssl localhost? link: https://192.168.100.1/public/mayur/fbtest/ working in browser? if not , please configure apache first , try— how a

sql server - How to dump data from MSSQL to XML with SQL Agent? -

i need export data sql procedure mssql (2012) xml , run script periodically sql server agent. i directly sql server, because doing console application generating xml structure raw data sql , takes on 10 hours! output xml has 300m. does how it? have stored procedure generating xml output. thanks much. the procedure executed successfully. had set rights destination folder user "sqlserveragent", because agent finishes wrote nothing. but have small problem final xml. @ beginning , @ end of xml file included information agent. do know how remove header , footer? header: job 'xml dump' : step 1, 'xml dump procedure' : began executing 2013-07-23 12:24:52 xml_f52e2b61-18a1-11d1-b105-00805f49916b --------------------------------------------------------------------------------- footer: (146270 rows(s) affected) stored procedure contains this : create procedure getxmldumpcompletedata (@xml xml) set @xml = (select * [mytable]

ruby on rails 4 - how to verify email through link in rails4 application -

how verify email through link. i have user edit profile , showing user email.i want give 1 link verify email.i not do. add 1 column your user model : email_verification , default set 0 (0). then using persistence_token create url , sent specific email address. if dnt have persistence_token column in user model can add custom column of choice verify_email_token column name , stored 50 random string. using o = [('a'..'z'),('a'..'z'),('0'..'9')].map{|i| i.to_a}.flatten string = (0...50).map{ o[rand(o.length)] }.join url example : http://www.yoursitename.com/verifyemailaddress/?token=persistence_token ; when user click on link, internally call function verifyemailaddress , in method update email_verification column 1 (1).

vi - Maintain indentation from previous row in vim -

what name of option keeps indentation when moving new row. example subject indented , press enter indentation happen automatically subject indented , press enter start here here , indent manually from manual ( :help indent.txt ): autoindent uses indent previous line ...so: :set autoindent if not work try starting vim without plugins , skipping .vimrc initializations: vim -u none -n

How do i set extended user attributes on android files? -

is there way android app retrieve , set extended user attributes of files? there way use java.nio.file.files on android? there way use setfattr , getfattr dalvik app? know android use ext4 file system, guess should possible. suggestions? the android java library , bionic c library not support it. have use native code linux syscalls that. here sample code started, tested on android 4.2 , android 4.4. xattrnative.java package com.appfour.example; import java.io.ioexception; public class xattrnative { static { system.loadlibrary("xattr"); } public static native void setxattr(string path, string key, string value) throws ioexception; } xattr.c #include <string.h> #include <jni.h> #include <asm/unistd.h> #include <errno.h> void java_com_appfour_example_xattrnative_setxattr(jnienv* env, jclass clazz, jstring path, jstring key, jstring value) { char* pathchars = (*env)->getstringutfchars(env, p

java - "gift" an In-App-Purchase Android -

is there way "gift" in-app-purchase google billing specific account? i put question here because if there way programmatically, fine, not must. couldn't find in official documentation. the reason want because 1 of apps in free , paid versions model. want go freemium, , want people bought paid version, have unlocked in free(now freemium) version. unpublish paid. thank time. i'm gonna go ahead , answer question. there no way. may change in future though. thanks.

javascript - JQuery library extraction -

i need extract jquery library. jquery library contain many functions. few functions using library. need remove unnecessary functions library. there easy way this. short answer: open file , copy&paste out functions need. don't specify ones these are, have job yourself. long answer: why want this? jquery library makes writing js easier. means written in jquery can done pure js. easier write functions straight out. also, many jquery-methods depend on each other, means can't take 1 out of core , expect work. more difficult that. and done pointed out, there's no reason doing this. may reduce filesize bit, today's speed downloading minimized library js not take long. if use google's cdn people has cached already. to sum up: copy&paste if really, have to, suggest not doing it.

Import specific class or function in Python Parallel job -

if using modules in function passed server.submit [ docs ], need specify these in modules argument. see below: import os def get_os_name(): return os.name jobserver.submit(get_os_name,modules=('os',)) but, this: from os import name def get_os_name(): return name # won't work jobserver.submit(get_os_name,modules=('os',)) how second code chunk work? tried replace 'os' 'os.name' , stuff that, no luck. try this: exec("jobserver.submit(get_os_name,modules=('os',))")

embedded linux - When we build a kernel and busy box, we need toolchain only for busybox not for kernel? -

am correct while making small linux system embedded device, need kernel build based on configuration set default toolchain. whereas rootfs requires toolchain ? since architecture set in kernel there no need of toolchains. whereas busy box makes binary. thus, needs toolchain. please correct me have doubt here. toolchain plays important role in embedded system development. in compiling , building required cross tool chain specific architecture.tools chain not default.you have set during configuration or while passing make command have specify tool chain prefix. make cross_compile=arm-none-linux-gnueabi- the same tool chain should used in compiling , building busybox. if compile busybox statically.then no need worry shared library. if compiled busy box dynamically toolchain plays important role in rootfs. here need copy libraries of toolchain rootfs /lib folder . what library need copied can known type following command. strings _install/bin/busybox | grep ^lib show

php - while uploading photo to Facebook CurlExeption 26 appears -

im using unity3d make screenshot , pload facebook. because app cross platform succesfully uploades php script, pass facebook through browser. while testing on xampp(windows) error: fatal error: uncaught curlexception: 26: couldn't open file "temp/528056320screenshot.png" thrown in c:\xampp\htdocs\base_facebook.php on line 994 this code: <?php require_once 'config.php'; if(isset($_files['thefile'])) { $img_src = "temp/" . $_files['thefile']['name']; print $img_src; move_uploaded_file($_files['thefile']['tmp_name'], $img_src); print " moved"; facebook::$curl_opts[curlopt_ssl_verifypeer] = false; print "no ssl"; // allow uploads //$facebook->setfileuploadsupport("http://" . $_server['server_name']); $facebook->setfileuploadsupport(true); print " file upload on"; // add status message $photo = $facebook->api('/me/photos', 'post&

wix3.7 - Wix Bootstrapper - DownloadUrl - Can it be a local network path? -

i want have exepackage saved on network path , bootrapper "download" place if needed. i cannot bootstapper work path. log says failed connect .... i have tried may different things / or \ , "file" @ beginning. cannot seem right. firefox, internet explorer , file explorer have no problem format, wix change in log. log show "file://servname..." downloadurl="file://///servname/foldername1/foldername2/folder%20withaspace/myexe.exe" what should be? edit: 1 work around use source attribute , have pointing network path. development pc visual studio (m$ version) not have access network share cannot use name or source of exepackage refer file. burn supports downloading bits, ftp, http, , https. doesn't support smb shares.