Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - MultiformeIngegno
151
Off-topic / Re: json_decode and arrays
« on June 6th, 2013, 09:52 PM »
Quote from Arantor on June 6th, 2013, 09:50 PM
Now you're just showing off. I'm so proud!
shhh, someone told me :P
152
Off-topic / Re: json_decode and arrays
« on June 6th, 2013, 09:49 PM »
Code: [Select]
foreach (array_slice(json_decode($data_feedin), 0, 5) as $obj)
153
Off-topic / Re: json_decode and arrays
« on June 6th, 2013, 09:34 PM »
Yep :P
154
Off-topic / Re: json_decode and arrays
« on June 6th, 2013, 08:21 PM »
Code: [Select]
<?php
// JSON URL which should be requested
$json_url 'https://api.feedbin.me/v2/entries.json';

$username 'username';  // authentication
$password 'password';  // authentication

// Initializing curl
$ch curl_init$json_url );

// Configuring curl options
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => $username ":" $password   // authentication
);

// Setting curl options
curl_setopt_array$ch$options );

// Getting results
$result =  curl_exec($ch); // Getting JSON result string

    
$i=0;
    foreach (
json_decode($result) as $obj) {
    if(
$i==5) break;
        
$feedbin_title $obj->title;
        
$feedbin_url $obj->url;
        echo 
'<li><a href="'$feedbin_url'">'$feedbin_title'</a></li>';
    }
?>


It works fine. I get a 100 objects JSON result. I'm trying to limit the objects processed to the first 5. Why doesn't work the $i=0; if($i==5) break; thing? :)
155
Off-topic / Re: json_decode and arrays
« on June 5th, 2013, 09:24 PM »
Some guy suggested me

Code: [Select]
$image = null;
foreach ($track['image'] as $i) {
    if ($i['size'] == 'medium') {
        $image = $i['#text'];
        break;
    }
}

or

Code: [Select]
$image = array_reduce($track['image'], function ($image, array $i) { return $image ?: ($i['size'] == 'medium' ? $i['#text'] : null); });

or

Code: [Select]
$image = array_filter($track['image'], function ($image) { return $image['size'] == 'medium'; });
$image = isset($image[0]['#text']) ? $image[0]['#text'] : null;

The one line solution is cool :D
156
Off-topic / Re: json_decode and arrays
« on June 5th, 2013, 08:48 PM »
My JSON has

Code: [Select]
        "image":[
           {
              "#text":"http:\/\/userserve-ak.last.fm\/serve\/34s\/3996573.jpg",
              "size":"small"
           },
           {
              "#text":"http:\/\/userserve-ak.last.fm\/serve\/64s\/3996573.jpg",
              "size":"medium"
           },
           {
              "#text":"http:\/\/userserve-ak.last.fm\/serve\/126\/3996573.jpg",
              "size":"large"
           },
           {
              "#text":"http:\/\/userserve-ak.last.fm\/serve\/300x300\/3996573.jpg",
              "size":"extralarge"
           }
        ]

How can I retrieve 'medium' url?

I think it's something like this..?

Code: [Select]
        if ($track['image']['size'] == medium) {
$thumb = $track['image']['#text'];
}
157
Off-topic / Re: In Addition to Post Count - Power Ranking?
« on June 5th, 2013, 02:20 AM »
We could come up with a standard algorithm, customizable under advanced settings (or something like that).
158
Off-topic / Re: In Addition to Post Count - Power Ranking?
« on June 5th, 2013, 02:15 AM »
Maybe mixing quality (likes) with quantity (posts count, chars count, topics started count) could work.
159
Off-topic / Re: In Addition to Post Count - Power Ranking?
« on June 5th, 2013, 02:08 AM »
True. What I was saying is that ponderating post counts with char count could be wrong. It's quantity vs quality. Everyone has his style. Maybe one user makes a more qualified reply with less chars.
161
Off-topic / Re: Page load bottleneck
« on June 4th, 2013, 01:48 PM »
I don't think it's WP fault. It's something related to first connect to the server.
If you see the resources loaded they're few and only 2 little js are related to plugins.
162
Off-topic / Re: Page load bottleneck
« on June 4th, 2013, 11:39 AM »
Quote from live627 on June 4th, 2013, 11:29 AM
You have WordPress. And plugins. That's punishment enough.
But that 1.66s is the time to load just home page in plain text. Other resources (js, CSS) are loaded fast. It seems it's the initial load the issue.
Even because some time ago I could load the same entire website in 1s.
163
Off-topic / Page load bottleneck
« on June 4th, 2013, 10:52 AM »
http://tools.pingdom.com/fpt/#!/d3pSnc/http://multiformeingegno.it/

I can see it takes 1.66 seconds to load the 7.1KB of index.php... what can cause this slowness?
Server configuration? Because it's all "wait" time!
164
Features / Re: Culmination of Permissions Ruminations
« on June 4th, 2013, 02:57 AM »
Quote from Arantor on June 4th, 2013, 02:55 AM
Until that user wants to hand over the keys to the kingdom on retiring or whatever ;)
It would be the case even for the sysadmin or who takes care of the hosting..
165
Features / Re: Culmination of Permissions Ruminations
« on June 4th, 2013, 02:54 AM »
Quote from Arantor on June 4th, 2013, 02:50 AM
As far as creating other admins goes, it gets messy because you have to do something with the inherent notion of 'admins have every permission' which would have to essentially go (or be reformulated) to support admin permissions being handled this way.
I think that one user (super admin?) having more powers than all others (even other admins) is needed. Also to prevent a "night of the long knives" thing..