Posts

Showing posts from February, 2015

php - Re-directing to certain page if logged in -

i have main page has log in link on takes user login page. however, if user logged in want take user page, example info page. i have function: function logged_in_redirect() { if (logged_in() === true) { header('location: client.php'); exit(); } } i'm wondering put this? i've tried pretty everything. if put on login page, not redirect me when logged on. i've tried adding onclick function link on home page didn't work. this logged_in() function: function logged_in() { return (isset($_session['user_id'])) ? true : false; } any suggestions? edit: i have fixed problem making button on home page link test.php file has code: <?php include 'core/init.php'; if (isset($_session["user_id"])) { header('location: client.php'); } else { header('location: info.php'); } ?> is there way around this? if session set , user authenticated work. you don't need function check wheth

django - Recompile Python code on Raspberry Pi? -

i know might sound dummy question i'd know if python code needs recompiled or that's done (binding / rendering) server handles python code? i'm asking because i've started sample project , while adding link page got "page not found" (404 error) using urlconf defined in httpi.urls, django tried these url patterns, in order: ^$ ^piface/ current url, mypage.html, didn't match of these. you're seeing error because have debug = true in django settings file. change false, , django display standard 404 page. and python code looks like: from django.conf.urls import patterns, include, url django.conf import settings # uncomment next 2 lines enable admin: # django.contrib import admin # admin.autodiscover() urlpatterns = patterns('', url(r'^$', 'httpi.views.index'), url(r'^/mypage.html', 'httpi.views.index'), url(r'^piface/', include('httpiface.urls')), # uncomment admin/doc l

ios - Compressing an NSKeyedArchiver file that included UIImageView with loaded image -

i have view uiimageview. loaded either jpg or png image format. says jpg image version has data size of 100k. used nskeyedarchiver save view file. size of file getting 3mb. if used png version of image, archived file still around 3mb. i used zlib compress archived file. not seem have effect. anything can close as possible 100k area? btw: if used uiwebview load image, jpg version of image archived file's close original jpg's. edit: matt's answer gave me idea, ended doing: note: arleady used subclass of uiimageview create ivar hold nsdata image in encodewithcoder before calling [super encodewithcoder...] , set self.image = nil ; , set self.image image data using saved nsdata in 1. make sure encode nsdata ivar in 1. in initwithcoder , using nsdata ivar restore image. you don't need keyed archiver this. if image came inside app, you've got image file, there's nothing save; archive image's name. if image came fro

php - Time ago function accuracy -

i have function in gets date post , supposed write how long ago posted. when use function says posted 43 years , 4 months ago odd reason. function relativetime($date,$precision=2) { $times=array(365*24*60*60 => "year", 30*24*60*60 => "month", 7*24*60*60 => "week", 24*60*60 => "day", 60*60 => "hour", 60 => "minute", 1 => "second"); $passed=time()-$date; if($passed<5) { $output='less 5 seconds ago'; } else { $output=array(); $exit=0; foreach($times $period=>$name) { if($exit>=$precision || ($exit>0 && $period<60)) break; $result = floor($passed/$period); if($result>0) { $output[]=$result.' '.$name.($result==1?'':'s'); $passed-=$re

Encode string as HTML in Ruby with tags intact -

this question has answer here: how encode/decode html entities in ruby? 7 answers how encode strings html keep tags intact? eg <div id='blah'>i brown fox > > </div> becomes <div id='blah'>i brown fox &gt; &gt; </div> why not use xml/html builder nokogiri? simply install gem. gem install nokogiri the following little script created based on provided in question: require 'nokogiri' builder = nokogiri::html::builder.new |doc| doc.div(:id => 'blah') { doc.text "i brown fox > >" } end puts builder.to_html gives following html snippit. <!doctype html public "-//w3c//dtd html 4.0 transitional//en" "http://www.w3.org/tr/rec-html40/loose.dtd"> <div id="blah">i brown fox &gt; &gt;<id>hello</

opengl - Best algorithm for ray picking through a lot of spheres -

Image
in opengl application have lot of spheres (more 100.000) , i'm willing implement efficient ray-picking algorithm. my approach far naive one: calculate ray (in object space) corresponding mouse pointer , intersect each sphere have ray. while approach may fast enough application (the actual rendering of spheres can become slower picking them ray...), wondering best approaches out there kind of situation. i'm concerned fact sphere may have arbitrary radius, , don't know how take account in space partitioning structure such octree. do have suggestion? i'll add more details: the application in question molecular viewer atoms represented spheres such in picture: spheres can overlap partially or completely. scene can dynamic (you can molecular simulation), don't want pick during animation. ideally, find solution can extended cylinders in future. interesting question! ray vs sphere collision test 1 of simple , why spheres used in determining

java - Syntactical issue using generics -

this homework problem: i have generic class defined follows: public class priorityqueue<t extends comparable<t>> { arraylist<t> queue; public priorityqueue(){ queue = new arraylist<>(); } void add(t t){ queue.add(t); collections.sort(queue); } <t extends comparable<t>> t remove(){ t t = queue.get(0); queue.remove(t); return t; } } but netbeans showing following error (red-underline) on line t t = queue.get(0) : incompatible types required: t#2 found: t#1 t#1,t#2 type-variables: t#1 extends comparable<t#1> declared in class priorityqueue t#2 extends comparable<t#2> declared in method <t#2>remove() it seems though somehow it's not understanding t type i'm referring in method declaration same 1 referred in type parameter of class. i'm guessing sort of syntax issue. i wonder if i'm overcomplicating things - seem more logical me if declared method t remove() { . compiles

asp.net - Creating a Search Function, using stored procedure -

supposedly have projectcode textbox: <td align="left" width="200px"> <asp:textbox id="tbprojectcode" runat="server" width="194px"></asp:textbox> </td> and 1 imagebutton: <asp:imagebutton id="btnsearch" runat="server" imageurl="../support/image/magnifierglass.png" width="75%" height="75%" onclientclick="opennewwin();return false;" /> and gridview: <asp:panel id="paneldgv" runat="server" height="100%" scrollbars="none" width="100%"> <asp:gridview id="dgv" runat="server" autogeneratecolumns="false" gridlines="none" allowpaging="true" pagesize="2" cssclass="mgrid" pagerstyle-cssclass="pgr" alternatingrowstyle-cssclass="alt"> <columns> <asp:boundfield datafield="pr

scala - Play! 2.1 / Why isn't my Jerkson dependency resolved? -

attempting use forked jerkson library https://github.com/randhindi/jerkson . cloned source dependency folder module , defined following: object applicationbuild extends build { val appname = "coolapp" val appversion = "1.0-snapshot" lazy val jerkson = project( id = "jerkson", base = file("module"), settings = seq( name := "jerkson", organization := "com.codahale", version := "0.6.0-snapshot", scalaversion := "2.10.0" ) ) val appdependencies = seq( "com.codahale" % "jerkson" % "0.6.0-snapshot", "jp.t2v" %% "play2.auth" % "0.9", "jp.t2v" %% "play2.auth.test" % "0.9" % "test", "org.ocpsoft.prettytime" % "prettytime" % "1.0.8.final", "com.typesaf

mod rewrite - Moving cakePHP 2.3.4 REST API from development to production 404 errors -

i working on simple rest api, working on development system (mac osx, zend studio, zend server ce - http://localhost:10088/apitest/ ) rewritebase in .htaccess files (see below). modified .htaccess files use apache 2.2 virtual host created ( https://api.domain.com/ ) , receiving 404 errors. changes (1) rewritebase lines in .htaccess, https: access in url. error response: <response> <code>404</code> <url>/v1/flightlogs/9230.xml</url> <name> controller class flightlogscontroller not found. </name> </response> ** commented rewritebase lines below working in development. ** /v1/.htaccess: <ifmodule mod_rewrite.c> rewriteengine on #rewritebase /apitest/v1/ rewritebase /v1/ rewriterule ^$ app/webroot/ [l] rewriterule (.*) app/webroot/$1 [l] </ifmodule> /v1/app/.htaccess: <ifmodule mod_rewrite.c> rewriteengine on #rewritebase /apitest/v1/app/

sql - Join in Django? -

i'm trying make application in django, need join in django, somethin that: select user.name, post.contain user, post post.user_id = user.id; hoy can user.name? my model from django.db import models django.contrib.auth.models import user class post(models.model): titulo = models.charfield(max_length = 60) contenido = models.textfield(max_length = 140) fecha = models.datetimefield(auto_now_add = true, blank = true) usuario = models.foreignkey(user) def __unicode__(self): return self.titulo really thank =) most of time, should not worry joins. orms job. posts = post.objects.filter(user=user) after first query, user should in orm cache, don't worry performance unless detect performance bottleneck (premature optimization root of evil). {% post in posts %} {% if forloop.first %}<h1>{{ post.user.name }}{% endif %} <li>{{ post.contain }}</li> {% endfor %} if want control freak: posts = post.object

ios - view as property of model object alternative -

i'm building arithmetic app & in there subclasses of nsobject numbers , digits.both of these have corresponding view objects take datasource (either number or digit) , delegate, view controller. i have found useful in getting views & model work set digit views property of corresponding digits. for example, number class has nsmutablearray property holds digits. if want find size corresponding numberview, write can write code in controller: -(void) updatenumberviewframesize:(acnumberview*) sender { nsuinteger i; float width = 0, height = 0; (acdigit* digit in [sender.datasource returnnumberviewdatasource].digitarray) { width += digit.digitview.size.width; height += digit.digitview.size.width; } sender.frame = cgrectmake(sender.frame.origin.x, sender.frame.origin.y, width, height); } the code works fine, feel not practice hold pointer view model, if model isn't using itself. if bad practice, potential pitfalls, , th

arrays - Ruby "gets" prompts user for input. How do I get input (string) to reference existing object? -

i'm prompting user gets give me either peg1, peg2, or peg3, each reference array made before prompt. however, input user string, "peg1", "peg2", or "peg3". how make user's input reference/attach 3 arrays made? if assign possible arrays hash keyed name of array, can ask user name , select array hash. using technique, don;t need hardcode values long case statement or (even worse) eval anything. def ask_for_peg(pegs) peg = nil while peg.nil? print("which peg want? ") id = gets.strip peg = pegs[id] end peg end available_pegs = { "peg1" => array_for_peg1, "peg2" => array_for_peg2, "peg3" => array_for_peg3 } selected_peg = ask_for_peg(available_pegs) # results in 1 of arrays assigned in available_pegs array above

post - How to retrieve text fields as an array in PHP -

i have form below allows users add more input field through addmore button . question how can retrieve array in post , echo them out . can see have 2 input fields name product[] , quantity[] (more fields can added) . have value of field using a foreach loop , store in varibla $message used in mail(). have tried each loop both , each loop code below $product = $_post['product']; $quantity = $_post['quantity']; foreach($product $value) { $message = "<html><head> <title></title> </head> <body> <table> <tr> <td>".$value.""; } foreach($quantity $value) { $message.=" </td> <td>".$value."</td> </tr> </table> </body> </html>"; } my input form <form id="quick_post" method="post"> <tab

Is it possible to map a discontiuous data on disk to an array with python? -

Image
i want map big fortran record (12g) on hard disk numpy array. (mapping instead of loading saving memory.) the data stored in fortran record not continuous divided record markers. record structure "marker, data, marker, data,..., data, marker". length of data regions , markers known. the length of data between markers not multiple of 4 bytes, otherwise can map each data region array. the first marker can skipped setting offset in memmap, possible skip other markers , map data array? apology possible ambiguous expression , solution or suggestion. edited may 15 these fortran unformatted files. data stored in record (1024^3)*3 float32 array (12gb). the record layout of variable-length records greater 2 gigabytes shown below: (for details see here -> section [record types] -> [variable-length records].) in case, except last one, each subrecord has length of 2147483639 bytes , separated 8 bytes (as see in figure above, end marker of previous subrec

c - Nested loop in OpenMP -

i need run short outer loop , long inner loop. parallelize latter , not former. reason there array updated after inner loop has run. code using following #pragma omp parallel{ for(j=0;j<3;j++){ s=0; #pragma omp reduction(+:s) for(i=0;i<10000;i++) s+=1; a[j]=s; } } this hangs. following works fine, i'd rather avoid overhead of starting new parallel region since preceded another. for(j=0;j<3;j++){ s=0; #pragma omp parallel reduction(+:s) for(i=0;i<10000;i++) s+=1; a[j]=s; } what correct (and fastest) way of doing this? the following example should work expected: #include<iostream> using namespace std; int main(){ int s; int a[3]; #pragma omp parallel { // note moved curly bracket for(int j = 0; j < 3; j++) { #pragma omp single s = 0; #pragma omp reduction(+:s) for(int i=0;i<10000;i++) { s+=1; } // implicit barrier here #pragma omp single a

c# - Disabling textboxes on page load -

i have login form in 1 div hidden , when clicked on "login" visible. login form in master page , has client side html5 validations email id , pwd. i have 1 child page ajax update panel has 1 button "add cart". due validation in master page login form m not able postback on "add cart" button click. for avoiding such thing m trying disable text boxes in login form(which in master page) @ page load: c#: scriptmanager.registerstartupscript(this,this.gettype(), "javascript2", "javascript:disablepopuptxt();", true); js: function disablepopuptxt() { document.getelementbyid("txtcustemailid").disabled = true; document.getelementbyid("txtcustpwd").disabled = true; } but above code not working , not able post back on of child page. plz give me solution. thanx in advance. i think setting causevalidation=false on particular link or button might solve error more understanding can check msdn

android - SQLite returning an empty cursor even if the data exist -

i using sqlite in android application store data. each time when start application data server , store in client.the existing data updates , new data inserts db. but in many case blank cursor db when access existing item db querying "select * table itemid = x" . if extract db device/emulator before updating it, can see data exist in db. this problem happen if many data server , compare existing data. comparison done in loop , each time cursor , close before moving next comparison. try{ int[] ids = getids(); // required ids for(i =0; i<ids.length, i++) { // cursor c = db.rawquery("select * table id = "+ids[i]); if(c == null || (c != null && c.getcount() == 0)) { // new data }else if(c.getcount()>0) { // existing data } } }catch(exception e){ e.printstacktrace(); }finally{ if(c!=null && !c.isclosed()) { c.close() } c = null; } i noticed, 1st time cursor data after blank cursor. after query, if cursor contains more 0 ro

c - Problems in Memory Handling with MSXML -

i've got application testing fabricated products using legacy code in dll. application set different products. setup done via xml-files , can (and will) changed during runtime, i.e. @ end-of-lot. processing of xml done mentioned legacy dll. after running on longer time (days weeks) i've noticed increasing memory footprint. debugging that, trace (possible) leak dll. after getting source, further investigate till found this: caobjhandle doc; msxml6_newdomdocument40ixmldomdocument2(0, 0, locale_neutral, 0, &doc); [...] msxml6_ixmldomdocument2load(doc, 0, vtpath, &success); it seems me, called every time, new lot started. , it's doc structure, seems reside in memory. don't find place freed. after all, dll had lot of minor leaks, not freed objects (of cvi-functions). fixed those, don't know, how free ms-objects. came across this: understanding msxml garbage collection mechanism , after have ansi-c code, i'm not sure, gc , wether works or not. i

algorithm - youtubeplayersupportfragment in android video play -

i have develop 1 android application. i have play video using youtubeplayerfragment. here video playing on fullscreen mode. same video playing on normal mode also.here facing 1 problem. the problem is, more number of video available in gallery view. here if have click 1 video gallery view means video playing well.now have stop video , click next video means next video audio hearing .but last playing video(at stopping place) thumbnail image displaying.but working fullscreen mode correctly. how can clear cache memory here ??? there specific algorithm this?please give me solution ??? i using following code : fragmentmanager fragmentmanager = getchildfragmentmanager(); fragmenttransaction fragmenttransaction = fragmentmanager .begintransaction(); youtubeplayersupportfragment fragment = new youtubeplayersupportfragment(); fragmenttransaction.add(r.id.youtube_fragment, fragment); fragmenttransaction.commit();

html - Maintain the height of <td> at a fixed amount, no matter what (IE vs FireFox) -

i have html page containing table, problem height of 1 <td> rendered correctly in ie-8 incorrectly in firefox 20.0.1 i'm fan of firefox myself, specially when comes ie :) anyway have set height of <td> , containing word "bottom", 30px (or 10%; makes no difference) , upper <td> 90% the height of bottom <td> shown correctly in firefox when reduce contents of right <td> , when add more lines of text in right <td> , (the bottom one) shown incorrectly(very larger) in firefox , okay in ie. what's wrong code or unlikely firefox? :) in other words, want keep height of bottom <td> 30px no matter what. here's code: <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>agent</title>

cordova - JQuery Mobile and Phonegap - not getting any JQuery Mobile css effects -

i trying write appw ith both jquery mobile , phonegap(cordova). so far phonegaps behaving fine , can simple animations plain jquery. want make use of jquery mobiles styling abilities, eg: <div data-role="header"> however, none of comes through. perhaps have set wrongly? ive compared sample projects , seems fine. the header div should have ios looking black bar gradient, appears unstyled. can point me in right direction? my code is: <!-- jqm css--> <link rel="stylesheet" type="text/css" href="css/jqmcss.css" /> <!-- normal css--> <link rel="stylesheet" type="text/css" href="css/styles.css" /> <title>my app</title> </head> <body> <div data-role="page"> <div data-role="header"> <h1>program</h1> </div><!--header

javascript - spit string and set them to map as a marker -

i try create marker on map. use bing map have 2 string comma separate. in 2 different variable. var region = "pune,kolkata"; var activity = "cricket,one day"; i try java-script ajax:- <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title></title> <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.3c"> </script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> var region = 'pune,kolkata'; var cntry_code= 'in'; var activity = "cricket,one day" var map = null; function getmap() { map = new vemap('mymap'); map.loadmap(); $(document).ready(function(){ var array_region =

javascript - jQuery $(window).load not working as expected -

i ran did not expect today when removing part of function loaded in asset pipeline needed extracted partial a/b testing. i'm using bigvideo.js library load full-screen video on page. bigvideo.js started loading wrong dimensions today when extracted code partial. partial loads below rest of javascript assets. i had code incapsulated in anonymous function inside normal asset pipeline. original code (working) $(function () { (function () { var bgvid = new $.bigvideo({useflashforfirefox: false}) bgvid.show('http://videourl.com', { ambient : true }); }(); }); next, tried set equal variable call in partial. video started loading without using correct dimensions. $(function () { var initvid = function () { var bgvid = new $.bigvideo({useflashforfirefox: false}) bgvid.show('http://videourl.com', { ambient : true }); }; in partial: $(function () { initvid(); }); it looked going on dom dimensions not loading, tried switching function th

php - ORA-01861: literal does not match format string while using DateTime -

i try persist entity database , face the ora-01861: literal not match format string error. know of times error between dates , strings'conversions leads message. might case me too, can't figure out why. here sql statement (from profiler) : insert person (no_person, first_name, usual_name, last_name, birth_date, comments, c_user_creation, date_creation, c_user_modification, date_modification, email, id_rh, cod_civ) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) parameters: { 1: '173704', 2: test, 3: 'null', 4: test, 5: object(datetime), 6: 'null', 7: web, 8: object(datetime), 9: 'null', 10: 'null', 11: zefzf@dgeghte.fr, 12: 'null', 13: '1'} time: 0.00 ms the person entity : <?php namespace my\mybundle\entity; use doctrine\orm\mapping orm; use symfony\component\httpfoundation\file\uploadedfile; /** * my\mybundle\entity\person * * @orm\table(name="person") * @orm\entity(repositoryclass=&qu

c# - LINQ correlated subqueries -

starting next entities definition: public class certificate{ public id int; } public class authority{ id int; certificates ienumerable<certificate>; } my function recives 2 collections: ienumerable<certificate> , ienumerable<authority> . need select authorities certificates collection has @ least 1 certificate in ienumerable<certificate> input parameter. my firt implementation enumerating ienumerable<certificate> , selecting authority using where(predicate) . public ienumerable<authority> selectauthorities(authlist ienumerable<authority>, certlist ienumerable<certificate>){ foreach (certificate loadedcert in certlist) { yield return auth.where(a => a.certificados.any(c1 => c1.idcert == loadedcert.idcert)); } } i think there must way avoid loop using more complex linq correlated subquery (i feel in "force") can't find it. can help? you can use double any avoid loop:

sql - Dynamically create ranges from numeric sequences -

i have table following: +----+-----+-----+ | id | grp | nr | +----+-----+-----+ | 1 | 1 | 101 | | 2 | 1 | 102 | | 3 | 1 | 103 | | 4 | 1 | 105 | | 5 | 1-2 | 106 | | 6 | 1-2 | 109 | | 7 | 1-2 | 110 | | 8 | 2 | 201 | | 9 | 2 | 202 | | 10 | 3 | 300 | | 11 | 3 | 350 | | 12 | 3 | 351 | | 13 | 3 | 352 | +----+-----+-----+ i wanted create view groups list grp , concatenates values in nr . possible dynamically detect sequences , shorten them ranges? 1, 2, 3, 5 become 1-3, 5 . so result should this: +-----+--------------------+ | grp | nrs | +-----+--------------------+ | 1 | 101 - 103, 105 | | 1-2 | 106, 109 - 110 | | 2 | 201 - 202 | | 3 | 300, 350 - 352 | +-----+--------------------+ what got concatenate values, table above become this: +-----+--------------------+ | grp | nrs | +-----+--------------------+ | 1 | 101, 102, 103, 105 | | 1-2 | 106, 109, 110 | | 2 | 201, 202

c# - Can this be victim of sql injection -

hi getting id value drop down list , passing code behind method passes value sql operation. i wondering if right way of doing it. if not why not , how can inject sql injection , solution. protected void drop1_selectedindexchanged(object sender, eventargs e) { int abcid; abcid= convert.toint32(drop1.selecteditem.value); string sc = "select dddd table1 abcid not in(" + abcid + ")"; using (sqldatasource ds = new sqldatasource(connectionstring(), sc )) { } since using, convert.toint32 on value sent user, sql injection not occur. invalid values throw exceptions. however practice use parametrized queries. way string values safe. sqlcommand command = new sqlcommand("select dddd table1 abcid not in(@myid)"); command.parameters.addwithvalue("@myid", abcid);

Match with Regex any number except a specific number -

using regex match strings like: 3.2 title 1 3.5 title 2 3.10 title 3 i did @"^3\.\d+[ ]." not match strings of "3." followed single 1 : 3.1 title 4 i tried @"^3\.[^1][ ]." doesnt match strings 3.10 so how can match numbers except number 1? thank in advance use lookahead assertion word boundary anchor s: @"^3\.(?!1\b)\d+ ." explanation: ^ # start of string 3\. # match 3. (?! # assert it's impossible match... 1 # digit 1 \b # followed word boundary (i. e. assert number ends here) ) # end of lookahead assertion \d+ # match number.

asp.net - How to retrieve value by dynamically added checkbox -

here html code dynamically added checkbox <asp:panel id="panel1" runat="server"> <asp:label id="label1" runat="server" text="text catogaries"></asp:label> <br /> <br /> <br /> <asp:repeater id="repeater1" runat="server"> <itemtemplate > <table> <td> <asp:checkbox id="checkbox1" runat="server" text='<%# eval("categoryname") %>'/> </td> </table> </itemtemplate> </asp:repeater> <br /> <asp:button id="button1" runat="server" text="button" onclick="button1_click" /> <br /> <br /> </asp:panel> here code using behind button retrieve checkbox value foreach (control cr in repeater1.controls) { //

r - Subset data frame based on unique combination of multiple conditions -

i cant seem find answer through search on so. i'm trying select subset of data.frame based on 4 conditions ( lon1 , lon2 , lat1 , lat2 ). have huge dissimilarity matrix has been vectorized , sites ( lon1 , lon2 , lat1 , lat2 ) cbind it. here example data frame: out1 <- data.frame(lon1 = sample(1:10), lon2 = sample(1:10), lat1 = sample(1:10), lat2 = sample(1:10), dissimilarity = sample(seq(0,1,.1),10)) > out1 lon1 lon2 lat1 lat2 dissimilarity 1 2 6 4 4 0.6 2 4 2 1 3 1.0 3 10 9 2 6 0.0 4 3 1 10 8 0.5 5 9 5 9 1 0.8 6 5 7 5 9 0.9 7 1 8 6 7 0.2 8 8 3 8 5 0.7 9 7 4 3 10 0.3 10 6 10 7 2 0.1 out2 <- out1[c(2,5,6,8),] lon1 lon2 lat1 lat2

Repair broken git history -

Image
my git history broken, in sense current branch appears 501 commits before master, not case. in intellij idea can see @ point there jump in stream, did nothing different branching usual: i had branch historical_dev , created new branch historical_dev_new. branch surprisingly created right files (i.e. last commits on historical_dev) wrong history. didn't realize , kept committing on historical_dev_new, , need rebuild history. rebasing mean rebasing on project source code what can have occurred? how can solve it? if haven't pushed these changes remote repository, use interactive rebase clean history. more information here: https://help.github.com/articles/interactive-rebase

c++ - How to turn off the display of a Win8 tablet -

is there way turn off display of win8 tablet without putting tablet in sleep mode? i use following c++ code, code puts tablet in sleep mode: const lparam off = 2; // const lparam low = 1; const lparam on = -1; lparam state = 0; if (monitoron) state = on; // set monitor on else state = off; // set monitor off sendmessage(hwnd_broadcast, wm_syscommand, sc_monitorpower, state); we need create new vnc connection while display off. can't while tablet in sleeping mode. monitor on functionality (see code above) doesn't work in sleeping mode... anybody knows how can turn off display of win8 tablet? you can try using power management api keep computer on when put sleep. i'm not sure if can still connect using vnc when computer in state, it's worth try. #include <atlbase.h> #include <atlutil.h> #include <powrprof.h> #pragma comment(lib, "powrprof.lib") #include <iostream> using namespace std; int main(

caching - How to stop page cache for disk I/O in my linux system? -

here system based on linux2.6.32.12: 1 contains 20 processes occupy lot of usr cpu 2 needs write data on rate 100m/s disk , data not used recently. what expect: can run steadily , disk i/o not affect system. my problem: @ beginning, system run thought. time passed, linux cache lot data disk i/o, lead physical memory reducing. @ last, there not enough memory, linux swap in/out processes. cause i/o problem lot cpu time used i/o. what have try: try solved problem, "fsync" everytime write large block.but physical memory still decreasing while cached increasing. how stop page cache here, it's useless me more infomation: when top show free 46963m, including cpu %wa low , vmstat shows no si or so. when top show free 273m, %wa high affect processes , vmstat shows lot si , so. i'm not sure changing affect overall performance. maybe might use posix_fadvise(2) , sync_file_range(2) in program (and more fsync(2) or fdatasync(2) or sync(2) or sy

asp.net - Login Page to verify NIC number -

i facing followingj problem: have database on access 2010 fields nic , active , page , of number types. want create login page takes nic (numeric) input user , redirects them specific page per nics. different people see different pages.. getting error in executescalar command, maybe query not correct or maybe executescalar can't hold query... getting data type mismatch error. try { firsstpage f = new firsstpage(); secondpage second = new secondpage(); oledcon.open(); string nic = ( textbox1.text); // string query = "select * logintable nic='" + nic + "'and active=0 , page=1"; //string query = "select * logintable nic='" + nic + "'and active=0"; string query = "select * logintable nic= '" + nic + "' , active=0 , page=1"; //string query = "select oledbcommand comm = new oledbcommand( query,oledcon); string = (string) comm.executescalar();

jquery - ASP.NET MVC 4 routing corrupting a decimal json value -

i have method in controller: [httppost] public virtual jsonresult add(additemmodel request) this receives ajax call. json request sends serialized version of "additemmodel" class , mvc routing creates additemmodel expected properties (which include datatypes such strings, integers , decimals). i deploy our qa server , behaviour different. json request identical (checked fiddler) additemmodel has properties populated except decimal 1 - has value of 0 default value. i can't find differences between our dev environment , qa server, i'm not looking @ right thing. can suggest causing difference? dev win7, qa win2003 server, running latest patches. thanks in advance griff update #1 we added custom model binder both decimal , nullable decimal types , added tracing ascertain happening. when value came in, picked attempted value: var attvalue = modelbindingcontext.valueprovider .getvalue(modelbindingcontext.modelname).attemptedvalue

printing - How to print square of n*n given characters in prolog? -

write prolog program print out square of n*n given characters on screen. call predicate square/2. first argument should (positive) integer. second argument character (any prolog term) printed. example: ?-square(5, '*'). ***** ***** ***** ***** ***** yes i start learn language. did this: square(_,'_'). square(n, 'b') :- n>0, write(n*'b'). it doesn't work @ all. can me? so question is, basically, "how write loop nested in loop?" this how write empty loop integer counter: loop(0). loop(n) :- n > 0, n0 n-1, loop(n0). which in c be: for(i=0; < n; ++i) { } and seem know how print ( write(foo) ).

java - Dynamic columns with jasper reports -

i have csv/excel report 5 fixed columns , want add more columns, depending on input. each report generation may require different number of columns. the jrxml approach done, question - can add dynamic columns in jrxml ? if not, correct way coding ? example note : prefer not use dynamic jasper library i think purpose can best achieved using dynamicjasper creates report design , layout on fly. allow custom made report before generating it.

SAS reading data from file containing tab and comma delimiters -

so problem tab delimiter defined '09'x , , comma - ",". know can use multiple delimiters if have e.g. colon , comma , define ":," dont know how define multiple delimiter of tab , comma. data file looks this: aislelevels: 14, enroute: 10, orderavg: 2, psnum: 2, pstype: 1, aisleslots: 150, nop: 1 run 1 run 2 run 3 run 4 run 5 rn set 1 rn set 2 rn set 3 rn set 4 rn set 5 elevutil 0.147 0.147 0.149 0.139 0.142 msutil 0.186 0.186 0.189 0.174 0.182 pickutil 0.417 0.424 0.417 0.394 0.407 tput 668 678 666 632 649 first row delimited comma, , else tab.. thank help! i not use multiple delimiters; read whole thing tab delimited, , parse first line separately. something this: data want; infile datalines dlm='09'x truncover; if _n_ = 1 do; input @1 str $1500.; *(parse string scan); levels=scan(str,1,','); enroute = scan(str,2,','); /*etc.*/ end; e

ODE solving library for Fortran, to be used on Ubuntu x64 -

as part of larger program, need solve quite simple ode in fortran. avoid having implement solver myself (and surely introduce couple of bugs before right) thought i'd use library, if there 1 - can't find works. i've looked @ odepack , found re-packaged it , original distribution distributed really hairy source code, , re-pack doesn't build on laptop - emits bunch of warnings converting integer(8) , real(8) integer(4) , real(4) before stopping on gfortran -shared -o libodepack.so opkda1.o opkda2.o opkdmain.o /usr/bin/ld: opkda1.o: relocation r_x86_64_32 against `dls001_' can not used when making shared object; recompile -fpic opkda1.o: not read symbols: bad value collect2: error: ld returned 1 exit status make: *** [odepack.so] error 1 so assume it's 32/64-bit incompatibility issue (i have 64-bit processor). adding -fpic flag error message suggested didn't - got same message anyway. is odepack, or similar, available modern ubuntu distributi

xml - Best SAX Parser Framework in java -

i have requirement parse xml files around 1 3 gb. if not wrong parse such huge xml files sax parsing mechanism used. please suggest best sax parser framework javax.xml.parsers.saxparser parser suggest

ubuntu - VTUNE: Cannot display data -

i'm using intel vtune analyzis: memory access, access contention, etc. , i'm getting error: cannot display data. data cannot displayed: there no viewport applicable data. i'm using debian 6, intel vtune amplifier (gui) update 5 (2013). i've found suggestion problem on ubuntu didn't find debian , suggested solutions ubuntu seems no applicable debian. first of sanity check hardware event based collection works on system, run: amplxe-cl -collect lightweight-hotspots -d 20 this simple 20 seconds system-wide collection,you should see summary report result. if doesn't pass please let know error see? if passes try run application under same analysis , make sure runs without errors or unexpected exits: amplxe-cl -collect lightweight-hotspots -- your_app if latter passes main reason of not receiving data in memory access , other in-depth event based analysis workload short , did not collect enough samples. try increase analysis duratio

c - clutter stage in gtk can't not handle stage mouse press event -

i have tried use clutter-gtk. wrote small piece of code create gtk window clutter stage in it. try mouse button press event on stage there nothing. here code: #include <clutter/clutter.h> #include <clutter-gtk/clutter-gtk.h> #include <glib.h> #include <stdlib.h> #include <stdio.h> /*gcc 3_clutter_app_clickable_text_in_gtk.c -o 3_clutter_app_clickable_text_in_gtk `pkg-config clutter-1.0 clutter-gtk-1.0 glib --cflags --libs`*/ /*mouse clic handler*/ void on_stage_button_press( clutterstage *stage, clutterevent *event, gpointer data) { printf("ok\n"); } int main(int argc, char *argv[]) { if (gtk_clutter_init(&argc, &argv) != clutter_init_success) return exit_failure; /*create window*/ gtkwidget *window = gtk_window_new (gtk_window_toplevel); gtk_window_set_default_size (gtk_window (window), 640, 480); /*destroy window close all*/ g_signal_connect(window, "destroy", g_callback(gtk_main_quit), nu