« first day (2169 days earlier)      last day (2764 days later) » 

12:03 AM
Hello, what's the best php framework in your opnion?
 
12:48 AM
0
A: Which one of the following PHP array structure would be using less memory?

SherifTL;DR; the second takes up more memory. While @Andrea's answer is is great, I figured I'd provide just a little more insight into the internals aspect of calculating PHP memory accurately. Because memory_get_usage() doesn't accurately represent the amount of memory a particular data structure ...

I know it's old, but old questions need love too?
 
Immediate boo at PHP 5
:-)
 
Yea, but in all fairness I wrote that extension like 3 years ago. There was no PHP 7 then :p
 
And you were too lazy to quickly port it right now? pfffz :-P
 
@bwoebi More like, I don't care enough to port it. I mean, how many people actually find knowing the exact array size in PHP useful?
I wrote a lot of useless extensions back then.
 
I'd find a tool giving ancestors useful for debugging sometimes… I.e. what is referencing an array/object/reference
 
12:55 AM
@bwoebi I wrote that too. gist.github.com/srgoogleguy/5796925
Or you mean like a reverse array value to key?
But yea, pretty much useless for anything other than debugging.
 
@Sherif that's just for variables… I mean, I have an object and I want to know all the references to it in the whole program
 
If you're actually doing that you're crazy.
@bwoebi Ahh, I had one for objects too, but also not PHP 7 compatiable :/
You can give it the object and tells you all variables in the global/local symbol table that reference it.
Also, just as simple to write though.
 
@Sherif no, not just symtables; everywhere.
Every array and object referencing the object
 
@bwoebi You mean like expressions too?
 
?
 
1:00 AM
@bwoebi It just inspects the symtables for the pointer. It doesn't evaluate any constructor dereferencing expressions, if that's what you're saying. It can dig into arrays and other object properties.
I had a bug with recursion though. The recursion guard was shoddy at best.
 
It can dig into arrays and other object properties.
^ that's what I meant
 
@bwoebi Right, that's still fairly trivial though. You just do recursive search for the pointer.
 
good, I'd appreciate if this could be part of phpdbg
 
Are you asking for a feature request?
 
Somewhat, yes ^^
 
1:02 AM
:p
Well... I have been meaning to actually dig into PHP 7 internals at some point. Maybe I will do that this weekend.
Oh God, I just vomited in my mouth a little. I'm getting back into PHP internals.
 
1:21 AM
@Sherif you … should shed tears of joy instead…
 
@bwoebi Why?
 
@Sherif well… php is not that bad^^
It's been worse
 
2:09 AM
@bwoebi Yea, it wasn't PHP I had the problem with ;)
 
 
1 hour later…
Wes
3:28 AM
mornggng
 
o/
I'm feeling ranty
we just lost a very tight hockey game. grrr. searches for random new javascript framework
 
Wes
so canadian :B
 
Hi everybody, I asked a question earlier and it's either I havn't understand how MySQL Load data infile work or it really don't fit my exact need, but I have a large (102000 lines) csv file that I need to import into different tables in MySQL, so I wrote a little script to insert the data, my only concern is about "parent_id" field, I need to be able to insert an id on this field that come from a mysql search (i supose? SELECT id from parent_table WHERE parent_table.name = CSVDATA_PARENTNAME
I havn't looked at this syntax yet...) am I on the right way ? Since the search functionnality will eat a lot of memory I need to make sure i'm right, before I invest more time...
 
@Wes :)
seriously. we had a great two first periods, then crumbled in the third. lost by one goal, scored at 7 seconds from the end. :(
 
Wes
how can you have goals without a ball? #neverwatchedahockeygameever
 
3:34 AM
lolcat
 
Wes
@JonathanLafleur do it with php?
 
@Wes that's what I do right now
and I wrote all the code to insert all the information, but now I still need the code to insert the parent_id everywhere
@Wes any sugestion ?
 
Wes
that looks right
how many times are you going to do that?
 
Normaly I should not modify this db after it's created :P
 
Wes
why worry about performance then :B
 
3:44 AM
but if you mean about the search... there is 10200 cities
Because my first version that I invest my whole day was so slow that it never worked :P when I came to the massive search it was hanging forever (hopefuly I had set a timeout after 30 minutes)
That's a CSV file that is really hard to work with :| there's a lot of collumn that I will not use, but let's say the most important

continent, country, state, sub_state, city
A,AB, ABC, ABCD, F
A,AB, ABC, ABCD, G
A,AB, ABC, ABCD, H
A,AC, BC, CD, I
A,AC, BC, CD, J
A,AC, BC, CD, K

And I need to create 5 tables based on that... with reference to know wich city goes where and state etc...
and i'm really stressed about running 5 time

while (($data = fgetcsv($handle, 0, ",")) !== FALSE) {

when I have that much entries on it :|
better way to run it 5 time ? :|
 
@JonathanLafleur There is something I can't seem to figure out. You mean one of the field of each csv row figures a value that is already present elsewhere in your database?
also you may want need to index the fields on which you join rows, or terrible performance can be had.
 
@FélixGagnon-Grenier you just make me realise one thing tho.. I will need to run it 6 time.... one to create array with unique value, the way the csv is done I will have the same amount of Canada in coutry that we have city...
damn
but the 5 others time will be directly on an array instead of read the csv again
 
3:59 AM
If you're trying to solve a #problem and you get stuck, you're probably trying to solve more than one problem at a time.
Your problem is actually much simpler than you're making it out to be. You just need to break it down into smaller chunks. 1) Assemble the PHP array structure such that it's a multi dimensional map keys that map Continentsto Countries and countries that map to States/Sub States/whatever and those map to cities.
2) Take that data structure and build your tables with it. It'll be much easier from there.
That can all be done in a single loop if you just spend enough time breaking down the things the loop does into smaller, more isolated, pieces of code that are easy to test.
i.e. functions.
 
@Sherif that's what I've done today on "V1" and it failed on performance, was timing out after 30minutes (because i set it to faile after 30minutes...)
 
@Sherif true
 
@JonathanLafleur No, it's not what you've done today. What you've done today is try to solve all your problems in one single step.
How's that working out for you so far?
 
:P
well... pretty good ? :P sarcasm alert
 
Riiiight. Now try it the other way. Break down the problem into smaller problems.
Solve each one separately.
Rinse, repeat...
 
4:03 AM
I'd honestly start by inserting all this scv csv into a huge ugly dirty table
scv ready
then normalize it as you see fit
 
@FélixGagnon-Grenier It's not actually necessary to do that though. All he needs is an easier way to build the tables. He already has the data in the CSV. What's the point of copying it into the database? It's the same data.
The normalization part isn't hard to do because the data is in a csv file. It's hard to do because it requires planning ahead of time. That's done when you define the schemas for the normalized tables.
Now the problem is getting that data into those schemas.
This is a basic ETL problem.
 
Importing a csv in different tables is more complicated than inserting in tables from other tables
 
@FélixGagnon-Grenier What other table? There is no table. There's a CSV file.
Hence: it's an ETL problem.
 
what mean ETL ?
 
once in the database...
 
4:06 AM
In computing, Extract, Transform, Load (ETL) refers to a process in database usage and especially in data warehousing that performs: Data extraction – extracts data from homogeneous or heterogeneous data sources Data transformation – transforms the data for storing it in the proper format or structure for the purposes of querying and analysis Data loading – loads it into the final target (database, more specifically, operational data store, data mart, or data warehouse) Since the data extraction takes time, it is common to execute the three phases in parallel. While the data is being extracted...
 
Thank you :)
I just found a bigger flaw then performance tho LOL and probably why it was hanging
 
Stop saying you have performance problems. You don't have performance problems. Your code just sucks.
 
when I create my multi dimensionnal array I loop trough continent at first, then inside this loop I loop again with country, but there's only 7 continent, so only 7 countries are recorded too...
Yeah my code suck that's exactly the point :P
 
@JonathanLafleur Like I said, you don't need more than one loop to do this.
Abstractions are about being able to draw up a solution without tying it to a specific state. If your solution requires that you first build an array of 7 continents and then loop over that array in order to insert the countries, then it's not a good abstraction of the problem.
 
I'm pretty curious on how I can acheive entering data in 5 different tables with parent_id in one and loop
 
4:11 AM
foreach($csvRow as $row) { $row = array_combine($columnNames, $row); $data[$row["Continent"]] = $row["Country"]; }
Work smarter, not harder.
12 mins ago, by Sherif
If you're trying to solve a #problem and you get stuck, you're probably trying to solve more than one problem at a time.
Just sayin' if you haven't groked this ^ yet, you stopped thinking about the problem and started thinking about the solution prematurely.
Once you tie a solution directly to the state of your program you just created a solution that cannot be reused. Instead, think of an abstraction rather than a solution. How can you solve the problem by obviating state from the solution?
This is the only way to solve a problem well. And remember... "Good is the enemy of great".
 
I hear you, but it's not that easy :P
 
@JonathanLafleur Only because you've never been faced with this problem before. This is why breaking down the large problem into smaller problems is more likely to help you realize that you are familiar with these smaller, more manageable problems.
Surely, you've created arrays in PHP before. Surely you understand that an array key is unique. So what's so hard about ensuring using this pre-existing wisdom and expanding on it to solve a large problem?
 
@Sherif but, the first version of my code, that's what I've done, break it into small part, test them then go forward
 
@JonathanLafleur Show me.
 
4:19 AM
@JonathanLafleur $data = array_map( "convert", $data ); where is this convert function? It's not defined anywhere in this code.
 
My problem in this version start at line 203, and i'm pretty sure it's the get_path_the_id (yeah it's a terrible function name, it hurt my eyes, I havn't renamed it yet)
@Sherif was commented out, forgot to remove before I put it on gist
 
@JonathanLafleur Then update and show me the code you're really working with.
 
@Sherif already updated, that's exactly the code I was working on
 
@JonathanLafleur OK, so let's start in your loop where you're reading the CSV gist.github.com/jonathanlaf/…
 
@Sherif that's the second version I was about to try tonight (yes I know there's db information in the gist and I don't mind it's a VM) gist.github.com/jonathanlaf/7d01dbcbe2c803107365ef382779bd72
 
4:23 AM
1st, this part needs to happen before the loop, not after.
Here's what you need... $columnNames = array_keys(fgetcsv($handle, 1000, ","));
Now inside your loop you can do $data = array_combine($columnNames, $data);
So now on every iteration you can say something like $rows[$data["Continent"]][$data["Country"]][$data["City"]] = /* some value */
The fact that you have an array that's already normalized means it's that much easier to transform it into an entity that makes sense in code.
foreach($rows as $continent => $countries) { foreach($countries as $country => $cities) { ...
Look how much easier it is to store these rows into the db now?
You could even do the insertion in a single loop while reading from the CSV this way without creating the array at all.
It's just easier to understand when you think about it like this.
Pretty much this entire gist can be boiled down to about 10 lines of code to do the insertion.
 
@Sherif if you don't mind, let me a minute or two, I really enjoy your explanation i'm setting up a new test base
 
morning
 
Good morning
I will work here for this "test" will be easier to share, if you still want to help me understand your logic :) I really do appreciate it
 
4:40 AM
@JonathanLafleur Here, I'll get you started gist.github.com/srgoogleguy/4525be335812e7f81fd23bfea1112073
Should be relatively straight forward what to do from there.
 
:O
wow !
Thank you man
that will be a lot of help and bare with me I will not just copy paste, I will apply my self to understand and see how you do it ! :)
 
You do realize Max Mind already provides a compressed binary file and PHP extension for this, right?
 
@Sherif has far that I see on his site, he don't have relation between them on the API too
 
@JonathanLafleur Huh? I'm unable to mentally parse that sentence.
If you're trying to build your own normalized database out of the GeoLite 2 database, then sure their tools don't help you, but if you just want to import the GeoLite 2 database to MySQL from their CSV they already have a tool for that github.com/davidsneal/maxmind-csv-import
Their database doesn't actually require normalization, because it's decomposed by design in order to be fast.
That's why they give a dat file. It's orders of magnitude faster to load that into memory and read it than it is to use a database.
 
@Sherif sorry my english is not always perfect, what I was trying to say it's that I haven't found anything that could make what I need. All I need is a map that I can query "relation" in form, that's really stupid, it's use on a website to classify offer and member by geo filter.
Example : At subscription you choose where you are from
when you search for an item in your city or state or country
I don't need the spatial search at least -.-
 
4:53 AM
@JonathanLafleur So you want something like this then github.com/hiiamrohit/Countries-States-Cities-database
 
I saw this DB but there's no continent
that I particulary need for this project
 
@JonathanLafleur Right, but how hard would it be to just add continents there on your own?
I mean there are only 7 of them and 1 doesn't even have a human population.
 
You are really sure to know every Country in the world and wich continent they belong ?
 
Or any known human territories apart from scientific research destinations that are considered international territory.
This is a list of sovereign states and dependent territories of the world by continent, displayed with their respective national flags and capitals, including the following entities: In bold: Internationally recognized sovereign states The 193 member states of the United Nations (UN) Vatican City (administered by the Holy See, a UN-recognized non-member state) State of Palestine (administered by the PNA, a UN-recognized non-member state) Kosovo (officially known as the Republic of Kosovo) Taiwan (officially known as the Republic of China) In bold italics: States with limited recognition an...
@JonathanLafleur No, I let other people do it for me and then just copy from them
Welcome to the Internet
 
haha ;)
 
4:56 AM
I'm pretty sure if I could find that database in 3 seconds of Googling, I can find another one that has continents if I gave it 30 more seconds.
 
I gave almost 2hour searching before I go with geolite2
 
Just sayin... information is definitely out there and easy to access these days. You aren't the only one looking for it. I'm sure someone else was too at some point and probably one of those someones made it available.
 
Yeah pretty sure it exist, I was tired to search :P now I will make it from what I have then share it on my github page to freely download
 
Fine... I'll take another 30 seconds out of my day for you
There
 
And i'll put a special thanks to you in a readme file somewhere :P
@Sherif still no continent
 
4:59 AM
@JonathanLafleur Sure there is continent varchar(15) NOT NULL,
Read carefully please.
I did all the hard work for you.
;)
 
you're right
:P
I just see it enum
continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL,
where I am right now, I will finish the code you started for me :P if it's not working will buy this db tomorow and forget about that story haha :P
 
@Wes Which is precisely why nobody cares about Continents anymore. Real business needs classify geolocation data into regions, instead.
Middle East, South East Asia, East Asia, North America, Central America, etc...
If you ever work for company that deals with global advertising you learn a lot about geo classification data ;)
 
Wes
 
yomin
 
Wes
\o hey joe
 
!!dad
 
My wife is on a tropical food diet, the house is full of the stuff It's enough to make a mango crazy
 
@Jeeves get somethng new.
 
6:14 AM
Hello All
Anybody, please help me on this
http://stackoverflow.com/questions/39653522/automated-recurring-billing-arb-process-using-php
 
Good morning, and happy rebecca day! May your Fridays always be long and a back seat always available.
 
o/
 
6:33 AM
\o mornin Patrick,Epodax
 
Hi
is there any one know how can i list of cipher support by server ?
 
Wes
6:53 AM
mornings
 
mornin Wes
 
Wes
yo linus
 
yo how are you?
 
morngins
 
tangueray
 
7:01 AM
ochtend PeeHaa
 
@Wes :D
@Linus morgen
 
@PeeHaa o/
 
hey @reikyoushin o/
 
someone here was located in/near Rotterdam. Was that you @PeeHaa?
 
that would be me yeah
As well as @Oldskool
Why?
 
7:11 AM
do you or @Oldschool listen to rock? If so, I can recommend July Talk tmr in Rotown
 
I am not a fan of either rock or rotown no :)
 
ah, too bad…
 
Wes
so "peehaa rocks" was a lie???
 
hey PeeHaa
 
Oh no no no. I do rock.
 
7:13 AM
he probably got a rocking chair
 
:P
 
Wes
:P
 
hi i need to know syntax for ignoring some files in git
 
Wes
7:18 AM
kamehamehaaaaaaa. no that's dragon ball hadoukeeeen :B
 
That's more like it
 
@PeeHaa Indent Hadouken
 
morning
 
yo
 
Morgen
 
Wes
7:24 AM
btw, did you know that preferred indentation by the js community is 2 spaces :B everything about js is designed to make your life just a little bit more difficult than it needs to be
 
ThW
Morning
 
@Wes true
 
Anonymous
Supmorn
 
Wes
but since you get dozens of nested functions pretty much everywhere i can see why 12*4 is too much
 
@JayIsTooCommon o/
@Wes callbacks >.<
 
Wes
7:27 AM
eh. tell it to the js people :D
 
@Wes Also double quotes
 
Hello guys I want to change my website design and add some new features but I dont want to see changes I do untill I finish is there any best practice or a tool to do it ??
 
@undefined feature branch
Or even feature switches
 
@PeeHaa on the remote server or on local
 
7:41 AM
@Wes no, it's 4 spaces
 
Although I don't like the latter
@undefined That depends who needs access to it
 
I want to access to the whole website and change design and add new features
 
Wes
in JavaScript, Sep 15 at 16:35, by William
while you are at it you should use 2 spaces not tabs
(continue reading)
 
@Wes yeah, that guy is a joke
trust Loktar over any other guy in that room any day
 
Mornings
 
7:45 AM
morning
anyone who is willing to help?
 
i don't know c++
 
@Mike probably go to Lounge<C++> ? and ask for help
 
Wes
@FlorianMargaine regardless who said that, it's not the first time i hear it
> Let's start with the religious problems first. Our benevolent dictator has chosen 2 space indention for the node core, so you would do well to follow his choice.
:B
 
:P
 
Wes
> This is why I use tabs for indentation and spaces for presentation (e.g. for lining up variables).
 
!!rebecca
 
morfriningday
 
mornmginfdvdzx
 
7:58 AM
has anyone ever made SOAP WSDL request
with PHP
 
mooyiyjxfj
 
Anonymous
!!wotd
 
plutocracy: the rule or power of wealth or of the wealthy.
 
phew so exams end today... what a relief!
 
damn. Rep doesn't expand :(
 
Anonymous
7:59 AM
whore
 
41, 100
 
quick, someone ruin it!
 
:O
 

« first day (2169 days earlier)      last day (2764 days later) »