Daily Archives

Articles indexed Sunday April 11 2010

Page 6/79 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • using fopen on uploaded file with php

    - by Patrick
    Im uploading a file, and then attempting to use fgetcsv to do things to it. This is my script below. Everything was working fine before i added the file upload portions. Now its not showing any errors, its just not displaying the uploaded data. Im getting my "file uploaded" notice, and the file is saving properly, but the counter for number of entries is showing 0. if(isset($_FILES[csvgo])){ $tmp = $_FILES[csvgo][tmp_name]; $name = "temp.csv"; $tempdir = "csvtemp/"; if(move_uploaded_file($tmp, $tempdir.$name)){ echo "file uploaded<br>"; } $csvfile = $tempdir.$name; $fh = fopen($csvfile, 'r'); $headers = fgetcsv($fh); $data = array(); while (! feof($fh)) { $row = fgetcsv($fh); if (!empty($row)) { $obj = new stdClass; foreach ($row as $i => $value) { $key = $headers[$i]; $obj->$key = $value; } $data[] = $obj; } } fclose($fh); $c=0; foreach($data AS $key){ $c++; $phone = $key->PHONE; $fax = $key->Fax; $email = $key->Email; // do things with the data here } echo "$c entries <br>"; }

    Read the article

  • easy Switching to open folders on a mac

    - by Charles
    How do I easily switch to an open folder on a mac? In windows, which I'm used to using, I can see all my opened folders in my vertical taskbar, all i need to do to switch to another window is click on the folder in the task bar. There's no taskbar in mac, and when i have a lot of folders opened, ie, lots of finder windows, how can I switch between them? The way i'm doing it is, i put expose on an active corner and switch that way. However that's still damn hard, because first i have to bring up expose, and then find my window. The folders are placed in a random position between opened apps, the folders are not in a list, and on a big screen i have to scan the whole screen in order to find the one i want... etc. Is it really this hard just to switch to a different folder on a mac? :(

    Read the article

  • Local links ( in browsers ) on *nix systems

    - by meder
    On Windows I can access files directly from the browser ( or at least I have it configured currently, forget if it was native like this ) with the file:// protocol, so I can access files from say the C drive. I'm wondering what the equivalent would be to accessing my files from the browser, if at all possible on a *nix system such as Debian.

    Read the article

  • mac os x - detect file system read

    - by quano
    I want to know what files a specific application is trying to access on my disc. I know that you can use fs_usage, but this outputs events from all applications. I know that you can target a single application, but only one that is already running. I want to detect all readfile-events an application is trying to do, ever since it is started. I don't want to miss out on any event. How do you achieve this?

    Read the article

  • How to Store Cookies in Ruby?

    - by viatropos
    I am programmatcally accessing authenticated content in my CDN on Google App Engine, and it's returning a cookie that I'm supposed to store: {"set-cookie"=>"ACSID=cookie-hash; expires=Mon, 12-Apr-2010 01:56:06 GMT; path=/"} What do I do with that? This is my first time dealing with Cookies. I can put in the header of the next request, but what's the recommended way to store that? I'm testing this with irb in the console and when I exit and try again, the cookie is gone. How do I save it for a few days/weeks? I'm using pure ruby without Rails or anything. Thanks so much.

    Read the article

  • Storing URLs while Spidering

    - by itemio
    I created a little web spider in python which I'm using to collect URLs. I'm not interested in the content. Right now I'm keeping all the visited URLs in a set in memory, because I don't want my spider to visit URLs twice. Of course that's a very limited way of accomplishing this. So what's the best way to keep track of my visited URLs? Should I use a database? * which one? MySQL, sqlite, postgre? * how should I save the URLs? As a primary key trying to insert every URL before visiting it? Or should I write them to a file? * one file? * multiple files? how should I design the file-structure? I'm sure there are books and a lot of papers on this or similar topics. Can you give me some advice what I should read?

    Read the article

  • Hide/ change width/ change position of UIButton based on device type

    - by Giles Van Gruisen
    I'm using the new in-app SMS features in my iPhone app, but obviously iPod Touches aren't able to send and receive SMS without support of a third party app. I know all well how to detect the device and how to hide a UIButton, but what I do not know is how to change the width of the others. Above are the three icons. The one on the far rights needs to be hidden on an iPod Touch, and the other two need to adjust size/ position to fill the remaining space. Any tips on programatically changing the position and width of a UIButton is greatly appreciated. Thanks!

    Read the article

  • How to count each digit in a range of integers?

    - by Carlos Gutiérrez
    Imagine you sell those metallic digits used to number houses, locker doors, hotel rooms, etc. You need to find how many of each digit to ship when your customer needs to number doors/houses: 1 to 100 51 to 300 1 to 2,000 with zeros to the left The obvious solution is to do a loop from the first to the last number, convert the counter to a string with or without zeros to the left, extract each digit and use it as an index to increment an array of 10 integers. I wonder if there is a better way to solve this, without having to loop through the entire integers range. Solutions in any language or pseudocode are welcome. Edit: Answers review John at CashCommons and Wayne Conrad comment that my current approach is good and fast enough. Let me use a silly analogy: If you were given the task of counting the squares in a chess board in less than 1 minute, you could finish the task by counting the squares one by one, but a better solution is to count the sides and do a multiplication, because you later may be asked to count the tiles in a building. Alex Reisner points to a very interesting mathematical law that, unfortunately, doesn’t seem to be relevant to this problem. Andres suggests the same algorithm I’m using, but extracting digits with %10 operations instead of substrings. John at CashCommons and phord propose pre-calculating the digits required and storing them in a lookup table or, for raw speed, an array. This could be a good solution if we had an absolute, unmovable, set in stone, maximum integer value. I’ve never seen one of those. High-Performance Mark and strainer computed the needed digits for various ranges. The result for one millon seems to indicate there is a proportion, but the results for other number show different proportions. strainer found some formulas that may be used to count digit for number which are a power of ten. Robert Harvey had a very interesting experience posting the question at MathOverflow. One of the math guys wrote a solution using mathematical notation. Aaronaught developed and tested a solution using mathematics. After posting it he reviewed the formulas originated from Math Overflow and found a flaw in it (point to Stackoverflow :). noahlavine developed an algorithm and presented it in pseudocode. A new solution After reading all the answers, and doing some experiments, I found that for a range of integer from 1 to 10n-1: For digits 1 to 9, n*10(n-1) pieces are needed For digit 0, if not using leading zeros, n*10n-1 - ((10n-1) / 9) are needed For digit 0, if using leading zeros, n*10n-1 - n are needed The first formula was found by strainer (and probably by others), and I found the other two by trial and error (but they may be included in other answers). For example, if n = 6, range is 1 to 999,999: For digits 1 to 9 we need 6*105 = 600,000 of each one For digit 0, without leading zeros, we need 6*105 – (106-1)/9 = 600,000 - 111,111 = 488,889 For digit 0, with leading zeros, we need 6*105 – 6 = 599,994 These numbers can be checked using High-Performance Mark results. Using these formulas, I improved the original algorithm. It still loops from the first to the last number in the range of integers, but, if it finds a number which is a power of ten, it uses the formulas to add to the digits count the quantity for a full range of 1 to 9 or 1 to 99 or 1 to 999 etc. Here's the algorithm in pseudocode: integer First,Last //First and last number in the range integer Number //Current number in the loop integer Power //Power is the n in 10^n in the formulas integer Nines //Nines is the resut of 10^n - 1, 10^5 - 1 = 99999 integer Prefix //First digits in a number. For 14,200, prefix is 142 array 0..9 Digits //Will hold the count for all the digits FOR Number = First TO Last CALL TallyDigitsForOneNumber WITH Number,1 //Tally the count of each digit //in the number, increment by 1 //Start of optimization. Comments are for Number = 1,000 and Last = 8,000. Power = Zeros at the end of number //For 1,000, Power = 3 IF Power 0 //The number ends in 0 00 000 etc Nines = 10^Power-1 //Nines = 10^3 - 1 = 1000 - 1 = 999 IF Number+Nines <= Last //If 1,000+999 < 8,000, add a full set Digits[0-9] += Power*10^(Power-1) //Add 3*10^(3-1) = 300 to digits 0 to 9 Digits[0] -= -Power //Adjust digit 0 (leading zeros formula) Prefix = First digits of Number //For 1000, prefix is 1 CALL TallyDigitsForOneNumber WITH Prefix,Nines //Tally the count of each //digit in prefix, //increment by 999 Number += Nines //Increment the loop counter 999 cycles ENDIF ENDIF //End of optimization ENDFOR SUBROUTINE TallyDigitsForOneNumber PARAMS Number,Count REPEAT Digits [ Number % 10 ] += Count Number = Number / 10 UNTIL Number = 0 For example, for range 786 to 3,021, the counter will be incremented: By 1 from 786 to 790 (5 cycles) By 9 from 790 to 799 (1 cycle) By 1 from 799 to 800 By 99 from 800 to 899 By 1 from 899 to 900 By 99 from 900 to 999 By 1 from 999 to 1000 By 999 from 1000 to 1999 By 1 from 1999 to 2000 By 999 from 2000 to 2999 By 1 from 2999 to 3000 By 1 from 3000 to 3010 (10 cycles) By 9 from 3010 to 3019 (1 cycle) By 1 from 3019 to 3021 (2 cycles) Total: 28 cycles Without optimization: 2,235 cycles Note that this algorithm solves the problem without leading zeros. To use it with leading zeros, I used a hack: If range 700 to 1,000 with leading zeros is needed, use the algorithm for 10,700 to 11,000 and then substract 1,000 - 700 = 300 from the count of digit 1. Benchmark and Source code I tested the original approach, the same approach using %10 and the new solution for some large ranges, with these results: Original 104.78 seconds With %10 83.66 With Powers of Ten 0.07 A screenshot of the benchmark application: If you would like to see the full source code or run the benchmark, use these links: Complete Source code (in Clarion): http://sca.mx/ftp/countdigits.txt Compilable project and win32 exe: http://sca.mx/ftp/countdigits.zip Accepted answer noahlavine solution may be correct, but l just couldn’t follow the pseudo code, I think there are some details missing or not completely explained. Aaronaught solution seems to be correct, but the code is just too complex for my taste. I accepted strainer’s answer, because his line of thought guided me to develop this new solution.

    Read the article

  • Detect ANY touch in a view (iPhone SDK)

    - by David
    Hello, I'm currently using ... - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { to detect swipes. I've got everything working. The only problem is if the user touches on top of something (eg a UIButton or something) the - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { is not called. Is there something like touchesBegan but will work if I touch ANYWHERE on the view? Thanks in advance, David

    Read the article

  • Azure, SLAs and CAP theorem

    - by dayscott
    Azure itself is imo PaaS and not IaaS. Do you agree? MS gurantees an availability of 99% and a strong consistency. You can find MS SLAs here: http://www.microsoft.com/windowsazure/sla (three SLAs Uptime: http://img229.imageshack.us/img229/4889/unbenanntqt.png ) I can't find anyhing about how they are going to archive that. Do they do backups? If Yes: How do they manage consistency? According to the Cap theorem (http://camelcase.blogspot.com/2007/08/cap-theorem.html ) their claims are not realistic. 2.1 Do you know detailed technical stuff about the how they are going to realize the claims about consistency and availability? On the MS page you'll find three SLAs .docs, one for SQL Azure, the second for Azure AppFabric/.Net Services and the third for Azure Compute&Storage.(Screenshot in 1.) How can one track whether SLAs are violated? Do they offer some sort of monitor, so I don't have to measure the uptime by myself?

    Read the article

  • Passing parameters to custom RESTful routes in Rails (using :collection)

    - by dwhite
    I am trying to add a custom route to my RESTful routes using the :collection param on map.resources like so: map.resources :products, :collection => { :tagged => :get } The tagged action takes in a :tag parameter. I am able to link to the URL route using: tagged_products_path(:tag => tag.name). My issue with this is that the URL that this generates: /products/tagged?tag=electronic I would like the tag to be in the URL and not the tag, like so: /products/tagged/electronic Of course this can be accomplished by a separate named route, but I'm wondering if I'm missing something and there is a way to do this with the :collection hash. Thanks in advance for your help -Damien

    Read the article

  • triying to do a combo select with this.val() but it doesnt show the second select

    - by irenkai
    Im triying to do a combo where the when the user selects Chile out of the select box, a second select shows up showing the cities. The jQuery code Im using is this. $(document).ready(function(){var ciudad = $("#ciudad"); ciudad.css("display","none"); $("select#selectionpais").change(function(){ var hearValue = $("select#selectionpais").val(); if( hearValue == "chile"){ ciudad.css("display","block"); ; }else{ ciudad.css("display","none") } }); }); and the Html is this (abreviated for the sake of understanding) <select name="pais" id="selectionpais"> .... Chile Afganistán and the second select (the one that should be shown is this) <select id="ciudad" name="ciudad" class="ciudad"> Santiago Anyone has a clue why it isnt working?

    Read the article

  • $.each and animation confusion

    - by XGreen
    I am expecting when I go $.each($(something).find(something), function(){ $(this).delay(1000).fadeOut(); }); then for each matching element I get a second of delay before it is gone. but what I get is a second of delay and then it all fades out. its 3am and I can't think. please help

    Read the article

  • What are some design patterns that you know of for PHP OOP?

    - by Doug
    I recently learned a lot about MVC design pattern which is a very interesting concept. I would assume there are a lot more design patterns out there, and I thought it would be great for people to share some. Here's my contribution, MVC design pattern: http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller

    Read the article

  • How to add UIView to MKMap ??

    - by user128647
    How to add UIView to MKMap so that when we move map around, UIView also moves with map, i mean to say that generally when we add UIView (or any UI component) to MKMap and then if we either zoom / move map around, UIView remain fixed at its initial position, i need as map moves UIView also moves with it.

    Read the article

  • Can WD SmartWare be used on multiple computers?

    - by Matt
    I am wondering if I can use my portable Western Digital 1 tb drive and it's WD Smartware on 2 different computers (I have a desktop and a laptop) at the same time. So in essence, could it run two separate backups? I would even be happy if the portable external combined both data, as long as I had backups of each computer. Can anyone share some insight? Thank you.

    Read the article

  • "Android 2.x" vs "Google APIs" for Android AVD Setup

    - by Adam Haile
    In the Android AVD manager (or a new project for that matter), it will give two options for the same API level. For example, for Level 7 (2.1) it will show "Google APIs - Level 7" and "Android 2.1 - Level 7" in the selection drop down. What, if any, is the actual difference between these two and why would I want one over the other?

    Read the article

  • Lazy-loading flash objects

    - by friedo
    I'm using the jQuery lazy-loading plugin to defer loading of below-the-fold images on a large web page. This works great. Now, I would like to apply the same technique to a large Flash object which is also below-the-fold. I don't think the lazy-load plugin handles things that aren't images (at least it doesn't look that way so far.) I may have to do it myself. In that case, how do I detect when the area containing the Flash object becomes visible?

    Read the article

  • PLPGSQL : How to return a record from function executed by INSERT/UPDATE rule?

    - by seas
    Do the following scheme for my database: create sequence data_sequence; create table data_table { id integer primary key; field varchar(100); }; create view data_view as select id, field from data_table; create function data_insert(_new data_view) returns data_view as $$declare _id integer; _result data_view%rowtype; begin _id := nextval('data_sequence'); insert into data_table(id, field) values(_id, _new.field); select * into _result from data_view where id = _id; return _result; end; $$ language plpgsql; create rule insert as on insert to data_view do instead select data_insert(new); Then type in psql: insert into data_view(field) values('abc'); Would like to see something like: id | field ----+--------- 1 | abc Instead see: data_insert ------------- (1, "abc") Is it possible to fix this somehow? Thanks for any ideas. Ultimate idea is to use this in other functions, so that I could obtain id of just inserted record without selecting for it from scratch. Something like: insert into data_view(field) values('abc') returning id into my_variable would be nice but doesn't work with error: ERROR: cannot perform INSERT RETURNING on relation "data_view" HINT: You need an unconditional ON INSERT DO INSTEAD rule with a RETURNING clause. I don't really understand that HINT. I use PostgreSQL 8.4.

    Read the article

  • UITextView like iPhone Notes application

    - by Mark
    I am trying to recreate the Notes application. So far I got the following: textView = [[UITextView alloc] initWithFrame:CGRectMake(25.0, 30.0, 295.0, 214.0)]; textView.delegate = self; textView.backgroundColor = [UIColor clearColor]; textView.font = [UIFont fontWithName:@"MarkerFelt-Thin" size:19.0]; [self.view addSubview:textView]; The thing I dont know is how they were able to put the date on top like a header (it is within the UIScrollView that is obvious). Also under every text there is a line where did that came from. Does someone have an idea or a sample project I can take a look at?

    Read the article

  • Does XercesC contain an extensive logic of XMLSchema validation?

    - by seas
    Tried to implement a small XML validation tool with XercesC. For some reason I cannot use existing validators right from the box - I need some preprocessing and would like to combine it with validation in a single tool. I used DOM parser and specified DOMErrorHandler. Instead of a set of errors with detailed messages like I saw from xmllint for the same xml and xmlschema files, only one message appeared that document has a wrong structure without details. Probably, I did something wrong. But also assume XercesC doesn't contain xmllint functionality right from the box. Does anybody can give me a hint before I spent too much time? Thanks.

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >