Posts

Showing posts from March, 2011

arrays - Python (scipy) import time from text file -

i have text file: 2010-05-16 2010-09-26 2011-04-28 each line string: yyyy-mm-dd my goal read text file , write information array. import scipy sp x=sp.empty(200,ftype=sp.datetime64) file=open(place,'r') p in file: x[i]=p but not work. see "an error". how can solve task? know can use panda need write scipy array. try this: import numpy np x = np.empty(200, dtype='datetime64[d]') open(place, 'r') f: i, date in enumerate(f): x[i] = date.strip() firstly, it's dtype , not ftype . then, need use datetime64[d] since date, not date , time. then, date has newline @ end, results in parse error ( strip() fixes this). might want use np.zeros() instead of np.empty() . you can access these methods through scipy well, they're technically part of numpy, use import numpy np .

asp.net - Object reference not set to an instance of an object -

this question has answer here: what nullreferenceexception, , how fix it? 32 answers i new asp.net mvc , cannot find solution how make selectable dropdown list. my model: public class parentcategory { public int id { get; set; } [required] [display(name = "parent category name")] public string pcatname { get; set; } [required] [display(name = "urlseo")] public string urlseo { get; set; } [required] [display(name = "description")] public string pcatlogo { get; set; } public icollection<childcategory> childcategories { get; set; } } public class addparentcategoryviewmodel { public int id { get; set; } public string pcatname { get; set; } public string urlseo { get; set; } public string pcatlogo { get; set; } } my controller [htt

javascript - pdf2json gives me a blank output txt file? -

i following "code example" guide on github. https://github.com/modesty/pdf2json#code-example in example says "parse pdf write .txt file (which contains textual content of pdf)", copied , pasted exact implementation local javascript file , called output text file blank. 'use strict'; let fs = require('fs'); let pdfparser = require("pdf2json"); let pdfparser = new pdfparser(); pdfparser.on("pdfparser_dataerror", errdata => console.error(errdata.parsererror) ); pdfparser.on("pdfparser_dataready", pdfdata => { fs.writefile("./node_modules/pdf2json/test/f1040ez.content.txt", pdfparser.getrawtextcontent()); }); pdfparser.loadpdf("./node_modules/pdf2json/test/pdf/fd/form/f1040ez.pdf"); is doing wrong? or not work on part? there alternatives pdf text converters nodejs without additional binaries installed? the frontpage documentation bit wrong! in order make work set pdfparser

java - I get error (1, 19) when tapping on multiple buttons that play sound -

it works few buttons, when tap 6 of them work. ones don't work give error (1, -19). media player state wrapper set up, if need use states of "mp"s, let me know. public class soundfile { public soundfile(final activity activity, final string soundfile, int imgbuttonid, arraylist<mediaplayerstatewrapper> mps) { this.mp = new mediaplayerstatewrapper(); try { this.afd = activity.getassets().openfd(soundfile + ".mp3"); } catch (ioexception e) { e.printstacktrace(); } this.allmps = mps; mps.add(this.mp); this.position = (imagebutton) activity.findviewbyid(imgbuttonid); this.position.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { try { mp.reset(); mp.setdatasource(afd.getfiledescriptor(), afd.getstartoffset(), afd.getlength());

replace words from string having more than 6 digits regex php -

i want replace words string having more 6 digits. example: 'my contact no (432)(323)(322). other number +1239343. 1 343as32240' to: 'my contact no [removed]. other number [removed]. 1 [removed]' i aware of regex , preg_replace. need correct regex this. you can use regex search: (?<=\h|^)(?:[^\h\d]*\d){6}\s* and replace [removed] . breakup: (?<=\h|^) # loookbehind assert previous position line start or whitespace (?: # start of non capturing group [^\h\d]*\d # 0 or more non-space , non-digits followed 1 digit ) # end of non capturing group {6} # match 6 of group \s* # followed 0 or more non-space characters code: $result = preg_replace('/(?<=\h|^)(?:[^\h\d]*\d){6}\s*/', '[removed]', $str); regex demo

asp.net - Dynamically create data table based on incoming Excel data in C#? -

i'm trying import excel sheet data table in c#. keep getting out of bounds exception because columns value being hard coded me. for (int c = 0; c <40; c++) { ... } so rather hard coding , having bunch of empty columns listed on data table, there way count columns being passed in before create table? thereby allowing me create table dynamically around incoming data? below code. if (fileupload.hasfile) { datatable dt = new datatable(); (int c = 0; c <40; c++) { dt.columns.add(c.tostring(), typeof(string)); } using (stream filestream = fileupload.postedfile.inputstream) using (streamreader sr = new streamreader(filestream)) { string = null; while ((a = sr.readline()) != null) { dt.rows.add(a.split(new char[] { ',' }).toarray()); } } gridview1.datasource = dt; gridview1.databind(); try using instead: datatable dt;

spring-boot-configuration-processor 1.3.3.RELEASE (or 1.3.0.RELEASE) gives compile error with Maven 3.0.4 -

i'm using spring-boot-configuration-processor 1.3.3.release maven 3.0.4 , maven-compiler-plugin:3.3 , gives compile error when using jdk 1.7. compile error gives no details either , in fact if have single interface class compile still fails. what odd if use jdk 1.8 or spring-boot-configuration-processor 1.2.6.release compilation works fine. here output of compilation. c:\git-repos\alpha>mvn -e -x clean compile apache maven 3.0.4 (r1232337; 2012-01-17 03:44:56-0500) maven home: c:\xxx\fc-maven java version: 1.7.0, vendor: oracle corporation java home: c:\temp\jdk1.7_64\jre default locale: en_us, platform encoding: cp1252 os name: "windows 7", version: "6.1", arch: "amd64", family: "windows" ... [debug] === reactor build plan ================================================ [debug] project: com.xxx.xyz:alpha:jar:5.0.0 [debug] tasks: [clean, compile] [debug] style: regular [debug] ============================================

swift - Facebook login for iOS error: The operation couldn’t be completed. (com.facebook.sdk.core error 3.) -

i'm receiving error code: the operation couldn’t completed. (com.facebook.sdk.core error 3.) for logging facebook on app , not sure why. here viewcontroller code: import fbsdkcorekit import fbsdkloginkit @iboutlet weak var facebookloginbutton: fbsdkloginbutton! override func viewdidload() { super.viewdidload() facebookloginbutton.readpermissions = ["public_profile", "email", "user_friends"] facebookloginbutton.delegate = self } //mark: facebook login func loginbutton(loginbutton: fbsdkloginbutton!, didcompletewithresult result: fbsdkloginmanagerloginresult!, error: nserror!) { if error == nil { print("login complete") performseguewithidentifier("facebooksegue", sender: self) } else { print(error.localizeddescription) } } func loginbuttondidlogout(loginbutton: fbsdkloginbutton!) { print("user logged out") } here appdelegate: import fbsdkco

ruby - Delete item from array without returning it -

i'm trying write method cause rspec test pass: it "starts thing , move on" class.method_1("name one") class.method_1("name two") expect(class.method_2).to eq "some string name one" expect(class.method_3).to eq ["name two"] end method_1 adds name array, , method_3 returns array (defined in initialize method): def method_1(name) @array << name end def method_3 @array end i figured pretty simple interpolate @array[0] string , use @array.delete_at(0) modify array. so: def method_2 p "some string #{@array[0]}" @array.delete_at(0) end but method returns "name one" instead of string. if comment out delete code, string returns array hasn't been modified. i've been in ruby docs long time #shift has same issue returning removed item. i'm i've on complicated -- missing? you can collapse down more conventional ruby this: class mytestclass attr_reade

java - Android: Timed out error while waiting for emulator to come online in mac? -

i found related post . have simple app displays button on screen. use mac os, latest android studio, , java 8. can launch android without app, android: timed out after 300seconds waiting emulator come online error app. simulator setting 1 gb ram, 512 vm heap, nexus 5x, marshmallow (android 23). how can identify problem , app run without reinstall everything? from console: /users/me/library/android/sdk/tools/emulator -netdelay none -netspeed full -avd nexus_5x_api_23 hax enabled hax ram_size 0x40000000 hax working , emulator runs in fast virt mode. console on port 5554, adb on port 5555 from app console: 06/10 19:25:48: launching app error while waiting device: timed out after 300seconds waiting emulator come online. try changing graphics option on avd manager software or try combinations.

Shiro custom realm restrict simple auth to certain users -

i'm using shiro , have custom realm. app has many users in database, , want support non-user process accounts api access. in realm, have implemented: public boolean supports(authenticationtoken at) protected authenticationinfo dogetauthenticationinfo(authenticationtoken authctoken) protected authorizationinfo dogetauthorizationinfo(principalcollection principals) this works great, have login form , process un/password no problem. i want allow users able use basic http auth, , rest use form auth working. can set ini allow either method don't see how implement check type of authentication used in realm. if login attempt non-api user authenticated via http headers, want reject request. how do this, write filter , check http header way can think of. i did following make work: add "api" role users create application class , set applicationpath /api rest endpoints wanted expose restricted /api path authcbasic, role[api] in shiro.ini

java - Communication to DB error in production -

this question has answer here: is safe use static java.sql.connection instance in multithreaded system? 2 answers i did web app deploy in production. after several hours (looks 8 hour), can't communicate db. here connect.java package util; import java.sql.connection; import java.sql.drivermanager; import javax.xml.ws.response; public class connect { public static connection connection = null; public static connection getconnection() { if (connection != null) { return connection; } else { string driver = "com.mysql.jdbc.driver"; string url = "jdbc:mysql://localhost/dbprk?autoreconnect=true&useunicode=true&characterencoding=utf8"; string username = "prk"; string password = "prk"; try { class.forname(

Javascript: Audio from local file not playing without HTML "<audio>" element present -

now 1 has me stumped, hoping see if spot doing things incorrectly. so essentially, have page 2 elements. 1 html5 file handler, , second button. when user selects file respond onchange event generated, decoding audio , constructing buffer used. know there html5 audio tag, going utility needs able break file manageable chunks. i have done several tests , have found audio decode myself play after audio element on page has been played. have absolutely no idea causing behavior, since have studied several examples online on playing audio. include audio engine below. just clarify, handled code. thank you. "use strict"; var audiofile = function (){ this.length = 0; // number of samples this.duration = 0; // time in seconds this.samplerate = 0; // sample rate this.channels = 0; // number of channels this.data = []; //audio/waveform data }; var audioctx = null; class audioengine { constructor (){ // of necessary audio control variables if(!audioctx)

javascript - Is this the best pattern for creating objects that have been JSON serialized? -

i'm working on project have nice set of objects serialize , send down wire when user calls rest api. problem json.stringify() , json.parse() not support methods, private data , properties defined object.defineproperty/defineproperties ; publicly visible fields [de]serialized. i haven't come across many examples of consumer of javascript api deserializing response payload pojo members, properties, etc. simple pattern i've come isn't interesting , i'm wondering if there more common or superior patterns accomplishing same thing? consider example: var mytype = function(name, age) { this._name = name; this._age = age; } // add properties object.defineproperties(mytype.prototype, { 'name': { get: function() {return this._name;} }, 'age': { get: function() {return this._age;} } }); // add method mytype.prototype.tostring = function() { return this._name + ' ' + this._age; } // add 'static' deserialize met

swift - Retrieving an array from Firebase -

this question has answer here: how retrieve objects firebase key value 2 answers i have array in firebase composed of 1's , 0's (true , false basically), stored separate key/value pairs. retrieve them firebase , append each value array in swift. i have tried (found elsewhere on so ) not working. let ref = firebase(url:"https://<<unique>>.firebaseio.com/users/\(self.uuid)/scorearray") ref.observesingleeventoftype(.value, withblock: { snapshot in if snapshot.value nsnull { print("snap null") } else { let enumerator = snapshot.children while let rest = enumerator.nextobject() as? fdatasnapshot { self.scorearray.append(rest.value! as! string) } } }) it doesn't crash, doesn't fill array, though if print(rest.value) give me

sql - Stored procedure not returning any data for the date passed -

i have stored procedure takes 1 parameter date . return data date table. alter procedure [dbo].[userreportdata] @as_ondate datetime begin declare @reportdate datetime --declare @opening int select * #temptable (select a.cuser_id, b.user_id, a.u_datetime reportdate inward_doc_tracking_trl inner join user_mst b on a.cuser_id = b.mkey , a.u_datetime = @as_ondate) x declare cur_1 cursor select cuser_id, user_id #temptable open cur_1 declare @cuser_id int declare @user_id int fetch next cur_1 @cuser_id, @user_id while (@@fetch_status = 0) begin select u_datetime inward_doc_tracking_trl u_datetime = @as_ondate update #temptable set reportdate = @reportdate cuser_id = @cuser_id , user_id = @user_id

magento - Create Custom layout module -

hi created custom module in magento , frontend doesn't work. the config file : <?xml version="1.0"?> <config> <modules> <shareino_sync> <version>0.1.0</version> </shareino_sync> </modules> <global> <helpers> <sync> <class>shareino_sync_helper</class> </sync> </helpers> <blocks> <sync> <class>shareino_sync_block</class> </sync> </blocks> </global> <frontend> <routers> <sync> <use>standard</use> <args> <module>shareino_sync</module> <frontname>shareinosync</frontname> </args> </sync> </routers> <layout> <updates> <sync> <

express - How to show username on dropdown button using React-Bootstrap and EJS? -

i show username on dropdown button after users log in site. but, how done using react-bootstrap? my code dropdown button looks this. <dropdownbutton title="dropdown" id="bg-nested-dropdown"> <menuitem eventkey="1">account</menuitem> <menuitem eventkey="2">log out</menuitem> </dropdownbutton> i want change title username he/she can confirm logged in seeing username on dropdown button. i can retrieve username using ejs. <% if (!user) { %> text <% } else { %> <%= user.username %> <% } %> but, want show username( user.username ) on dropdown button. you can do: <dropdownbutton title="dropdown" id="bg-nested-dropdown"> <menuitem eventkey="1">account</menuitem> <menuitem eventkey="2">log out</menuitem> { user ? <menuitem eventkey="x">{ user.username }</menuitem> :

mongodb - Populate nested array in mongoose - Node.js -

Image
these schemas (topic parent , contains list of 'thought's): var topicschema = new mongoose.schema({ title: { type: string, unique: true }, category: string, thoughts: [thoughtschema] }, { timestamps: true, toobject: {virtuals: true}, tojson: {virtuals: true} }); var thoughtschema = new mongoose.schema({ text: string, author: {type: mongoose.schema.types.objectid, ref: 'user'}, votes:[{ _id:false, voter: {type: mongoose.schema.types.objectid, ref: 'user'}, up: boolean, date: {type: date, default: date.now} }] }, { timestamps: true, toobject: {virtuals: true}, tojson: {virtuals: true} }); .... i trying read thought's author , change topic api this: ... var cursor = topic.find(query).populate({ path: 'thoughts', populate: { path: 'author', model: 'user' } }).sort({popularity : -1, date: -1}); return cursor.exec() .then(respondwithresult(res)) .ca

Convert Rewrite Rule Prefix Matching from Apache to Nginx -

how convert apache's prefix matching nginx? rewritecond %{request_uri} ^/test1 rewriterule ^(.*)$ http://newsite/$1 [r=301,l] rewritecond %{request_uri} ^/foo rewriterule ^(.*)$ http://newsite/$1 [r=301,l] rewritecond %{request_uri} ^/bar rewriterule ^(.*)$ http://newsite/$1 [r=301,l] or rewriterule ^/test1/(.*)$ http://newsite/test1/$1 [r=301,l] rewriterule ^/foo/(.*)$ http://newsite/foo/$1 [r=301,l] rewriterule ^/bar/(.*)$ http://newsite/bar/$1 [r=301,l] is this? location / { rewrite ^/(test1|foo|bar)/(.*)$ http://newsite/$1/$2 permanent; ... } your rewrite not bad. work. thing people prefer return directive in nginx because little faster ( nginx needs less processing). i'm not familiar apache rewrites might wrong in interpretation of them believe want rewrite urls under /test1 , /foo , /bar . purpose not need rewrite directive, can make simple return in nginx location /test1 { return 301 http://newsite$request_uri; } loc

scapy - Angle brackets in Python -

this question has answer here: difference between __str__ , __repr__ in python 17 answers i want craft packets using scapy. when looking through ip() class members came across following code idiom: 'fieldtype': { 'frag': <field (ip,iperror).frag>, 'src': <field (ip,iperror).src>, 'proto': <field (ip,iperror).proto>, 'tos': <field (ip,iperror).tos>, 'dst': <field (ip,iperror).dst>, 'chksum': <field (ip,iperror).chksum>, 'len': <field (ip,iperror).len>, 'options': <field (ip,iperror).options>, 'version': <field (ip,iperror).version>, 'flags': <field (ip,iperror).flags>, 'ihl': <field (ip,iperror).ihl>, 'ttl': <field (ip,iperror).ttl>,

javascript - Unusual object definition -

i stumbled upon this, eyes, strange object declaration. var config = {}; { config.foo = 'foo'; config.bar = 'bar'; }; it works, though have guessed wouldn't. confused open console in chrome devtools, , enter: var = {}; // => undefined nothing strange far. enter: { a.b = 'b'; } // => uncaught syntaxerror: unexpected token . ok, hmm ... wasn't supposed work? try, without separate evaluations of statements: var = {}; {a.b = 'b'}; // => "b" hmm, no syntaxerror thrown. , if evaluate a, can see defined intended. a; // => object {b: "b"} what happening? i've tried google it, don't know search for, , lack kind of knowledge figure out happening. can please explain it? to add on has been said.. in javascript, object literal: {x: 3} and block: { console.log("hello, world!"); } any statement can go inside of block. the trouble is, {x: 3} interpreted block

ASP.Net MVC 5 Routing wildcard + querystring -

i using route filter [route("search/{*segments}")] this takes segments providing many. here example http://localhost:50877/search/c_50_showcases%5e-displays/a_brand-name:33113319_balt:1623762%7cmooreco:1672386/a_total-number-of-shelves:33111115429_5:3138:lt/so_ts now need query string route unable make work. http://localhost:50877/search/?query=hp%20designjet&items=hew51645a|eli75220 it gives me 403 error. the web server configured not list contents of directory how can make route can take wildcard , query string handle incoming request. bound use search in route . also tried http://localhost:50877/search/test?query=hp%20designjet&items=hew51645a|eli75220 it works effects seo. defining action , route way: [system.web.mvc.route("search/{*segments}")] public actionresult search(string segments, string query, string items) allows wildcard (in segments variable) , query string parameters (query , items)

Pass List of Strings to Java method -

i have question how use java method boolean[] hasroles(list<string> roleidentifiers) . how can send list of strings? the method returns boolean[] not boolean error complaining how use result list<string> data = ...; if (currentuser.hasroles(data)) // not work boolean[] if not boolean you need check element of boolean[] one alternative check hasallroles return boolean or check specific roles interested in index.

c++ - Visual Studio, find/replace text within all files inside a certain Filter (of Solution Explorer) -

after searching 1 month, still don't find how it. i using visual studio 2015, , create lot of filter in solution explorer. all of .cpp , .h, in same windows folder, in different visual studio's filter. i want replace words of files within filter e.g. replace occurrences of "customarray()" "ca". i don't want action take effect on whole project. i tried :- edit > find in file but didn't find option limit affect filter. is there way achieve it? edit i want affect files inside filter. i don't want solution affect files inside window folder. example the whole project consists of files f1.h, f2.h, , f3.h. they inside c:/fs (without subdirectory), f1.h & f2.h inside a_filter_name filter. i want one-pop-up solution of "replace all" affect f1.h & f2.h. close files, open files filter (select of them shift+click, in windows explorer, , press enter), in search form use option "all

javascript - THREE js proper removing object from scene (still reserved in HEAP) -

Image
what proper way remove mesh form scene? in example: removable_items = []; box = new three.object3d(); scene.add(box); function add() { var mesh = new three.mesh( new three.icosahedrongeometry( 10, 5 ), new three.meshphongmaterial( {color: 0xffffff}) ); box.add( mesh ); removable_items.push(mesh); //clean(); ///// when integrated in function memory cleaned } function clean() { if( removable_items.length > 0 ) { removable_items.foreach(function(v,i) { v.parent.remove(v); }); removable_items = null; removable_items = []; } } function makeexperiment(r) { var = 0; while (i < r) { add(); i++; if( r === ) console.log(r+' finnished '); } } makeexperiment(50); /// after mannualy set clean(); meshes not visible @ scene anymore, expected, sill using memory, after time finis

Audio is playing twice in Android Media Player -

in application i'm having method responsible playing file placed under raw directory. when ever call function in onresume() method, sound played twice. have googled , tried different solutions. checking mediaplayer.isplaying() , stopping mediaplayer instance still didn't help. private void englishsound(){ if(mediaplayer1!=null){ if(mediaplayer1.isplaying()){ mediaplayer1.stop(); } mediaplayer1.reset(); mediaplayer1.release(); } mediaplayer1 = mediaplayer.create(this, r.raw.p012); mediaplayer1.start(); } public void onresume() { super.onresume(); englishsound(); } and englishsound() called no else in whole activity. have tried debugging never enters if block containing isplaying() . try release onpause() public void onpause() { super.onpause(); if(mediaplayer1 != null) mediaplayer1.release(); }

google places api - How to pause a FOR loop in Javascript in a function? -

there's query per second limit in google places api, need slow down loop sends requests: function callback(results, status) { if (status != google.maps.places.placesservicestatus.ok) { alert(status); return; } (var = 0, result; result = results[i]; i++) { requestinfo(result); } } any idea how can that? i'm bit of newb. recursive solution, function requestinfowrapper(results, i) { = + 1; if (i >= results.length) {return}; requestinfo(results[i]); settimeout(function() {requestinfowrapper(results, i);}, 1000); } some example code test it, var results = ["test 1", "test 2", "test 3"]; function requestinfo(str) {console.log(str);} requestinfowrapper(results, -1); also integrated code be, function callback(results, status) { if (status != google.maps.places.placesservicestatus.ok) { alert(status); return; } requestinfowrapper(results, -1); }

html - How to align Navigation Menu to center? -

i need align website's nav menu center. here code. what's wrong it? not align menu center. html <div class="menu_nav"> <ul style="font-family:ubuntu"> <li><a href="index.html">home</a></li> <li><a href="activities.html">activities</a></li> <li><a href="games.html">games</a></li> <li><a href="about.html">about us</a></li> <li><a href="contact.html">contact us</a></li> </ul> </div> css .menu_nav { text-transform: uppercase; margin: 0 auto; } .menu_nav ul { list-style: none; margin: 0 auto; } .menu_nav ul li { margin: 0 auto; padding: 0 auto; } .menu_nav ul li { display:block; margin: 0 auto; padding:35px 50px; color:#fff; text-decoration:none; font-size:20px;

Any good suggestions for refactoring the following javascript code? -

any ideas or suggestions more concise way refactor code? maybe loop solution or that? this._featuredimage = '../../../../../../../../content/images/' + this.post.slug + '.jpg'; this._checkimage(this._featuredimage, function() { // image exists this.featuredimage = this._featuredimage; }.bind(this), function() { // image doesn't exist this._featuredimage = '../../../../../../../../content/images/' + this.post.slug + '.png'; this._checkimage(this._featuredimage, function() { // image exists this.featuredimage = this._featuredimage; }.bind(this), function() { // image doesn't exist this._featuredimage = '../../../../../../../../content/images/' + this.post.datestamp + '.jpg'; this._checkimage(this._featuredimage, function() { // image exists this.featuredimage = this._featuredimage; }.bind(this), function() { // image doesn't exist this._featuredimage = '../../../../../../../../cont

jquery - Retain radio button state that affects other elements -

i have form lots of inputs. using jquery if person selects answer "yes" text box appears if click "no" nothing appears. problem when person submits page , page runs through php validation if throws page (incurs reload) error while can radio button remember value chosen (using php) not re-show textbox if user clicked yes. basically: user picks yes, text box shows. user submits page, page thrown due validation error. radio button remembers state "yes" text box not shown unless re clicking yes. any idea how can textbox show up? jquery $("input[name='radiobutton']").change(function(){ if ($(this).val() == "yes") { $("#txt1").show(); } else { $("#txt1").hide(); } }); you can checked radio button on page load: $(document).ready(function(){ if($("input[name='radiobutton'][value='yes']").is(':checked')) $(&qu

pointers - Array address in c++ -

i have code : int n; cin >> n; int array[n]; (int = 0; < n; ++i) { cin >> array[i]; } int tmp[n - 1]; tmp[0] = 1; with input : 1 10 found value of array[0] changed , instead of 10 has same tmp[0] . then realized input length of tmp[] became zero. print address of array[] , tmp[] with: printf("%d\n %d\n", array, tmp); and found had same address. i want figure out happen if array has length of 0; tried this: int array[1]; array[0] = 10; int tmp[0]; tmp[0] = 1; address: array[]: 1363909056 tmp[] : 1363909052 it looks previous code (except input part). tmp[0] , array[0] has different values , address now. and i'm confused tmp has smaller address array . so question is: what happen if declare array of length zero? why these 2 codes works different? (they same me :) ) this called "undefined behavior". after declaring, in case int tmp[0]; the next thing happens is: tmp[0]=1; since tmp[

Android - change preference category color on marshmallow -

Image
i want change v7 preferencecategory text , divider color. i have viewed question: preferencefragmentcompat requires preferencetheme set , i've added style: <style name="appthemenoactionbar.listseparatortextview"> <item name="android:textsize">14sp</item> <item name="android:textstyle">bold</item> <item name="android:textcolor">@color/website_main</item> <item name="android:paddingtop">8dp</item> <item name="android:layout_marginbottom">2dp</item> </style> and works on kitkat, have checked on marshmallow , that: (gray title instead of blue) how can change this?

android - Bitmap caching doesn't work -

i'm trying cache downloaded bitmaps using google code it's not working me. i download code article: http://developer.android.com/training/displaying-bitmaps/cache-bitmap.html and used in code, couldn't find example using guess may not using correctly. in oncreate have line: init(new imagecacheparams(this, this.getapplicationcontext().getcachedir().getpath())); the init methods: private void init(imagecacheparams cacheparams) { mcacheparams = cacheparams; // set memory cache if (mcacheparams.memorycacheenabled) { if (buildconfig.debug) { log.d(tag, "memory cache created (size = " + mcacheparams.memcachesize + ")"); } // if we're running on honeycomb or newer, if (utils.hashoneycomb()) { m