Posts

Showing posts from January, 2014

Haskell - Lempel-Ziv 78 Compression - very slow, why? -

so i've finished lempel-ziv compression/decompression, compared c++ unbelievably slow, i've tried on http://norvig.com/big.txt file, program can't process it, while in c++ took 1 second. of haskell gurus @ code , tell me if there obvious flaws? after adding prepending instead of appending, managed reduce time 16 seconds 0.4! haskell's laziness deceiving, printing 'compression finished' immediately, in fact compression made program run slow import system.io import control.monad import qualified data.map map import debug.trace main = contents <- readfile "plik.txt" let compressed = reverse $ compress contents map.empty 1 "" [] let decompressed = reverse $ decompress compressed map.empty 1 "" --print $ contents print $ length compressed print $ length decompressed --print $ contents == decompressed compress :: string -> map.map string int -> int -> string -> [(int,char)]-> [(int,char)...

javascript - Adding an event in a dynamically generated class on hover -

i attempting loop hover effect such image dances 4 corners of site (top left corner -> top right corner -> bottom right corner -> bottom leftcorner -> top left corner) the way doing adding class, hoverleft, right, down, up, etc. , removing previous class. issue have dynamically added classes not recognized after page loads. have been trying work .on() function have been having difficulty. not sure why , pretty sure missing simple. here have, html js: fiddle here: http://jsfiddle.net/5w0nk6j9/4/ <div class="bodycontainer"> <div id="kim"> <div id="dance" class="dancingkim"> <div class="header"> <h2 class="introheader">hover original</h2> </div> <img src="http://placehold.it/240x208" /> </div> </div> $('#kim').hover(function(){ $(".header h2").text("hover text"); }); $(...

javascript - Access to i18n inside Socket.io -

i use i18n-2 internationalization this: router.get('/route', function (req, res, next) { res.redirect('/route/?lang=' + req.i18n.getlocale()); }); right now, want access req.i18n inside socket.io block. use socket.io this: io.on('connection', function(client){ client.on('event', function(data){ ... }); }); but here, don't access req use i18n . how can solve this? if @ expressbind method of i18n-2, attach i18n property request object method proxies response object (to use in templates assume). can same thing client. var i18n = require('i18n-2'); io.on('connection', function(client) { client.i18n = new i18n(/* options */); client.on('event', function(data) { // use client.i18n.__ }); }); you fancier , use util.inherits give client same methods i18n has, prefer first way.

android - set repeated reminder that repeats every month -

i taking 2 dates user in android code. want set reminder every month in between 2 dates. if first date : 1st jan 2015 , other date 1st feb 2016 want set reminder 1st day every month in between these 2 dates. tried using alarm manager couldnt able repeat alarm. please help. thank one method might have alarm receiver set next alarm when called (e.g. activates on 1 jan 2015 , sets next 1 one feb 2015), you're setting 1 ahead.

php - .htaccess file not working at all -

i trying redirect when trying hit "192.168.21.3:8080/ping" "192.168.21.3:8080/ping.php" via creating .htaccess file following code in it: //301 redirect old file redirect 301 http://192.168.1.234:8080/ping http://192.168.1.234:8080/ping.php also, following line in httpd.conf has been un-commentated: loadmodule rewrite_module modules/mod_rewrite.so please help! i still learning basics myself have try out, if let me know how on.. can re-edit answer should solution not work. you can either redirect traffic page named ping.php or per question can redirect specific ip address ping.php. add code below .htaccess file. rewriteengine on rewritecond %{remote_addr} 192\.168\.21\.3 rewritecond %{request_uri} !/ping\.php$ rewriterule $ /ping.php[r=301,l] alternatively take here may out: https://perishablepress.com/permanently-redirect-a-specific-ip-request-for-a-single-page-via-htaccess/ thanks

java - Android custom toast as in Facebook app -

Image
never messed custom layout in android. what i'm trying this: the closest thing i've found this , didn't manage make work (tried few hours , no result, won't show), , require more work make facebook's one. i'd able call toast everywhere app, too. thanks ahead.

How to fill with multiple color in Python using turtle module? -

Image
i pretty new in python, trying have fun before going serious stuffs. trying draw simple 1 wheel cart type something, body , cart have different colors. trying code: import turtle truck = turtle.turtle() truck.color("blue", "green") truck.begin_fill () truck.fd(50) truck.color("blue", "red") truck.begin_fill () truck.circle(50) truck.end_fill() truck.fd(50) in range(2): truck.right(90) truck.fd (100) truck.right(90) truck.fd(100) truck.end_fill () this code fill red color in wheel. box remains uncolored. if remove color filling codes circle, full structure becomes green. i know using penup , pendown, can draw ease. like, using code: import turtle truck = turtle.turtle() truck.color("blue", "green") truck.begin_fill () in range(4): truck.right(90) truck.fd (100) truck.end_fill () truck.penup() truck.bk(50) truck.pendown() truck.color("blue", "red") truck.begin_fill () truck.circle(50...

rust - How to reverse after zip two chains -

i have following code not compile. fn main() { let = "123" .chars() .chain("4566".chars()) .zip( "bbb" .chars() .chain("yyy".chars())) .rev() .map(|x, y| y) .collect::<string>(); println!("hello, world! {}", a); } got error following: src/main.rs:37:10: 37:15 error: trait `core::iter::exactsizeiterator` not implemented type `core::iter::chain<core::str::chars<'_>, core::str::chars<'_>>` [e0277] src/main.rs:37 .rev() ^~~~~ src/main.rs:37:10: 37:15 error: trait `core::iter::exactsizeiterator` not implemented type `core::iter::chain<core::str::chars<'_>, core::str::chars<'_>>` [e0277] src/main.rs:37 .rev() ^~~~~ src/main.rs:38:10: 38:23 error: type `core::iter::rev<core::iter::zip<core::iter::chain<core::str::chars<'_>, core::str::chars...

node.js - Polymorphic associations with SailsJS -

i use sailsjs built rest api , takes advantage of blueprints. my design has lot of resource in 1 asset resource : asset ( id, type, owner_type, owner_id, url); this act entry point host multiple assets other resource in system. ie. user resource can have multiple images , video. of these records gets stored under asset resource. asset ( id, type, owner_type, owner_id, url); asset ( 1, 'image', 'user', 1, 'http://path.to.image.com/abc.jpg'); asset ( 2, 'video', 'user', 1, 'https://youtube.com/sdasd'); asset ( 3, 'image', 'blogpost', 20, 'http://path.to.image.com/blogpost.jpg'); so ideally when user id or users , prefer related assets object. its possible prepare response if implementing 2 methods getone , getall , when consuming blueprints bit blurred. if understand correct, have user model, have asset model. the user model looks //user.js module.exports={ assets:{collection:...

php - Phalcon: how to get distinct models? -

using phalcon model , how can distinct rows when rows using find() method. using builder: basic implementation later example: $querybuilder = $this->getdi()->getmodelsmanager() ->createbuilder() ->addfrom('tablename', 't'); distinct command: $querybuilder->distinct('t.id'); column thing works too, not recommended: $querybuilder->columns('distinct(t.id) id') using strictly model: // waiting it, may still not implemented tablemodel::find(array('distinct' => 'id')) for count: tablemodel::count(array("distinct" => "id")); and less recommended way according previous answer: tablemodel::find(array('columns' => 'distinct(id)')) and link imo best docs . also, there issues in phalcon 2.0.2 .

javascript - Transcluding in angularjs -

i trying understand idea of creating directives in angularjs. reason obvious angular 1.? finishing angular 2.? different? trying find way easy cross gap. , found this: link . java , c++ programmer starting frontend journey, , maybe not clear me, can't figure out transclude-to or transclude-id is? come from? in of documentation have been searched can't find it. welcome front-end world! transclude bit difficult understand, maybe better choice leave now... recommand start intro course of angular 1.x. moreover, should learn html, css , javascript basics building strong base next steps. can start here .

java - Cannot find javax.persistence.AttributeConverter -

i have following import import javax.persistence.attributeconverter , cannot find symbol error in netbeans. have search maven , cannot find matching results. my pom dependencies are <dependency> <groupid>javax.persistence</groupid> <artifactid>persistence-api</artifactid> <version>1.0.2</version> </dependency> <dependency>> <groupid>javax</groupid> <artifactid>javaee-api</artifactid> <version>6.0</version> <type>jar</type> </dependency> <dependency> <groupid>org.glassfish</groupid> <artifactid>javax.persistence</artifactid> <version>3.0-b29</version> </dependency> <dependency> <groupid>org.apache.openjpa</groupid> <artifactid>openjpa-all</artifactid> <version>2.0.0</version> </dependency>

css - How to change the style of active thumbnail in flexslider -

i want change size of thumbnail active 'image' in flexslider use class .flex-active-slide style active thumbnail. apply css transform - transform: scale(1.1) . http://flexslider.woothemes.com/thumbnail-slider.html #carousel .flex-active-slide img { opacity: 1; cursor: default; transform: scale(1.1); }

javascript - Load Google Maps in HTML page when button is clicked -

i have html page list of buttons representing locations. when button clicked, want google map appear location. should map open on new html page? (because map should take full page), or possible display map on same page? edit - ok, want open in html file. have external js file has following map code: function initialize(lat, lng) { var mapoptions = { center: {lat: parsefloat(lat), lng: parsefloat(lng)}, zoom: 8, maptypeid : google.maps.maptypeid.roadmap }; var map = new google.maps.map(document.getelementbyid("map-canvas"), mapoptions); } google.maps.event.adddomlistener(window, 'load', initialize(-34.397, 150.644)); my external html file given below: <html> <head> <style type="text/css"> html, body, #map-canvas { height: 100%; margin: 0; padding: 0;} </style> <script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3&sensor=f...

c# - ASP.NET DataGrid is empty -

i have asp.net datagrid on user control. have main page adds user control ( multiple copies of user control ) , restores them when post occurs. the datagrid has insert / edit / delete links. can add multiple copies of user control page , insert / edit delete functionality works each separate control. yesterday added property binding main page unrelated user control using format text='<%# documenttitle %>'. couldn't work until added page.databind(); main page's page_load method. @ point property binding started working correctly noticed insert functionality had stopped working in datagrid within each user control....i debugged , found when following line executes finds text fields in controls within datagrid empty or "": einfo.ref = ((textbox)gveg.footerrow.findcontrol("txtemployeename")).text; if remove page.databind() method main page property binding stops working datagrid(s) in usercontrol start working. my question 2 fold i) w...

sql - How to join select with itself in postgresql? -

how join select in postgresql? select * ( select src, dst records ) t1 join t1 t2 using(src) update: my table doesn't exists , create table "select" , want join selected table itself. use common table expressiom: with t1 ( select src, dst records ) select * t1 join t1 t2 using(src)

ios - 'UICollectionViewCell' does not have a member named 'image' [Swift] -

i'm setting project uicollectionview displays image label. created viewcontroller , cellviewcontroller , supposed to. in cellviewcontroller code following: class cellcontroller: uicollectionviewcell { @iboutlet weak var image: uiimageview! @iboutlet weak var label: uilabel! } but in viewcontroller when i'm setting image gives me error. here's code: func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell { let cell: uicollectionviewcell = collection.dequeuereusablecellwithreuseidentifier("cell", forindexpath: indexpath) as! cellcontroller cell.image.image = uiimage(named: "star") return cell } and weirdest thing is, have project downloaded github same mine, , works fine. thanks in advance! your problem :uicollectionviewcell . although cast cell cellcontroller makes type uicollectionviewcell , not have image property. removing or ...

java - Android Multi Threading -

how many java threads can run concurrently in android application ? think architecture dependent thing there way determine same ? how many java threads can run concurrently in android application ? that depends on definition of "run" , "concurrently". you can start many threads want, subject memory limitations. how many threads executing simultaneously depends on number of active cores on device. i think architecture dependent thing beyond architecture, depends on going on, android devices power down cores save battery power, whenever possible. plus, depending upon threads doing (e.g., blocking on i/o), having more threads cores reasonable. a typical multi-core thread pool sizing algorithm use 2n+1 threads, n number of cores. asynctask uses approach , example: private static final int cpu_count = runtime.getruntime().availableprocessors(); private static final int core_pool_size = cpu_count + 1; private static final int maximum_p...

c++ - Setting swipe event to a sprite -

i'm assinging swipe event cocos2dx sprite problem event assigned whole screen. want assigned single sprite. here code: rect = sprite::create(); rect->settexturerect(rect(0, 0, 180, 80)); // ekranın y ekseninde ortası | visiblesize.height / 2 + origin.y rect->setposition(point(visiblesize.width / 2 + origin.x, visiblesize.height + 80)); auto grad = layergradient::create(color4b(255, 255, 38, 255), color4b(199, 173, 68, 255)); grad->changeheight(rect->getcontentsize().height); grad->changewidth(rect->getcontentsize().width); //grad->setposition(point(visiblesize.width / 2 + origin.x, visiblesize.height / 2 + origin.y)); //grad->addchild(rect); rect->addchild(grad); this->addchild(rect); auto listener = eventlistenertouchonebyone::create(); listener->ontouchbegan = cc_callback_2(gamescene::ontouchbegan, this); listener->ontouchmoved = cc_callback_2(gamescene::ontouchmoved, this); listener->ontouchended = cc_callback_2(gamescene::ontouc...

sql server - What Database Information Applies to What Connection String Attributes -

i attempting deploy asp .net mvc 4.5 website server. have database details , connection string written. but unsure if connection string attributes correct , if have wrong way around. confused whether data source represents database name or instance , whether initial catalog server or else? given database information below, connection string correct? uploading files server haven't had chance test yet. db server: mssql.mywebsite.com db instance: .\mssqlserver2014 db name: db_mydatabase db user: myusername db password: mypassword <add name="myname" connectionstring="data source=.\mssqlserver2014; attachdbfilename=db_mydatabase; initial catalog=mssql.mywebsite.com; user id=myusername; password=mypassword;" providername="system.data.sqlclient" />

c# - Why am I printing out 'System.Int32[]' instead of my array of numbers? -

i trying print out array of numbers have assigned particular array. algorithm choosing numbers consists of choosing random number not duplicate , storing inside array. pretty simple really, have no idea why printing out error. int[] ticket1 = new int[4]; (int = 0; < 4; i++) { int temp = rand.next(43); while (ticket1.contains(temp)) { temp = rand.next(43); } ticket1[i] = temp; } console.writeline("{0}{1}", item.padright(20), ticket1.tostring());//ticket1 produces system.int32[] instead of 4 numbers. //i have changed line to: //console.writeline("{0}{1}", item.padright(20), string.join(",", ticket1)); //and still doesn't work. error remains. (system.int32[]) my question is, how can print out 4 numbers (beside each other) in string format. //edit: i've found problem. putting ticket1 inside foreach loop, it's somehow not reaching out array values , therefore prints out system.int32[] instead. all fixe...

Parse error: syntax error, unexpected '<' in C:\wamp\www\form1.php on line 2 -

this question has answer here: php parse/syntax errors; , how solve them? 11 answers <form action="form1.php" method="post"> username <input type="text" name="username"><br /> password <input type="password" name="password"><br /> <input type="submit" name="submitbutt" value="login!"><br /> </form> when add lines on code,the procedure runs error : parse error: syntax error, unexpected '<' in c:\wamp\www\form1.php on line 2 <?php <form action="form1.php" method="post"> username <input type="text" name="username"><br /> password <input type="password" name="password"><br /> <input type="subm...

How to access variable sent from Rails 4 controller in JavaScript? -

i have @coords variable: #maps controller def index @coords = map.all end inside index.html.erb, have: <%= content_tag 'div', id: 'coords', data: @coords.to_json %> <% end %> how content_tag looks after rendering html page: [{"id":1,"vibration_level":456,"lat":"71.45543","lon":"53.43424","time_sent":"1994-05-20t00:00:00.000z","created_at":"2015-06-13t06:53:30.789z","updated_at":"2015-06-13t06:53:30.789z"} ] how can access javascript file. you should consider using gon gem. gem sending data rails javascript. you can smth this: #map controller def index @coords = map.all gon.coords = @coords.to_json end and can acces variable in js: gon.coords

c# - Unable to run KinectAvatarsDemo for Kinect version 2 with KinectWapper -

i try use kinectwrapper http://rfilkov.com/2013/12/16/kinect-with-ms-sdk/ integrate kinect unity. following instruction given in package, able import package project , can see kinectavatarsdemo.unity under assert/kinectdemo/avatarsdemo. after double clicking kinectavatarsdemo.unity file, nothing happened. not see avatar in scene. when run it, nothing happened. kinect not turned on. have no idea shall run demo. sure ms-sdk kinect version 2 correctly install. can 1 show me more detailed instruction on using package? thank you. i assume using kinect window v2 device. kinectwrapper provided in http://rfilkov.com/2013/12/16/kinect-with-ms-sdk/ kinect windows v1. doesn't support kinect windows v2. use unity kinect windows v2, need use plug in kinect v2. can plug in here . official kinect windows v2 plug in unity. , contains 2 examples inside , other instructions use it. there unofficial paid asset kinect v2 ms-sdk in asset store. can check free asset freekinectv2 bone ...

javascript - SlideDown not animating properly - jQuery -

i seem confused this. i trying use slidedown function in jquery, when div clicked on, 'information' div jumps , doesnt animate. i think 1 of cause .information div has following properties: when min-height property removed animations work. want min-height there. would able provide solutions? view here: http://www.bootply.com/exxhrtaecu css: .information { margin-left: auto; margin-right: auto; /*border:1px solid #000;*/ border-top: 1px solid #000; border-bottom: 1px solid #000; width: 100%; display: none; background-color:#f2f2f2; box-shadow: 1px 1px 1px #f2f2f2; overflow: hidden; min-height: 300px; /*when remove works*/ height:auto; } that because not allowed specify min-height property on sliding div. remove min-height: 300px .information div, ...

Create vhost-file from mysql via shell script -

i create configuration script database. configuration stored as: <virtualhost *:80> servername example.com proxyrequests off proxypreservehost on <proxy *> require granted </proxy> proxypass / http://10.20.30.50:81/ retry=1 timeout=30 proxypassreverse / http://10.20.30.50:81/ <location /> require granted </location> </virtualhost> apache gives me following error message: apache2: syntax error on line 219 of /etc/apache2/apache2.conf: syntax error on line 1 of /etc/apache2/sites-enabled/example.com.conf: /etc/apache2/sites-enabled/example.com.conf:1: not closed. my script likes: sql="select domain, vhost v_create_proxy_vhost domain = 'example.com'" while read vhost echo "${vhost}" printf "${vhost}" > "$vhostconfavailable/$domain.conf" done < <(echo "$sql" |mysql -h $dbhost -u $dbuser -p$dbpa...

What's the benefit for a C source file include its own header file -

i understand if source file need reference functions other file needs include header file, don't understand why source file include own header file. content in header file being copied , pasted source file function declarations in per-processing time. source file include own header file, such "declaration" doesn't seem necessary me, in fact, project still compile , link no problem after remove header it's source file, what's reason source file include own header? the main benefit having compiler verify consistency of header , implementation. because convenient, not because required. may possible project compile , run correctly without such inclusion, complicates maintenance of project in long run. if file not include own header, can accidentally in situation when forward declaration of function not match definition of function - perhaps because added or removed parameter, , forgot update header. when happens, code relying on function mismatch st...

Java - take name from string -

i'm developing java application make statistic stuff. this application take data .txt file supplied user. first line of file contains name of sets of data follows this: velx,vely,velz //various data i need analyze first line , retrieve 3 name of variables, correctly first 2 i'm not able last one. there code names: public arraylist<string> gettitle(){ // arraylist not here in class intestation // copied here simplify code's understanding arraylist<string> title = new arraylist<string>(); try { inputstreamreader isr = new inputstreamreader(in); bufferedreader br = new bufferedreader(isr); stringbuilder sb = new stringbuilder(); int titlen = 0; string line = br.readline(); //read first line of file string temp; system.out.println(managetable.class.getname() + " line: " + line); int c = line.length(); for(...

swift - call generic function without params -

protocol idatasource:anyobject{ typealias ds; typealias u; func datasource(ds:ds, index:int?); func datasource(ds:ds, data:[u]); } class datasource<t:anyobject>{ var map = [nsmanagedobjectid:t](); var data = [t](); var ctrls:nshashtable = nshashtable.weakobjectshashtable(); func find(value:t)->int?; var selected:t?; func setneedsupdate<bar:idatasource bar.u==t,bar.ds==dsgen>(){ ctrl in self.ctrls.allobjects { let client = ctrl as! bar; client.datasource(self, data:self.data); } } func foo(){ // error setneedsupdate() } } how can call method setneedsupdate()? compiler error " cannot invoke 'setneedsupdate' no arguments" have found decision, decision demand parameter func setneedsupdate<bar:idatasource bar.u==t,bar.ds==dsgen>(type:bar.type){ ctrl in self.ctrls.allobjects { let client = ctrl as! bar; ...

javascript - adding sharing buttons (like "addtoany") to a single image in lightbox plugin -

i have developed own theme in wordpress using bootstrap. i using lightbox image gallery , both trying add sharing buttons on single image opened in pop up,both trying excercise bit in using jquery. the single image in lightbox of course comes without option of sharing buttons social network. the div contains image element consider, , there code of snippet. tried this... $sharingbuttons = $("</div>"); $sharingbuttons.css({top: 100, left: 20, 'absolute'}); $sharingbuttons.addclass(""); $sharingbuttons.appendto( '.lb-outercontainer' ); $('lb-outercontainer').append("<div class='addtoany_share_save_container addtoany_content_bottom'><div style='line-height: 32px;' class='a2a_kit a2a_kit_size_32 addtoany_list a2a_target' id=''> )etc... (here snippet code of addtoany)... </div></div>"); $('img.lb-outercontainer').css("opacity", "0.8...

Get window position and size C# -

how can size , position of window in c#? read getwindowrect function, not understand how use it. can please give me example on how use it? (i'd position of notepad++) form.location.x , form.location.y give x , y coordinates of top left corner. for own form application code this.

Last Button added Dictatorship in android -

i know title fancy going on in android app. i storing names of websites user wants open in arraylist of strings. array of buttons made size depends on size of arraylist. then set text of buttons using arraylist. works , buttons assigned correct text. then set on click listeners of each button , create implicit intent open web site. problem occuring despite fact text of buttons set , there problem listener because no matter button press, site of last button opened , hence last button dictatorship. here code. package com.example.hp.myproject; import android.app.activity; import android.content.intent; import android.net.uri; import android.os.bundle; import android.view.view; import android.widget.button; import android.widget.linearlayout; import android.widget.textview; import java.util.arraylist; /** * created @creativelabsworks */ public class act3 extends activity { linearlayout ll1; button[] bt_arr; string s; linearlayout.layoutparams pa...

php - Zend Guard Loader not getting enabled -

i trying optimize zend application using zend guard loader in xampp contol panel. install , configure this, have done following configuration settings. i have downloaded zend guard loader zend guard loader php 5.6 , extract in d:/xampp/php/ext/zend-loader . it contains zendloader.dll , php_opcache.dll . and in php.ini file, have updated as:- zend_extension_nts=d:/xampp/php/ext/zend-loader/zendloader.dll [as php thread safe enabled, , used zend_extension_nts ]. also have uncommented , modified:- opcache.enable=1 zend_loader.enable=1 and when check using php -v or using phpinfo(),its not showing zend guard loader enabled. appreciated.it taking hell lot of time configure it.also if knows effective ways how optimize zend apllication,please help. you need load php_opcache.dll after zendloader.dll . also directive zend_extension_nts should zend_extension . there no zend_extension_nts , zend_extension_ts has been removed since php 5.3.0. so php.in...

c# - How do I store an array of strings into another array of strings? -

i'm trying store old array of struct type holds first names of people new string array has been downsized can shuffle round in method. string[] newstringarray = new string[10] (int = 0; < oldstringarray.length; i++) { newstringarray = oldstringarray[i].firstname;//cannot convert type 'string 'string[]' } foreach (string value in newstringarray) { console.writeline(value); } it looks forgot index accessor: string[] newstringarray = new string[10]; (int = 0; < oldstringarray.length && < newstringarray.length; i++) { newstringarray[i] = oldstringarray[i].firstname; // ^ }

PHP - change first directory in url and keep remaining directories -

i have 2 language website, english , russian; english version: www.example.com russian version: www.example.com/ru/ looking @ example below, how can direct php add ru directory after domain , keep remaining url of current page forexample, if current page url is: http://example.com/newyork/car/ then want change link to: http://example.com/ru/newyork/car/">russian use fetch requested url.. $return_url = base64_decode($_get["return_url"]); //return url if need provide link original page use //redirect original page <a href="<?php echo $return_url; ?"> </a>

php - MIME Type 'application/octet-stream' is switched to 'text/html' in my server. How to prevent? -

i trying download .mp3 file server when pass below code , prints file @ browser screen in binary converting content-type: text/html;charset=utf-8 . if tried same code other server, runs content-type: application/octet-stream . can code 100% valid (code in php ). so problem in server configuration or other issue? please me resolve problem. <?php set_time_limit(0); $url = 'https://abcdefgh.s3.amazonaws.com/audio/1431428586_z3ptl.mp3'; $file = basename($url); $fp = fopen($file, 'w'); $ch = curl_init($url); curl_setopt($ch, curlopt_file, $fp); $data = curl_exec($ch); curl_close($ch); fclose($fp); header('content-description: file transfer'); header('content-type: application/octet-stream'); header('content-disposition: attachment; filename='.basename($file)); header('content-transfer-encoding: binary'); header('expires: 0'); header('cache-control: must-revalidate'); header('pragma: public'); header('c...

java - Compilation warning: Unchecked call to XXX as member of the raw type -

i getting compiler warning: warning: [unchecked] unchecked call setview(v) member of raw type abstractpresenter this.presenter.setview(this); where v type-variable: v extends abstractview declared in class abstractpresenter the code of abstractpresenter class following: public abstract class abstractpresenter<v extends abstractview, m> implements presenter<v, m> { private m model; private v view; @override public final v getview() { return this.view; } public final void setview(v view) { if (view == null) { throw new nullpointerexception("view cannot null."); } if (this.view != null) { throw new illegalstateexception("view has been set."); } this.view = view; } @override public final m getmodel() { return this.model; } protected final void setmodel(m model) { if (model == null) { ...

android - Getting error in viewpager adapter,java.lang.IllegalStateException: The specified child already has a parent -

i trying use viewpager images shows 1 picture if slides crashes, saying java.lang.illegalstateexception: specified child has parent. must call removeview() on child's parent first. adapter code is: public class newdemoadapter extends pageradapter { public arraylist<integer> imagelist; public arraylist<string> lines; public context context; private imageview imageview; private bitmapfactory.options bounds; private viewgroup viewpager; private bitmap cropimg; private layoutinflater minflater; public newdemoadapter(context context, arraylist<integer> imagelist, arraylist<string> line) { this.imagelist = imagelist; this.lines = line; } @override public int getcount() { return imagelist.size(); } public int getitemposition(object object) { return position_none; } @override public boolean isviewfromobject(view view, object object) { return v...

html - Scrambled elements when resizing -

html: <p style="margin-left:1250px; margin-top:70px;"><a href="">go main website</a></p> css: a { color: #000000; text-decoration: none; } html { background-color: #ffffff; -webkit-font-smoothing: antialiased; } body { margin: 0 auto; background-color: #ffffff; max-width: 100%; font-family: "helvetica neue", helvetica, arial, sans-serif; font-size: 16px; line-height: 1.5em; color: #545454; background-color: #ffffff; text-align: center; } whenever re-size browser's window "go main website" getting scrambled. help? see if helps css a { color: #000000; text-decoration: none; } html { background-color: #ffffff; -webkit-font-smoothing: antialiased; } body { margin: 0 auto; background-color: #ffffff; max-width: 100%; font-family: "helvetica neue", helvetica, arial, sans-serif; font-size: 16px; ...

c# - Binding Master Detail data to XtraReport Winforms DevExpress Programtically -

Image
am trying bind data (master details) xtrareport programmatic. if master single data/values means xtrareport working fine. in case master multiple data/values, here details data prints on masters . eg. (vehicle report) - here 1)cars & 2)bikes master, details of cars master bmw, datsun, hyundai . details of bike master honda, moto, yamaha . want print this report cars bmw datsun hyundai bikes honda moto yamaha but printing report cars bmw datsun hyundai honda moto yamaha bikes bmw datsun hyundai honda moto yamaha already place labels in designer xtrareports. code prints data on xtrareports programmatic private void report1_beforeprint(object sender, system.drawing.printing.printeventargs e) { try { strconnection = "provider=microsoft.ace.oledb.12.0;data source=" + properties.settings.default.datapath + @"cmdb\database.mdb"; string qry2 = ...

java - How to set a system property for the log4j2 JUL adapter in an OSGi environment -

i want use log4j2 jul adapter in osgi environment. directly used log4j2 osgi bundles , set following system property in 1 of custom osgi bundle mentioned here : system.setproperty("java.util.logging.manager", "org.apache.logging.log4j.jul.logmanager"); it seems system property not setting because logs coming java util framework not going appenders. the osgi framework i'm using eclipse equinox . where set system property work osgi? edit: as far understood here problem @ begging of jvm start required property i.e. java.util.logging.manager set default value, setting inside osgi environment not effective, cannot set property using -d option because log4j2 osgi bundles not exposed class path, class not found exception occurs. any highly appreciate on matter. generally, if setting property through system.setproperty api not work ok (maybe because property has been read before can overwrite it), should try setting jvm start, entering ...

forms - Radio Button INPUT not sending the input to the PHP code -

the code given below shows errors : <div class="field form-inline radio"> <form method="post" action=""> <div> <label><input type="radio" name="eatable" value="fruit_in"/> fruit</label> </div> <div> <label><input type="radio" name="eatable" value="vegetable_in"/> vegetable</label> </div> <div> <label><input type="radio" name="eatable" value="bread_in"/> bread</label> </div> <div> <label><input type="radio" name="eatable" value="milk_in"/> milk</label> </div> </form> <?php $veg = $_post['eatable']?> please can tell problem in code ? error says : notice: undefined index: eatable in c:\xampp\htdocs\k\upload.php on line 250 notice: undefined index caused, due $_post...

What is the difference between these two SQL Server connection strings -

when use following connection strings, first 1 working , second not working on system. may know difference between these 2 connections strings? dsn=abcd;database=db1;uid=userid;pwd=passwd and second one data source=abcd;database=db1;uid=userid;pwd=passwd error thrown second string [unixodbc][driver manager]data source name not found, , no default driver specified (0) (sqldriverconnect) i new using sql server, confused difference between dsn , data source there can many reasons why second connection string not working. need check why error "data source name not found , no default driver specified"? the odbc driver manager relies on driver attribute know odbc driver load.

pdf generation - PDF Parsing -- Extract single page -

i wrote program in python allowed me read in pdf, take commands user, , output part or of original pdf pages in different orders. select pages interested in. @ time, there great library it, pypdf2 . did of heavy lifting. now, working in language (haskell) has no pdf support can find. i'm considering making own personal library. however, when looking @ contents of pdf file, i'm finding hard determine specific pages are. can tell how many pages total there in file, can't @ specific part of file , say, "this page x of y." so, how separate out content based on pages? how split file based on pages, if don't know page content on? the first thing need copy of pdf specification. can download free adobe web site here: http://wwwimages.adobe.com/content/dam/adobe/en/devnet/pdf/pdfs/pdf32000_2008.pdf in document, @ section 7.7.3 explains how "page tree" works. basically, pdf file contains tree (adobe suggests should balanced tree you're ...

Matlab loop not working properly -

largest = 0; num = 0; temp = 0; num_flip = 0; x = 100 : 999 y = x : 999 num = x*y; temp = num2str(num); num_flip = str2double(fliplr(temp)); if num/num_flip == 1 largest = num; 1 = x; 2 = y; end end end i'm trying find largest palindrome made product of 2 3-digit numbers reason loop stops @ x = 924 , y = 962 know that's not answer. code works fine 2-digit numbers(10 : 99) though. you not testing if largest largest code. go through loops possible smaller palindrome detected after larger one, , reassigning largest it. try added test whether new palindrome larger current largest : largest = 0; num = 0; temp = 0; num_flip = 0; x = 100 : 999 y = x : 999 num = x*y; temp = num2str(num); num_flip = str2double(fliplr(temp)); if ((num/num_flip) == 1) && (num > largest) largest = num; end end end i removed these assignments ...

ios - How can I save the high score in sprite kit using swift? -

this question has answer here: how set high score in game sprite kit , swift 1 answer im complete beginner @ programming. in following code want save high score , can't manage that. you'll i'm using nsuserdefaults doesn't show in screen once game over. appreciated. want high score show on screen , doesn't. class wt: skscene { let showmessage = sklabelnode() let tryagain = sklabelnode() var highscore = sklabelnode() override func didmovetoview(view: skview) { backgroundcolor = skcolor.blackcolor() showmessage.fontname = "noteworthy-light" showmessage.fontsize = 55 showmessage.fontcolor = skcolor.redcolor() showmessage.text = "time's up!" showmessage.position = cgpoint(x: self.frame.size.width/2, y: self.frame.size.height*0.7) showmessage.name = "show message" showmessage.hid...

c# - How do I iterate through a directory stopping at a folder that excludes a specific character? -

i iterate through directory , stop @ first folder doesn't end in "@" this tried far (based on question site): string rootpath = "d:\\pending\\engineering\\parts\\3"; string targetpattern = "*@"; string fullpath = directory .enumeratefiles(rootpath, targetpattern, searchoption.alldirectories) .firstordefault(); if (fullpath != null) console.writeline("found " + fullpath); else console.writeline("not found"); i know *@ isn't correct, no idea how part. i'm having problems searchoption visual studio says "it's ambiguous reference." eventually want code name of folder , use rename different folder. final solution i ended using combination of dasblikenlight , user3601887 string fullpath = directory .getdirectories(rootpath, "*", system.io.searchoption.topdirectoryonly) ...

javascript - Leaflet js adding custom marker pic fails -

i trying add custom marker picture keeps giving me standard blue marker. here's custom marker definition: var amarker = { lat:location.lat, lng:location.lng, message: location.name, // focus: true, draggable: false, getmessagescope: function() { return $scope; }, message: '<button class="icon-left ion-information-circled" ng-click=""></button>&nbsp;&nbsp;&nbsp;'+location.name, compilemessage: true, 'icon': { 'type': "awesomemarker", // use awesomemarker font awesome 'icon': spotmarkericon, // variable icon } }; var spotmarkericon = l.icon({ iconurl: './images/spotm...

multithreading - Win32 Message Pump and std::thread Used to Create OpenGL Context and Render -

if have function following: bool foo::init() { [code creates window] std::thread run(std::bind(&foo::run, this)); while (getmessage(&msg, null, 0, 0)) { translatemessage(&msg); dispatchmessage(&msg); } } where run defined as: void foo::run() { [code creates initial opengl context] [code recreates window based on new pixelformat using wglchoosepixelformatarb] [code creates new opengl context using wglcreatecontextattribsarb] { [code handles rendering] } while (!terminate); } since window recreated on rendering thread, , message pump performed on main thread considered safe? function wndproc called on? above code considered bad design, not interested in. interested in defined behavior. a win32 window bound thread creates it. only thread can receive , dispatch messages window, , only thread can destroy window. so, if re-create window inside of worker thread, thread must take on respo...

python - Debugging Django admin panel bug -

when navigate admin interface particular model (the whole-table view), , hit 'save', error popping on usual red banner: please correct errors below. needless couldn't make edits view, until experimented , fixed it. here's class: class rolemapping(models.model): min_length, max_length = 3, 40 role_name = models.charfield(unique=true, max_length=max_length, validators = [ minlengthvalidator(min_length, "field length should greater {}".format(min_length)) ]) role_type = models.foreignkey(roletype, null=true, blank=true ) here's admin interface model. but, flipping around of editable fields seems have made things work. class rolemapping(admin.modeladmin): model = rolemapping list_display = ('role_name', 'role_type',) #list_editable = ('role_name', 'role_type',) # fails #list_editable = ('role_name',) # fails list_editable = ('role_type',) # w...

cmake - How to build fat libclang -

i able build llvm , clang on osx following tutorial: http://clang.llvm.org/docs/libastmatcherstutorial.html use cmake ninja this. then can find libclang.3.6.dylib under <path_to_llvm>/build/lib/libclang.3.6.dylib . problem library not fat . mean built x86_64 only. can verify with: lipo -info libclang.3.6.dylib this produces: non-fat file: lib/libclang.3.6.dylib architecture: x86_64 but need i386 i have few questions: how build fat (x86_64 + i386) libclang.dylib , libclang.a ? is possible build these libraries without rebuilding whole llvm, clang, tools etc (whole build takes few hours on machine) ? additional argument cmake "-dcmake_osx_architectures=x86_64;i386" did trick. guess works osx. now if run lipo , receive desired output. lipo -info lib/libclang.3.6.dylib architectures in fat file: lib/libclang.3.6.dylib are: x86_64 i386 but still have recompile whole llvm/clang project (takes few hours)

css - HTML formatting so that my form doesn't look bad -

this question has answer here: html form layout css 4 answers i'm trying make html form looks good. formatting little off. trying make form responsive. need first name , last name on 1 line. address on next. city , state on third , email , phone number on fourth , submit button , privacy link on last. have tried using table within table , wasn't good. my questions how fix fields line together. right address bar shorter others. lines different lengths , want make them same length , have them line correctly. here sample :before, :after { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } p, li { letter-spacing:-0.05vw; } h1 { letter-spacing:-0.3vw; } #p3 { background-color:white; } table { border:0; padding:0; border-collapse:collapse; } div { float:left; } ...