Summary
We follow pep8 rather stricly:
Code must be compatible with from Python 2.6 to the newest released version of Python.
If external libraries must be used, they should be wrapped in a mechanism that by default does not require them (e.g., conditional imports, graceful degradation, etc.).
Libraries used for testing and contributing (flake8, nose, tox) can be installed with pip:
pip install -r py4j-python/requirements-test.txt
# Run flake8
flake8
We are still looking for a portable/universal code formatter, but in the meantime, try to adhere to these conventions:
On the Python side, we use nose and tox:
pip install -r py4j-python/requirements-test.txt
# Run the full test suite
nosetests
# Run only one particular test
nosetests py4j.tests.java_gateway_test:GatewayLauncherTest.testRedirectToDeque
# Run all tests on all supported pythons:
tox
New code or bug fix should ideally be accompanied by a test case.
Because we start a JVM for most test cases, it may happen that some test fails because the process was not ready to receive a request. This is a problem we have been working on for some time now and it has been a few months since the test suite failed because of synchronization issues.
We use JUnit to write test cases.
Py4J does not have an official Contributor License Agreement (CLA), but it is assumed that as soon as you make a contribution (patch, code suggestion through any medium, pull requests) to Py4J, you accept that your code will be redistributed under the current license used by Py4J, i.e., the new BSD license. This is an irrevocable right to ensure that developers can use Py4J without the fear of seeing parts removed in the future.
You maintain the full copyrights for your contributions: you are only providing a license to distribute your code without further restrictions.
The copyright statement in the License has been standardized to:
Copyright (c) 2009-2015, Barthelemy Dagenais and individual contributors. All
rights reserved.`
Individual contributors are identified in the AUTHORS file. If you have contributed to Py4J and your name is not in AUTHORS, please open a pull request!
If you are working for a company while contributing to Py4J, make sure that the code is yours or that your company agrees with this implied CLA.
This approach is heavily inspired from the Django Contributor License Agreement..
If you have any question, do not hesitate to contact the founder of the project, Barthelemy.


Class discord.message
The discord message class.
It can be obtained either from a discord event, or by requesting a message by it's ID from the discord servers.
Usage:
local fetchedMessage = discord.message("channel_id", "message_id") --The requested message.
Methods
| discord.message:initialize(data, messageID) | Create a new message object. |
| discord.message:addReaction(emoji) | Add a reaction to the message. |
| discord.message:delete() | Delete the message. |
| discord.message:edit(content, embed) | Edits the message. |
| discord.message:isPinned() | Check if the message is pinned or not. |
| discord.message:isTTS() | Check if the message was sent with text to speech . |
| discord.message:isUserMentioned(user) | Check if a user was mentioned or not in this message. |
| discord.message:getAuthor() | Get the user object of the message's author. |
| discord.message:getAttachments() | Get the list of attachments if there are any. |
| discord.message:getChannelID() | Get channel ID/snowflake of which the message was sent in. |
| discord.message:getContent() | Get the message content. |
| discord.message:getEmbeds() | Get the message embeds if there are any. |
| discord.message:getGuildID() | Get the guild ID of the channel the message is sent in, would return nil for DM channels |
| discord.message:getID() | Get the ID/snowflake of the message |
| discord.message:getMember() | Get the guild member of the message if the message was sent in a guild. |
| discord.message:getMentions() | Get the list of specifically mentioned user. |
| discord.message:getReplyChannel() | Get a fake channel object for ONLY replying to the message. |
| discord.message:getTimestamp() | Get the timestamp of the message. |
| discord.message:getType() | Returns the type of the message. |
Internal fields
| self.id | ID of the message (snowflake). |
| self.channelID | ID of the channel the message was sent in (snowflake). |
| self.content | Contents of the message (string). |
| self.timestamp | When the message was sent (number). |
| self.tts | Whether this was a TTS message (boolean). |
| self.mentionEveryone | Where this message mentions everyone (boolean). |
| self.pinned | Whether this message is pinned (boolean). |
| self.type | Type of message (string). |
Internal optional fields
| self.author | The author of this message (not guaranteed to be a valid user) (user). |
| self.guildID | ID of the guild the message was sent in (snowflake). |
| self.member | Member properties for this message's author (guild member). |
| self.editedTimestamp | When the message was edited (or null if never) (number). |
| self.mentions | Users specifically mentioned in the message (array of user objects). |
| self.mentionRoles | Roles specifically mentioned in this message (array of snowflake objects). |
| self.attachments | Any attached files (array of attachment objects). |
| self.embeds | Any embedded (array of embed objects). |
| self.mentionChannels | Channels specifically mentioned in this message (array of channel mention objects). |
| self.reactions | Reactions to the message (array of reaction objects). |
| self.nonce | Used for validating a message was sent (snowflake). |
| self.webhookID | If the message is generated by a webhook, this is the webhook's id (snowflake). |
| self.flags | Message flags, describes extra features of the message (array of strings). |
Methods
- discord.message:initialize(data, messageID)
-
Create a new message object.
Either from an internal message data table, or by requesting the message data from discord servers.
Parameters:
- data
table or string
Either a message data table (from an internal api), or a
Guild ID
as a string. - messageID
optional string
The
Message ID
as a string to fetch, only whendata
is aGuild ID
.
Raises:
Request error when fails to request the message from discord servers. - data
table or string
Either a message data table (from an internal api), or a
- discord.message:addReaction(emoji)
-
Add a reaction to the message.
Parameters:
- emoji
string or discord.emoji
The reaction to add, either a string which is the name of a standard emoji (ex
sweat
), or an emoji object.
Raises:
Request error on failure. - emoji
string or discord.emoji
The reaction to add, either a string which is the name of a standard emoji (ex
- discord.message:delete()
-
Delete the message.
Raises:
Request error on failure. - discord.message:edit(content, embed)
-
Edits the message.
Parameters:
- content optional string The new message content, standard emojis are automatically replaced with their unicode character.
- embed optional discord.embed The new embed content of the message.
Raises:
Messages content can't be longer than 2000 characters!
,Either content or embed parameter has to be present!
or request error on failure. - discord.message:isPinned()
-
Check if the message is pinned or not.
Returns:
-
optional boolean
Whether the message is pinned or not,
nil
when not known. - discord.message:isTTS()
-
Check if the message was sent with
text to speech
.Returns:
-
optional boolean
Whether the message was send with
text to speech
or not,nil
when not known. - discord.message:isUserMentioned(user)
-
Check if a user was mentioned or not in this message.
Parameters:
- user discord.user The user to check.
Returns:
-
boolean
whether the user was mentioned or not.
- discord.message:getAuthor()
-
Get the user object of the message's author.
Returns:
-
discord.user
The author of the message.
- discord.message:getAttachments()
-
Get the list of attachments if there are any.
Returns:
-
optional {discord.attachment,...}
The message's attachments,
nil
when there are none, or if not known. - discord.message:getChannelID()
-
Get channel ID/snowflake of which the message was sent in.
Returns:
-
discord.snowflake
The channel ID/snowflake.
- discord.message:getContent()
-
Get the message content.
Returns:
-
optional string
The message content, or
nil
when it doesn't have content (embed only). - discord.message:getEmbeds()
-
Get the message embeds if there are any.
Returns:
-
optional {discord.embed,...}
An array for embed objects.
- discord.message:getGuildID()
-
Get the guild ID of the channel the message is sent in, would return nil for DM channels
Returns:
-
optional discord.snowflake
The guild ID/snowflake for the channel the message was sent in,
nil
if it was sent in a DM channel. - discord.message:getID()
-
Get the ID/snowflake of the message
Returns:
-
discord.snowflake
The ID/snowflake of the message.
- discord.message:getMember()
-
Get the guild member of the message if the message was sent in a guild.
Returns:
-
optional discord.guild_member
The guild member object.
nil
if it was not known, or in a DM channel. - discord.message:getMentions()
-
Get the list of specifically mentioned user.
Returns:
-
{discord.user,...}
The mentioned users array, can be an empty table if we don't know which users are mentioned.
- discord.message:getReplyChannel()
-
Get a fake channel object for ONLY replying to the message.
Only the channel ID has a proper value, and the channel type is just set into
GUILD_TEXT
for messages with guild ID , and intoDM
for other messages.Other channel fields are just nil.
Returns:
-
discord.channel
A fake channel object to send a reply message using it.
- discord.message:getTimestamp()
-
Get the timestamp of the message.
Returns:
-
number
A
os.time()
timestamp as provided by discord. - discord.message:getType()
-
Returns the type of the message.
Returns:
-
string
The type of the message.
See also:
Internal fields
- self.id
- ID of the message (snowflake).
- self.channelID
- ID of the channel the message was sent in (snowflake).
- self.content
- Contents of the message (string).
- self.timestamp
- When the message was sent (number).
- self.tts
- Whether this was a TTS message (boolean).
- self.mentionEveryone
- Where this message mentions everyone (boolean).
- self.pinned
- Whether this message is pinned (boolean).
- self.type
- Type of message (string).
Internal optional fields
- self.author
- The author of this message (not guaranteed to be a valid user) (user).
- self.guildID
- ID of the guild the message was sent in (snowflake).
- self.member
- Member properties for this message's author (guild member).
- self.editedTimestamp
- When the message was edited (or null if never) (number).
- self.mentions
- Users specifically mentioned in the message (array of user objects).
- self.mentionRoles
- Roles specifically mentioned in this message (array of snowflake objects).
- self.attachments
- Any attached files (array of attachment objects).
- self.embeds
- Any embedded (array of embed objects).
- self.mentionChannels
- Channels specifically mentioned in this message (array of channel mention objects).
- self.reactions
- Reactions to the message (array of reaction objects).
- self.nonce
- Used for validating a message was sent (snowflake).
- self.webhookID
- If the message is generated by a webhook, this is the webhook's id (snowflake).
- self.flags
- Message flags, describes extra features of the message (array of strings).


Meet the Best Doctors
Preference entreaties compliment motionless ye literature. Day behaviour explained law remainder. Produce can cousins account you pasture.
 Facilis maiores, qui impedit animi. Explicabo quibusdam maxime hic eaque suscipit voluptate asperiores mollitia, ipsam fugit, optio architecto eligendi recusandae provident! Harum.
Badies she basket season age her uneasy saw. Discourse unwilling am no described dejection incommode no listening of. Before nature his parish boy.
Full ProcessHead of Department: Profession Jonadul
Because yet mistake feeling has men. Consulted disposing to moonlights. Engage piqued in on coming. Preferred joy agreement put continual elsewhere delivered now.
Head of Department: Profession Jonadul
Because yet mistake feeling has men. Consulted disposing to moonlights. Engage piqued in on coming. Preferred joy agreement put continual elsewhere delivered now.
Head of Department: Profession Jonadul
Because yet mistake feeling has men. Consulted disposing to moonlights. Engage piqued in on coming. Preferred joy agreement put continual elsewhere delivered now.
Moment he at on wonder at season little. Six garden result summer set family esteem nay estate.
Read MoreMoment he at on wonder at season little. Six garden result summer set family esteem nay estate.
Read MorePower dried her taken place day ought the. Four and our ham west miss. Education shameless who middleton agreement how. We in found world chief is at means weeks smile.
View AllBoard certification is one of the most important factors to consider; it tells you that the doctor has the needed training, skills and experience to provide healthcare in cardiology. Also confirm that the cardiologist has no history of malpractice claims or disciplinary actions.
Board certification is one of the most important factors to consider; it tells you that the doctor has the needed training, skills and experience to provide healthcare in cardiology. Also confirm that the cardiologist has no history of malpractice claims or disciplinary actions.


asbury park convention center
Southside Johnny & The Asbury Jukes at the Asbury Park ... - IMDb
Discuss Southside Johnny & The Asbury Jukes at the Asbury Park Convention Center (1979) on the IMDb message boards ». Getting Started | Contributor Zone .
http://www.imdb.com/title/tt1527833/
Asbury Park Convention Hall - Wikipedia, the free encyclopedia
Asbury Park Convention Hall is a 3,600-seat indoor exhibition center located on the boardwalk and on the beach in Asbury Park, New Jersey. It was built .
http://en.wikipedia.org/wiki/Asbury_Park_Convention_Hall
Asbury Park Convention Hall Tickets - GoTickets.com
Asbury Park Convention Hall Seating Chart and Event Tickets. Buy Asbury Park Convention Hall Event Tickets Now. Select a Chart Type, Concert, Theater .
http://www.gotickets.com/venues/nj/asbury_park_convention_hall.php
Things You'll Need
- Certified copies of public records evidence in your case
Instructions
-
-
1
Asbury Park Convention Hall Hotels - Asbury Park, New Jersey
Compare discount rates for hotels near the Asbury Park Convention Hall in Asbury Park, New Jersey NJ. . Edison New Jersey Convention Center Hotels .
http://hotelguides.com/new-jersey/asbury-park-convention-hall-nj-hotels.htmlConvention Hall - Asbury Park | Tickets, Schedule, Seating Chart ...
Proceed on Asbury Park Ave. East all the way to Ocean Ave. which is on the Beachfront. Make a left onto Ocean Avenue and proceed for five blocks. Convention .
http://www.ticketmaster.com/Convention-Hall-tickets-Asbury-Park/venue/216 -
2
Asbury Park, NJ - Convention Hall | The Official Daughtry Website
Asbury Park, NJ - Convention Hall. Date: Nov 30 2012. Venue: Convention Hall. Location: Asbury Park, NJ. Tickets: Buy Tickets. Attending: Add me! See all fans .
http://www.daughtryofficial.com/event/2012/11/30Asbury Park Convention Hall - Information on Convention Hall in ...
Asbury Park Convention Hall Paramount Theatre 1300 Ocean Ave. Asbury Park, NJ. The historic Asbury Park Convention Center has been a host to many world .
http://www.asbury-park.net/asbury-park-convention-hall.shtml -
-
3
Convention Hall (Asbury Park) - StubHub
Convention Hall Asbury Park Tickets - Buy and sell Convention Hall Asbury Park event tickets and check out the Convention Hall Asbury Park schedule in .
http://www.stubhub.com/convention-hall-event-tickets/Rebel Legion :: View topic - NER Invite: Asbury Park Convention ...
This year, they have upgraded to the Asbury Park Convention Center (where we did the Roller Derby) and there will definitely be enough room .
http://www.rebellegion.com/forum/viewtopic.php?t=44913&sid=5315c36cf34c2fbba6f1c328f132c236 -
4
Asbury Park Boardwalk
The Asbury Park Boardwalk. Concerts & Events · Shopping · Drinking & Eating · Attractions. Asbury Park Boardwalk - Convention Hall, Paramount Theatre, The .
http://apboardwalk.com/Asbury Park Convention Center
Join Shawn Michaels, Sue Moll and the Shawn and Sue's All-Stars at the 6th annual Miracle Plunge Freezin' for a Reason at Asbury Park Convention Center!
http://wobm.com/venue/asbury-park-convention-center/
-
1
References
Resources
- Photo Credit Justice image by MVit from mr crowley keyboard tab


---
layout: archive
title: Lean Prover Zulip Chat Archive
permalink: 113488general/74975definingadependentfunctionoutoffin2.html
---
The archive URL format has changed. Please find this page at:
https://leanprover-community.github.io/archive/stream/113488-general/topic/defining.20a.20dependent.20function.20out.20of.20.60fin.202.60.html


{% extends "../helloWorld.html" %} {% block demoSectionClasses %}demo_hello_world{% endblock %} {% block meta_title %}Demo - Hello World - Better{% endblock %} {% block meta_description %}"Hello World!" demo and tutorial using Spincast - Better version{% endblock %} {% set demoId = "better" %} {% block demoBody %}
In general, you want to create a custom Guice module for your application, so you can bind custom components.
This is what we are going to do in this tutorial.
We will also create a controller so our Route Handlers
are not defined inline but have their
own dedicated method.
First, we add the latest version of the org.spincast:spincast-default
Maven artifact to our pom.xml
(or build.gradle
) :
<dependency> <groupId>org.spincast</groupId> <artifactId>spincast-default</artifactId> <version>{{spincast.spincastCurrrentVersion}}</version> </dependency>
Let's then create our controller :
public class AppController { public void index(DefaultRequestContext context) { JsonObject user = context.json().create(); user.set("name", "Stromgol"); user.set("age", 42); context.response().sendJson(user); } }
This controller contains one Route Handler
: "index". A
Route Handler
is a method that receives, as a parameter, an object implementing
RequestContext.
In this simple handler, we create a "user" object as a JsonObject
and we send it as "application/json"
.
Now, let's create a custom Guice module, so we can bind our components :
public class AppModule extends SpincastGuiceModuleBase { @Override protected void configure() { // Binds our controller bind(AppController.class).in(Scopes.SINGLETON); // ... binds all our other application components here } }
Finally, let's bootstrap and start the application! We do that in the standard main(...)
method, using the Bootstrapper :
public class App { public static void main(String[] args) { Spincast.configure() .module(new AppModule()) .init(args); } @Inject protected void init(Server server, DefaultRouter router, AppController ctrl) { router.GET("/").handle(ctrl::index); server.start(); } }
Explanation :
main(...)
method is the entry point of our application.
Spincast.configure()
starts the bootstrapper, so we can configure and initialize our application.
init()
method will create the Guice
context using the default plugins and our custom module, will bind the current
App
class in the context and will load it.
Route
for the index page
using a method reference targeting our controller's "index" method as
the Route Handler
. Spincast is going to call this method each time a GET
request
for the index page is received.
Download this application, and run it by yourself :
mvn clean package
java -jar target/spincast-demos-better-{{spincast.spincastCurrrentVersion}}.jar
The application is then accessible at http://localhost:44419
Try the Supercalifragilisticexpialidocious "Hello World!" demo, for an improved version!
Try the Quick "Hello World!" demo, for an easier version!
{% endblock %}


What does it do?
jPages is a client-side pagination plugin but it gives you a lot more features comparing to most of the other plugins for this purpose, such as auto page turn, key and scroll browse, showing items with delay, completely customizable navigation panel and also integration with Animate.css and Lazy Load.
Apart from all its features, the main diference for the other pagination plugins is that with jPages you can create as many navigation panels as you want and you can choose exactly where to place them.
The plugin is very unobtrusive and it won't apply any extra styles to the items you are paginating. It will only create and insert the links inside the element(s) you are applying the plugin to, in order to turn them into navigation panel(s).
Compatible with All Browsers and IE7+
How to
Add the following code to the  section of your page (correct file locations first):
<link rel="stylesheet" href="css/jPages.css">

In case you want to use Animate.css animations you will also need to add the file:
<link rel="stylesheet" href="css/animate.css">
Example source code:

...

...

...

...

...

...

Initiate the plugin:
$(function(){
$("div.holder").jPages({
containerID : "itemContainer"
});
});
This is how the 'div.holder' source code will look like (imagining that 10 pages were created):

← previous
1
...
2
3
4
5
6
7
8
9
...
10
next →

See how it looks like with the default options.
Styling
jPages comes with a style sheet so it can work right out of the box. The default style is very simple. This is what you need to know to style it in your own way.
Below there's a list of classes used in the navigation links. They all have the "jp-" suffix to prevent conflicts with classes you might have created before:
- jp-first
- Added to the button 'first' (not created by default)
- jp-previous
- Added to the button 'previous'
- jp-next
- Added to the button 'next'
- jp-last
- Added to the button 'last' (not created by default)
- jp-current
- Added to link correspondent to the current page
- jp-disabled
- If the current page is the first, buttons 'first' and 'previous' will have this class. The same happens to the buttons 'next' and 'last' if the current page is the last one.
- jp-hidden
- Used to hide elements (automatically added to the page so you won't find it in the stylesheet)


--- layout: archive title: Zulip Chat Archive permalink: /stream/113488-general/topic/finiteness.html ---
Do mathlib have something that behaves like:
class Finite (α : Type u) := (cardinality : nat) (bijection : trunc (equiv α (fin cardinality)))
Is this gross for some reason, and should be avoided?
It is in my category theory repo (the category “set”)
and it’s called fintype
It can't be called fintype, because mathlib already has a fintype which is slightly different (but equivalent, of course).
I guess I'm asking if there is a strong reason to (bite the bullet and learn how to use multisets and) use mathlib's fintype, or if it's okay to use something like this.
oops i meant the category is called set and uses fintype
but I guess I didn’t notice that you used trunc
That's fintype
. If you want to use such an interface to it, prove it and use it
Okay, I guess that's a good point. In the meantime I'm discovering fintype
is pretty easy to use anyway.
What is the lemma that says fintype
gives decidable_eq
?
I don't think it's true. So your formulation is a bit stronger, since it equips the set with a function to fin
; in mathlib's fintype
, this function is index_of
, but it requires a separate proof of decidable_eq
your Finite
should be equivalent to the conjunction of fintype
and decidable_eq
ah, okay.
{% endraw %}Last updated: Apr 24 2020 at 19:02 UTC


{{ define "content" }}
For long-term storage of siacoin it's safest to use a paper wallet instead of keeping your siacoins in an exchange or online wallet. It's also a great way to gift friends!
Just transfer siacoins into your new wallet, print the wallet, and keep it safe the way you would jewelry or cash.


| Description: |
Your full-color guide to all the things you need to know about your Android phone
Congratulations on your new phone, and welcome to the world of Android! Whether you're an old hat looking to make sense of a new model or a newbie who's too afraid to even take it out of the box, this fun and friendly guide arms you with the knowledge to make your Android phone your minion. Written by popular and bestselling author Dan Gookin, this new edition of "Android Phones For Dummies" makes it easy to set up and configure your phone, get up and running with texting and emailing, access the Internet, maps, and camera, navigate with GPS, synch with a PC, and so much more.
Approaching all the features of Android phones from the perspective of someone who's either new to technology or wary of working with a new device, this hands-on guide walks you through the basics and moves on to help you tackle more advances features, like dialing tricks to forward calls, working with predictive text, accessing special characters, manipulating the touch screen, and using a USB connection to synchronize your stuff. Set up your phone, get connected, and start browsing Shoot photos and videos, play games, and listen to music Keep in touch using email, texting, and social media Get the scoop on Google Voice typing
If you want to learn the ins and outs of your new Android phone in order to get things done, you've come to the right place! |


BBC Strictly Come Dancing viewers anger as fan favourite is eliminated from show
'Awwwww.....that's a real shame...thought they'd make it to the final'
by Rebecca KoncienzcyStrictly Come Dancing viewers were left angry after tonight's results show saw fan favourite Michelle Visage leave the show.
Last night the 51-year-old preformed a highly stylised version of Madonna's Vogue, but while it impressed the judges, Michelle and her professional partner Giovanni Pernice found themselves at the bottom of the leader board with 32 points.
Stand out dances from the other six couples made for tough competition and after combining her score with the public vote she had to battle it out in the dreaded dance-off against YouTube star Saffron Barker and her partner AJ Pritchard.
The judges were unanimous in their decision to save Saffron, but admitted they were torn by the choice of parings.
Craig Revel Horwood said: "I'm having a really difficult time with myself over this. This doesn't normally happen to me. I normally make a very quick, instant decision. This has been really, really difficult."
Michelle, a judge on RuPaul's Drag Race UK, said: "This whole experience has been amazing.
"At 51 years old and never danced in my life, I never thought I'd be able to do what I have done and to have such an incredible partner.
"To be here for my husband and my kids and the entire community, that's why I did what I did.
"I am so honoured to be welcomed by my new friends here."
Pernice admitted that the couple had been through a range of emotions during their time together, but said he has respect for his partner despite their arguments.
He said: "We laugh, we cry, we fight and we argue and we've done everything but I've loved every single second. I think you are inspirational."
Fans at home were devastated to see her go, many venting their frustration on Twitter, one @beckhughesxo said: "Can’t believe they saved Saffron over Michelle."
Another, @WestCountrySuzi said: "Awwwww.....that's a real shame...thought she'd make it to the final."
A third, @IshMotherBec said: "Another slightly shock exit. Although it's at the stage when almost any exit feels wrong."
A fourth, @AaronLR1991 said: "I’m so annoyed!"
And a fifth @evilcheltdevil added: "Gutted for @michellevisage and @pernicegiovann1 - just the worst result."
Kelvin Fletcher and Oti Mabuse, as well as Amy Dowden and Karim Zeroual, dominated the Strictly live show and earned near-perfect scores.
Chris Ramsey and Karen Hauer were spared the dance-off despite the judges leaving them second from bottom.
The final decision was a difficult one for the judges, with the experts torn on who to send home.
*Strictly returns next Saturday at 7pm on BBC One and iPlayer


Paramedics were unable to revive the sisters, aged just one and two, after they were left inside a black station wagon in a suburban area of Logan, south of Brisbane, on Saturday.
According to 7 News, the girls showed evidence of being "exposed to extreme heat''. It has yet to be established how long the children were left inside the sweltering vehicle.
Related News
'So frustrated': Another toddler found trapped in hot car in west Auckland
Twin babies die after dad leaves them in car for eight hours
Reports from local media claim the panicked mother attempted to splash water on the toddlers before police and paramedics arrived at the scene shortly after 1:30pm (local time).
The car was reportedly parked in front of the family's Waterford West property, the outside temperature surpassing 30 degrees on Saturday afternoon.
The mother, 27, has been charged with two counts of murder and will appear in Brisbane Magistrates Court on Monday.
Neighbours told the Sunday Mail they believed the girls had been in the car at roughly 6.30am - seven hours before they were pronounced dead.
The community is struggling to come to terms with the incident.
"It just makes you think that if you'd walked down maybe half an hour earlier, you could have saved those kids," one neighbour told the outlet.
"It's a very tragic incident," said Detective Inspector Mark White from the Logan Child Protection and Investigation Unit.
"We are putting a lot of emphasis on supporting our people."


Final Fantasy 7 Remake is getting all new bosses
by Emily GeraSquare Enix details more changes coming to the Final Fantasy 7 Remake.
The upcoming remake of Final Fantasy 7 will have include a number of new characters and boss battles, game director Tetsuya Nomura confirmed in a blog post today.
“With regard to new characters,” Nomura said in the post on the official Square Enix blog, “of whom I said during past interviews that there would be ‘none’ – though they aren’t main characters, their numbers ended up growing considerably in the process of creating a rich depiction of Midgar. When you think of Midgar’s final boss, you probably think of the M.O.T.O.R., but in this game new bosses will appear and add to the excitement of the story even more.”
Square Enix also confirmed that the Final Fantasy 7 Remake will be released in multiple parts. The first of which is entirely set within Midgar, and the developer is already working on the second.
“We’ve already begun working on the next one as well,” the director continues, “but I’m confident that playing through this title will expand your expectations just like the world that extends beyond Midgar.”
The news came alongside the release of 23 new screenshots from the game, including this beauty:
Final Fantasy 7 Remake hits PlayStation 4 on March 3 of next year.
Games featured in this article


{% extends "base.html" %} {% load i18n humanize static %} {% block content %}
This is a boilerplate for starting business / SaaS related webpages. Use it as a starting point to create something more unique.
Mailhog » Redis Browser » RabbitMQ Management » Postgres Management »
The numbers should be synchronized in different Browsers.
Add number »The latest user notifications should be shown here. Examples:


Design Patterns Are Sexist
Ok here we go: design patterns.  Then you hear them again, in the form of a very smart friend / developer telling you to read Design Patterns: Elements of Reusable Object-Oriented Software or any of the other books you’ll find recommended on this Amazon page. You’ll buy or steal it from the Internets, read a few pages, and move on with more practical stuff, feeling better about yourself. Maybe you’ll even use one or two, either by re-inventing the wheel and feeling mighty proud about your work (duh), or by obeying to framework conventions (ActiveRecord). But then the day comes when…
At a job interview yesterday I was asked to name some Design Patterns, and to explain them. Of course I know… F-bomb. MVC! Ok. Any more? Hm. Observer? I remember the name. F-bomb. Clearly, that puts me in the same category as a Non-FizzBuzzer right? Well, kind of. I think it’s natural that the complexity of learning to program makes you not ask or answer questions you clearly have, in order to get to what your current problem is, and that’s fine (YAGNI). But as soon as you either have enough head start to entertain the idea of cleaning up that past baggage you should. Otherwise, it’ll come back to haunt you (actually, preferably in a job interview than in a clusterf-bomb design of an app that you have to maintain).
So I’ll now become an expert on Design Patterns, wicked. Actually retaining the info from this talk is the goal:
And here’s a problem:
Reading books makes me tired, and watching stuff is great but merely goes to my passive memory, the one that goes “Ah yeah I knew that (But couldn’t tell you so I never used it in my code)”. I learn stuff when
- I explain it to people (or my right hand)
- I remember it in a context that is either funny, embarrassing, or otherwise emotionally impacted me.
Solution:
- I’ll (ab)use you for personal gain. Please use the comments to get even.
- I’ll make it so it’s embarrassingly sexist, with the probable repercussions to be shamefully remembered.
1. Value Objects
Examples in Ruby: Fixnum, Float, URI, Pathname If you end up creating state, and that state has some operations affiliated: Value Object! Why? You get domain specific comparisons… Oh f-bomb why is this so boring. Better – Logic for stuff that has value, and can be compared, represented or transformed in more than one, or one non-trivial way should live in its own class. A BodyMassIndex value should probably know how to set itself up given the Model inquiring, compare itself to other eager Models, and maybe even translated into some sort of other horrible category to measure unnatural human conditions. I can remember that. Next!
2. Service Objects aka Strategy Pattern
Oh I love those. It fits modern consumption so much: I need something! Answer: take something, use it, throw it away. My credit cards lets me know which services I use: car sharing, streaming music, screencasts, mobile phone, internet. All these have in common: I don’t have to know how they work, I want to be able to switch them like underwear, yet they directly impact me. I just need an interface to them to tell them what I need, and expect to be served. Of course I could also attach what they do directly on the activity, DIY style. But then I have to deal with the complexity of each process. Why would I? I’d have to fire up all the different elements of the systems that power them, and connect them, every time I need stuff. Why? I’d have to make network calls myself, instead of just screaming “get!” – when I just want to drive a car. And I’d have to stick to exactly the way I’m streaming music every time I listen to it, or go through the pain of re-designing that process. Models definitely need Service Objects.
3. Form Objects
So your client needs to enter stuff in a form for a shooting, and somehow, that stuff touches more than one (Active Record) Model. Chances are those Models are related, and have to be created in a certain fashion, order, or maybe even stuff has to be checked or modified in order to set things up correctly. That logic should go into its own class. Validate, create models, wire them up, hair, makeup, mix and match ethnicities for political correctness – and save!
4. Query Objects
But we have Scopes or class methods for that! Why would we need a query object? For one, Models like to look pretty, queries don’t.  Then you can set up your Query object to take a &block to execute on the return set – ha, and do the work! Which one of my really rich friends drives a really fast electrical engine car AND runs a non-profit? DudesToDate.new.find_each do |dude| self.make_available_to(dude) end #f-bomb sexism. I’ll make up for it somewhere.
5. View Objects
Need stuff from a Model just for a view? Don’t bother the Model with it, and don’t put that stuff into the view or its helpers. Put it on a View Object that you pass the Active Record Model it needs to come up with the stuff we wanna show in the view. Her hair is gonna be different tomorrow anyways.
6. Policy Objects
Great for analytics: Some stuff needs to be checked on an instance to return a boolean. The ugly actual politics of that check are best not discussed socially, and don’t need to bother the Model. Just let me know if that guy is a slut or not based on what we already know about him. If we need to query Facebook, that’s actually a Service Object. If we want to return a result set of non-slutty guys, that’s a Query Object, and will probably respond_to empty? with true.
7. Decorator
Avoid callback magic confusion! Here’s the trick: Give the Decorator class a reference to the Model instance, and then call stuff like “save” on the Decorator class, not the Model itself. Then have the Decorator add on stuff to “save”, preferably what you think it would when you read the Decorator class name. New booking for that Model? Need to send her a reminder, book flight, hotel, bodyguard, all that other stuff? Well, she doesn’t need to know how, does she? Now you have sort of an explicit callback – “Do this add-on stuff along with this Model lifecycle event, in this specific case”.


February 17, 2017
This problem focuses on implementing a heap, although you have a choice on the type of heap that you implement.
The problem demonstrates the modularity and nature of Abstract Data Types: you are responsible for replacing all public functionality of the PatientQueue class from part A with a heap structure. In other words, the patientqueueheap.h header file will have exactly the same public declaration as patientqueue.h from part A, but patientqueueheap.cpp will be implemented with a Heap instead of a Linked List. The private section of your patientqueueHeap.h file should be modified to comply with your heap class variables, functions, etc. In other words, you are making a drop-in replacement for the PatientQueue class, which should be faster than the Linked List implementation. This is an individual assignment. Write your own solution and do not work in a pair/group on this program.
We will go over the binary heap in lecture, but if you decide to implement a different type of heap, you will be responsible for researching how the data structure works.
Note: In your investigation, you may find that others have implemented the particular heap you have chosen in code (C++ or another language). You are not permitted to look at the code to implement your solution -- you must use descriptions and pseudo-code only. There is a somewhat fine line between using actual code and pseudocode, but you can consider pseudo-code to be a description of the algorithm. If you have any concerns, please reach out to either Chris, Aaron, or your Section Leader for clarification.
The heaps you may choose from are roughly ranked from easy to hard below:There are many other types of heaps you could build. If you would like to choose a different type of heap, you must schedule an appointment with Chris to discuss it -- we will look at the data structure and see if it is appropriate for the assignment.
As with Part A, your class must support all of the following operations. Note that the Big O column is not filled in: part of the assignment involves annotating all of your functions (in a function comment) with the Big O for each function.
| Member Name | Description | Big-Oh |
|---|---|---|
PatientQueue() |
In this parameterless constructor you should initialize a new empty queue. | |
~PatientQueue() |
In this destructor you must free up any memory used by your heap. | |
pq.newPatient(name, priority); |
In this function you should add the given person into your patient queue with the given priority. Duplicate names and priorities are allowed. Any string is a legal value, and any integer is a legal priority; there are no invalid values that can be passed. | |
pq.processPatient() |
In this function you should remove the patient with the most urgent priority from your queue, and you should also return their name as a string. You should throw a string exception if the queue does not contain any patients. | |
pq.frontName() |
In this function you should return the name of the most urgent patient (the person in the front of your patient queue), without removing it or altering the state of the queue. You should throw a string exception if the queue does not contain any patients. | |
pq.frontPriority() |
In this function you should return the integer priority of the most urgent patient (the person in the front of your patient queue), without removing it or altering the state of the queue. You should throw a string exception if the queue does not contain any patients. | |
pq.upgradePatient(name, newPriority); |
In this function you will modify the priority of a given existing patient in the queue. The intent is to change the patient's priority to be more urgent (a smaller integer) than its current value, perhaps because the patient's condition has gotten worse. If the given patient is present in the queue and already has a more urgent priority than the given new priority, or if the given patient is not already in the queue, your function should throw a string exception. If the given patient name occurs multiple times in the queue, you should alter the priority of the first occurrence of the value in your heap. | |
pq.isEmpty() |
In this function you should return true if your patient queue does not contain any elements and false if it does contain at least one patient.
|
|
pq.clear(); |
In this function you should remove all elements from the patient queue, freeing memory for your heap structure. | |
ostream << pq |
You should write a << operator for printing your patient queue to the console.
The elements should be printed out in front-to-back order and must be in the form of value:priority with {} braces and separated by a comma and space, such as:
{2:Ford, 4:Bernard, 5:Dolores, 5:William, 5:Teddy, 8:Arnold}
The PatientNode structure has a << operator that may be useful to you.
Your formatting and spacing should match exactly.
Do not place a \n or endl at the end of your output.
|
The headers of every member must match those specified above. Do not change the parameters or function names.
Constructor/destructor:
Your class must define a parameterless constructor.
Since your implementation allocates dynamic memory (using new
), you must ensure that there are no memory leaks by freeing any such allocated memory at the appropriate time.
This will mean that you will need a destructor to free the memory for your heap.
Helper functions:
The members listed on the previous page represent your class's required behavior.
But you may add other member functions to help you implement all of the appropriate behavior.
Any other member functions you provide must be private
.
Remember that each member function of your class should have a clear, coherent purpose.
You should provide private helper members for common repeated operations.
You will also need to do the following:
Add descriptive comments to PatientQueue.h/cpp. One comment for each file should be the Big O for that function. Both files should have top-of-file headers; one file should have header comments atop each member function, either the .h or .cpp; and the .cpp should have internal comments describing the details of each function's implementation.
Declare your necessary private member variables in PatientQueue.h, along with any private member functions you want to help you implement the required public behavior. Your inner data storage must be a heap; do not use any other collections or data structures in any part of your code.
Implement the bodies of all member functions and constructors in PatientQueue.cpp.
Here are a few other constraints we expect you to follow in your implementation:
You should not make unnecessary passes over the heap.
Duplicate patient names and priorities are allowed in your queue.
For example, the upgradePatient
operation should affect only a single occurrence of a patient's name (the first one found).
If there are other occurrences of that same value in the queue, a single call to upgradePatient
shouldn't affect them all.
You are not allowed to use a sort
function or library to arrange the elements of your heap, nor are you allowed to create any temporary or auxiliary data structures anywhere in your code.
You must implement all behavior using only the heap.
You will need pointers for several of your implementations, but you should not use pointers-to-pointers (for example, PatientNode**
).
If you like, you are allowed to use a reference to a pointer (e.g. PQNode*&
).
As in other assignments, you should follow our Style Guide for information about expected coding style. You are also expected to follow all of the general style constraints emphasized in the Homework 1-4 specs, such as the ones about good problem decomposition, parameters, redundancy, using proper C++ idioms, and commenting. The following are additional points of emphasis and style contraints specific to this problem. (Some of these may seem overly strict or arbitrary, but we need to constrain the assignment to force you to properly practice pointers and heaps as intended.)
Commenting: Add descriptive comments to your .h and .cpp files. Both files should have top-of-file headers. One file should have header comments atop each member function (either the .h or .cpp; your choice). The .cpp file should have internal comments describing the details of each function's implementation.
Restrictions on pointers: The whole point of this assignment is to practice implementing a heap. Therefore, do not declare or use any other collections in any part of your code; all data should be stored in your heap. There are some C++ "smart pointer" libraries that manage pointers and memory automatically, allocating and freeing memory as needed; you should not use any such libraries on this assignment.
Restrictions on modifying member function headers:
Please do not make modifications to the PatientQueue
class's public constructor or public member functions' names, parameter types, or return types.
Our client code should be able to call public member functions on your queue successfully without any modification.
Avoiding memory leaks: This item is listed under Style even though it is technically a functional requirement, because memory leakage is not usually visible while a program is running. To ensure that your class does not leak memory, you must delete the entire heap in your destructor.
For each assignment problem, we receive various frequent student questions. The answers to some of those questions can be found by clicking the link below.
operator <<
for printing a priority queue?
It seems like the operator would need access to the private data inside of the priority queue object.
<<
operator in our assignment is declared with a special keyword called friend
that makes it so that this operator is able to directly access the private data inside the priority queue if needed.
new
keyword.
clear
method?
Don't they do the same thing, deleting all elements from the queue?
clear
method is called explicitly when a client wants to wipe the elements and then start over and use the same list to store something else.
A destructor is called implicitly by C++ when an object is being thrown away forever; it won't ever be used to store anything else after that.
The implementations might be similar, but their external purpose is different.
For this problem, you are welcome to implement any of the extensions from Part A of the assignment, or you are welcome to implement a different type of heap.
Indicating that you have done extra features: If you complete any extra features, then in the comment heading on the top of your program, please list all extra features that you worked on and where in the code they can be found (what functions, lines, etc. so that the grader can look at their code easily).
Submitting a program with extra features: Since we use automated testing for part of our grading process, it is important that you submit a program that conforms to the preceding spec, even if you want to do extra features. If your feature(s) cause your program to change the output that it produces in such a way that it no longer matches the expected sample output test cases provided, you should submit two versions of your program file: a first one with the standard file name without any extra features added (or with all necessary features disabled or commented out), and a second one whose file name has the suffix -extra.cpp with the extra features enabled. Please distinguish them in by explaining which is which in the comment header. Our turnin system saves every submission you make, so if you make multiple submissions we will be able to view all of them; your previously submitted files will not be lost or overwritten.


array_unique
(PHP 4 >= 4.0.1, PHP 5, PHP 7)
array_unique — 移除数组中重复的值
说明
array array_unique ( array $array [, int $sort_flags = SORT_STRING ] )
array_unique() 接受 array 作为输入并返回没有重复值的新数组。
注意键名保留不变。array_unique() 先将值作为字符串排序，然后对每个值只保留第一个
遇到的键名，接着忽略所有后面的键名。这并不意味着在未排序的 array 中同一个值的第
一个出现的键名会被保留。
Note: 当且仅当 (string) $elem1 === (string) $elem2 时两个单元被认为相同。就
是说，当字符串的表达一样时。第一个单元将被保留。
参数
array
输入的数组。
sort_flags
The optional second parameter sort_flags may be used to modify the sorting
behavior using these values:
Sorting type flags:
□ SORT_REGULAR - compare items normally (don't change types)
□ SORT_NUMERIC - compare items numerically
□ SORT_STRING - compare items as strings
□ SORT_LOCALE_STRING - compare items as strings, based on the current
locale.
返回值
Returns the filtered array.
更新日志
版本 说明
5.2.10 Changed the default value of sort_flags back to SORT_STRING.
5.2.9 Added the optional sort_flags defaulting to SORT_REGULAR. Prior to
5.2.9, this function used to sort the array with SORT_STRING internally.
范例
Example #1 array_unique() 例子
"green", "red", "b" => "green", "blue", "red");
$result = array_unique($input);
print_r($result);
?>
以上例程会输出：
Array
(
[a] => green
[0] => red
[1] => blue
)
Example #2 array_unique() 和类型
以上例程会输出：
array(2) {
[0] => int(4)
[2] => string(1) "3"
}
参见
• array_count_values() - 统计数组中所有的值出现的次数
注释
Note: Note that array_unique() is not intended to work on multi dimensional
arrays.
User Contributed Notes 63 notes
===============================================================================
It's often faster to use a foreache and array_keys than array_unique:
$val) {
$res2[$val] = true;
}
$res2 = array_keys($res2);
$time += microtime(true);
echo "
deduped to ".count($res2)." in ".$time;
// deduped to 666667 in 0.84372591972351
?>
===============================================================================
Create multidimensional array unique for any single key index.
e.g I want to create multi dimentional unique array for specific code
Code :
My array is like this,
array("id"=>"1", "name"=>"Mike", "num"=>"9876543210"),
1 => array("id"=>"2", "name"=>"Carissa", "num"=>"08548596258"),
2 => array("id"=>"1", "name"=>"Mathew", "num"=>"784581254"),
);
?>
You can make it unique for any field like id, name or num.
I have develop this function for same :
Now, call this function anywhere from your code,
something like this,
Output will be like this :
array("id"=>"1","name"=>"Mike","num"=>"9876543210"),
1 => array("id"=>"2","name"=>"Carissa","num"=>"08548596258"),
);
?>
===============================================================================
For people looking at the flip flip method for getting unique values in a
simple array. This is the absolute fastest method:
It's marginally faster as:
And it's marginally slower as:
It's still about twice as fast or fast as array_unique.
This tested on several different machines with 100000 random arrays. All
machines used a version of PHP5.
===============================================================================
If you find the need to get a sorted array without it preserving the keys, use
this code which has worked for me:
The above code returns an array which is both unique and sorted from zero.
===============================================================================
recursive array unique for multiarrays
$value)
{
if ( is_array($value) )
{
$result[$key] = super_unique($value);
}
}
return $result;
}
?>
===============================================================================
Case insensitive; will keep first encountered value.
===============================================================================
This is a fast solution to remove duplicate values from an array when it
contains only strings or only integers:
'Yellow',
1 => 'Green',
2 => 'Yellow',
3 => 'Blue',
4 => 'Yellow',
);
$uniq = array_keys(array_flip($array));
var_export($uniq);
/* Output:
array (
0 => 'Yellow',
1 => 'Green',
2 => 'Blue',
)
*/
?>
===============================================================================
I needed to identify email addresses in a data table that were replicated, so I
wrote the array_not_unique() function:
$value) {
if ($value === NULL) { continue; }
if ($old_value == $value) {
$dupes[$old_key] = $old_value;
$dupes[$key] = $value;
}
$old_value = $value;
$old_key = $key;
}
return $dupes;
}
$raw_array = array();
$raw_array[1] =<EMAIL_ADDRESS>$raw_array[2] =<EMAIL_ADDRESS>$raw_array[3] =<EMAIL_ADDRESS>$raw_array[4] =<EMAIL_ADDRESS>// Duplicate
$common_stuff = array_not_unique($raw_array);
var_dump($common_stuff);
?>
===============================================================================
To clarify the note above Example #1, the function appears to cast the elements
to strings for comparison and then return the type of the first unique element
encountered.
array(4) {
[0]=>
int(0)
[1]=>
int(2)
[3]=>
int(3)
[4]=>
string(1) "9"
}
===============================================================================
I noticed there was no way to tell array_unique() to ignore certain duplicated
keys, so I wrote the following. I imagine there's half a dozen more efficient
ways to do this, but here goes:
OUTPUT:
Array
(
[0] => foo
[1] => bar
[2] => xyzzy
[3] => &
[5] => baz
[6] => bat
[7] => |
[9] => plugh
[11] => foobar
[12] => |
[13] => plonk
[15] => apples
[16] => &
[18] => oranges
[20] => pears
)
===============================================================================
[Editor's note: please note that this will not work well with non-scalar values
in the array. Array keys can not be arrays themselves, nor streams, resources,
etc. Flipping the array causes a change in key-name]
You can do a super fast version of array_unique directly in PHP, even faster
than the other solution posted in the comments!
Compared to the built in function it is 20x faster! (2x faster than the
solution in the comments).
This works faster for small and big arrays.
===============================================================================
Another way to 'unique column' an array, in this case an array of objects:
Keep the desired unique column values in a static array inside the callback
function for array_filter.
Example:
id = $id;
$this->value = $value;
}
}
/* callback function */
function uniquecol( $obj ) {
static $idlist = array();
if ( in_array( $obj->id, $idlist ) )
return false;
$idlist[] = $obj->id;
return true;
}
/* a couple of arrays with second array having an element with same id as the
first */
$list = array( new myObj( 1, 1 ), new myObj( 2, 100 ) );
$list2 = array( new myObj( 1, 10 ), new myObj( 3, 100 ) );
$list3 = array_merge( $list, $list2 );
$unique = array_filter( $list3, 'uniquecol' );
print_r( $list3 );
print_r( $unique );
?>
In addition, use array_merge( $unique ) to reindex.
===============================================================================
Here's the shortest line of code I could find/create to remove all duplicate
entries from an array and then reindex the keys.
===============================================================================
A very simple way of getting rid of duplicate entries and re-indexing with key
starting at 0:
===============================================================================
This is a script for multi_dimensional arrays
===============================================================================
another method to get unique values is :
Output:
Array ( [0] => a [1] => b [2] => c [3] => d [4] => e [5] => f )
===============================================================================
Let's say you have
It works but the if-statement gets a bit messy if the number of array elements
gets massive.
I find it is easier to use array_unique like so:
===============================================================================
I searched how to show only the duplicate elements from array, but failed.
Here is my solution:
Example:
Output:
Array
(
[4] => xyzzy
[12] => |
[16] => &
[21] => foobar
)
===============================================================================
This is how to merge 2 comma separated lists with unique value only.
The result is: 4444,5555,6666,7777
===============================================================================
Problem:
I have loaded an array with the results of a database
query. The Fields are 'FirstName' and 'LastName'.
I would like to find a way to contactenate the two
fields, and then return only unique values for the
array. For example, if the database query returns
three instances of a record with the FirstName John
and the LastName Smith in two distinct fields, I would
like to build a new array that would contain all the
original fields, but with John Smith in it only once.
Thanks for: Colin Campbell
Solution:
* $_GET = array('id' => '4587','with' => 'key');
* ...
* echo shared::implode_with_key('&',$_GET,'='); // Resultado: id=4587&with=key
* ...
*
*
* @param string $glue Oque colocar entre as chave => valor
* @param array $pieces Valores
* @param string $hifen Separar chave da array do valor
* @return string
* @author memandeemail at gmail dot com
*/
function implode_with_key($glue = null, $pieces, $hifen = ',') {
$return = null;
foreach ($pieces as $tk => $tv) $return .= $glue.$tk.$hifen.$tv;
return substr($return,1);
}
/**
* Return unique values from a tree of values
*
* @param array $array_tree
* @return array
* @author memandeemail at gmail dot com
*/
function array_unique_tree($array_tree) {
$will_return = array(); $vtemp = array();
foreach ($array_tree as $tkey => $tvalue) $vtemp[$tkey] = implode_with_key('&
',$tvalue,'=');
foreach (array_keys(array_unique($vtemp)) as $tvalue) $will_return[$tvalue] =
$array_tree[$tvalue];
return $will_return;
}
$problem = array_fill(0,3,
array('FirstName' => 'John', 'LastName' => 'Smith')
);
$problem[] = array('FirstName' => 'Davi', 'LastName' => 'S. Mesquita');
$problem[] = array('FirstName' => 'John', 'LastName' => 'Tom');
print_r($problem);
print_r(array_unique_tree($problem));
?>
===============================================================================
I required a function that removed a specific duplicate entry from an array and
ignoring all others so came up with this:
$array_value)
{
if ( ($count > 0) && ($array_value == $value) )
{
unset($array[$array_key]);
}
if ($array_value == $value) $count++;
}
return array_filter($array);
}
?>
===============================================================================
Lets say that you want to capture unique values from multidimensional arrays
and flatten them in 0 depth.
i.e.
array( 1,2,3,4 ), 'b' => array( 'c' => array( 4,5,6,7 ) )
);
?>
will return with array_flat( $tmp ) --> array( 1,2,3,4,5,6,7 );
I hope that the function will help someone
$v )
{
# check if the contained values are arrays
if( !is_array( $v ) )
{
# store the value
$s[ ] = $v;
# move to the next node
continue;
}
# increment depth level
$l++;
# replace the content of stored values
$s = array_flat( $v, $s, $l );
# decrement depth level
$l--;
}
# get only unique values
if( $l == 0 ) $s = array_values( array_unique( $s ) );
# return stored values
return $s;
} # end of function array_flat( ...
}
?>
===============================================================================
"1",
"UGCOURSE"=>"ABC",
"TSINITIATE"=>"540",
"COUNT"=>"34",
"ENTRY_DT"=>"2006-05-01",
"CUMULATIVE"=> 44);
$arrUGCourse[]= array( "CTR" => "2",
"UGCOURSE"=>"ABC",
"TSINITIATE"=>"5401",
"COUNT"=>"341",
"ENTRY_DT"=>"2006-05-11",
"CUMULATIVE"=> 44);
print_r(array_uniquecolumn($arrUGCourse));
?>
===============================================================================
I needed a way of retaining the original array's keys in the new, unique array.
I came up with this. It works for my purposes but may need refinement.
$var)
{
if (next($somearray) != $currentarrayvar)
{
$uniquearray[$key] = $currentarrayvar;
$currentarrayvar = current($somearray);
}
}
reset($uniquearray);
return $uniquearray;
}
?>
===============================================================================
I found the simplest way to "unique" multidimensional arrays as follows:
array(1, 2),
'b' => array(1, 2),
'c' => array(2, 2),
'd' => array(2, 1),
'e' => array(1, 1),
);
$array = array_map('json_encode', $array);
$array = array_unique($array);
$array = array_map('json_decode', $array);
print_r($array);
?>
As you can see "b" will be removed without any errors or notices.
===============================================================================
I created a function for doing array_unique with a custom in_array function.
So, if elements are considered in the array passed to this function, the array
returned won't include elements that are considered equal and only return the
values from the first array that are not considered in the array:
$item) {
if (!$in_array_func($item, $result)) {
$result[$key] = $item;
}
}
return $result;
}
?>
Example usage:
===============================================================================
Another form to make an array unique (manual):
This is my array
Array
(
[0] => Array
(
[0] => 40665
[1] => 40665
[2] => 40665
[3] => 40665
[4] => 40666
[5] => 40666
[6] => 40666
[7] => 40666
[8] => 40667
[9] => 40667
[10] => 40667
[11] => 40667
[12] => 40667
[13] => 40668
[14] => 40668
[15] => 40668
[16] => 40668
[17] => 40668
[18] => 40669
[19] => 40669
[20] => 40670
[21] => 40670
[22] => 40670
[23] => 40670
[24] => 40671
[25] => 40671
[26] => 40671
[27] => 40671
[28] => 40671
)
[1] => Array
(
[0] => 40672
[1] => 40672
[2] => 40672
[3] => 40672
)
)
this is my script:
$anterior = 0;
foreach($item as $array_key => $array_value)
{
echo "
$array_key";
echo "";
foreach($array_value as $xarray_key => $xarray_value){
if($xarray_value != $anterior) {
echo "- $xarray_key => $xarray_value";
$item_nuevo[$array_key][] = $xarray_value; // or to use
the same key number $item_nuevo[$array_key][$xarray_key] = $xarray_value;
}
$anterior = $xarray_value;
}
echo "
";
}
result:
0
0 => 40665
4 => 40666
8 => 40667
13 => 40668
18 => 40669
20 => 40670
24 => 40671
1
0 => 40672
saludos desde chile.
===============================================================================
My object unique function:
$f ) {
if( !array_key_exists( $n, $objArray ) ) unset( $obj->$n );
}
return $obj;
}
?>
And these code:
returns:
object(Test)[1]
public 'pr0' => string 'string' (length=6)
public 'pr1' => string 'string1' (length=7)
public 'pr3' => string 'string2' (length=7)
===============================================================================
If you use SORT_NUMERIC on this kind of filtering it will be significantly
faster.
However the array_flip method still is twice as fast.
===============================================================================
Taking the advantage of array_unique, here is a simple function to check if an
array has duplicate values.
It simply compares the number of elements between the original array and the
array_uniqued array.
===============================================================================
Although array_unique is not intended to work with multi-dimensional arrays, it
does on 5.2.9. However, it does not for 5.2.5. Beware.
===============================================================================
//Remove duplicates from a text files and dump result in one file for example:
emails list, links list etc
===============================================================================
so .... my problem was multidimensional sort.
Array $attribs is an array contaning arrays. Each array in the $attrib array
consists in multiple fields (ex: name, lenght, price, etc.) to be more simpler
in speech think that $attrib is the array resulted by a search sql query done
by a visitator on your online shoopping website ... (so ... each array in the
$attrib is a product :P) if you want to sort only the uniq results use the
above or use this:
"Test Product 1",
"length" => "42 cm",
"weight" => "0,5 kg",
"price" => "10 $",
"stock" => "100",
);
$attribs[] = array(
"name" => "Test Product 2",
"length" => "42 cm",
"weight" => "1,5 kg",
"price" => "10 $",
"stock" => "200",
);
/* The nice stuff */
$new = array();
$exclude = array("");
for ($i = 0; $i<=count($attribs)-1; $i++) {
if (!in_array(trim($attribs[$i]["price"]) ,$exclude)) { $new[] =
$attribs[$i]; $exclude[] = trim($attribs[$i]["price"]); }
}
print_r($new); // $new is our sorted array
?>
Have fun tweaking this ;)) i know you will ;))
From Romania With Love
===============================================================================
I came across one limitation of array_unique: it doesn't work properly if you
have arrays inside your main array.
The reason is that to compare two values, the function tests if (string)
$value1 == (string) $value2. So if $value1 and $value2 are both arrays, the
function will evaluate the test to 'Array' == 'Array', and decide that the
$values are repeated even if the arrays are different.
So a work around is to find a better conversion of an array to a string, which
can be done with json:
1,
'b' => 1,
'c' => 2,
'd' => array(1),
'e' => array(1),
'f' => array(2),
);
print_r($a_not_unique);
print "try to use simply array_unique, which will not work since it exludes
'array(2)':";
$a_unique_wrong = array_unique($a_not_unique);
print_r($a_unique_wrong);
print "convert to json before applying array_unique, and convert back to array,
which will successfully keep 'array(2)':";
$a_unique_right = $a_not_unique;
array_walk($a_unique_right, create_function('&$value,$key', '$value =
json_encode($value);'));
$a_unique_right = array_unique($a_unique_right);
array_walk($a_unique_right, create_function('&$value,$key', '$value =
json_decode($value, true);'));
print_r($a_unique_right);
?>
Results:
define an array with repeated scalar '1' and repeated 'array(1)':
Array
(
[a] => 1
[b] => 1
[c] => 2
[d] => Array
(
[0] => 1
)
[e] => Array
(
[0] => 1
)
[f] => Array
(
[0] => 2
)
)
try to use simply array_unique, which will not work since it exludes 'array(2)
':
Array
(
[a] => 1
[c] => 2
[d] => Array
(
[0] => 1
)
)
convert to json before applying array_unique, and convert back to array, which
will successfully keep 'array(2)':
Array
(
[a] => 1
[c] => 2
[d] => Array
(
[0] => 1
)
[f] => Array
(
[0] => 2
)
)
===============================================================================
Case insensitive for PHP v4.x and up.
$v) {
if (!in_iarray($v, $n)) {
$n[$k]=$v;
}
}
return $n;
}
$input = array("aAa","bBb","cCc","AaA","ccC","ccc","CCC","bBB","AAA","XXX");
$result = array_iunique($input);
print_r($result);
/*
Array
(
[0] => aAa
[1] => bBb
[2] => cCc
[9] => XXX
)
*/
?>
===============================================================================
This is a recursive arrayUnique function for arrays of any dimension. (tested
with 4-dimensional array)
The line '$newArray=deleteEmpty($newArray);' is optional and removes empty keys
and values
$val)
{
if (is_array($val))
{
$val2 = arrayUnique($val);
}
else
{
$val2 = $val;
$newArray=array_unique($myArray);
$newArray=deleteEmpty($newArray);
break;
}
if (!empty($val2))
{
$newArray[$key] = $val2;
}
}
}
return ($newArray);
}
function deleteEmpty($myArray)
{
$retArray= Array();
foreach($myArray as $key=>$val)
{
if (($key<>"") && ($val<>""))
{
$retArray[$key] = $val;
}
}
return $retArray;
}
?>
===============================================================================
Here's another solution for returning an array that only includes repeated
values. There is one given below but it only works on numerically indexed
arrays; this one is more comprehensive since I used the foreach iterator. Also,
this one preserves keys--in that the returned result contains a distinct list
of repeats (storing only the first instance it encounters of each duplicate
value).
$val ) {
end($array);
$k = key($array);
$v = current($array);
while ( $k !== $key ) {
if ( $v === $val ) {
$duplicates[$key] = $v;
break;
}
$v = prev($array);
$k = key($array);
}
}
return $duplicates;
}
?>
===============================================================================
I had a problem with array_unique and multidimensional arrays ... Maybe there's
a better way to do this, but this will work for any dimensional arrays.
===============================================================================
I quite like the following code for making multidimensional arrays unique:
$arrAddress) {
$arrAddressList[$key] = serialize($arrAddress);
}
$arrAddressList = array_unique($arrAdressList);
foreach ($arrAddressList AS $key => $strAddress) {
$arrAddressList[$key] = unserialize($strAddress);
}
?>
This gets me a unique array while not minding wether the the original array
contains arrays or just strings (or whatever...).
===============================================================================
Following the code copies of a little function I've wrote that actually works
with multidimensional arrays.
It also resets the array indexes.
===============================================================================
The following is an efficient, adaptable implementation of array_unique which
always retains the first key having a given value:
&$val) if (@$aHash[$val]++) unset ($aray[$key]);
}
?>
It is also adaptable to multi dimensional arrays. For example, if your array
is a sequence of (multidimensional) points, then in place of @$aHash[$val]++
you could use @$aHash[implode("X",$val)]++
If you want to not have holes in your array, you can do an array_merge($aray)
at the end.
Csaba Gabor
===============================================================================
Just to note that array_unique, treats null values as none unique values. So if
your using array_unique to detect duplicate values it will also detect multiple
null values.
===============================================================================
Before I found the mysql distinct I had to make a nicer array from the keys/
values that I got from array_unique so.
===============================================================================
One way to use array_unique() to handle the multidimensional array issue is to
use an md5 hash of the serialized array as the key. I've seen some solutions
listed here that stored the serialized string, but that requires
unserialization, and moving data back and forth between two states for little
reason is just a bad idea. Instead, you could try this method:
This will serialize and hash the value, and store the value with the hash as
they key. This will ensure that each piece is only stored once, as the second
attempt to store will just overwrite the first attempt with identical data.
The sort() at the end is a bit unnecessary, but I had to use it on my project,
because the function I was passing the array to couldn't handle keys that
weren't valid XML node names (and some md5 hash strings will start with
numbers, which is invalid for XML).
===============================================================================
Try this:
array_flip(array_flip($array));
It gives the same result as the old array_unique()
===============================================================================
result :
l810u00
This is not strange: $machin (as returned by array unique), contains "l810u00"
either in key[0] or key[1] but not both (the key depends on the ersion of PHP),
and "l810q00" in key[2].
The returned array has TWO elements so count($machin)==2.
The returned array has a hole in it, and you're not displaying its full
content. You could verify it by using this display loop instead:
foreach($machine as $key=>$value){
print '[' . $key . '] => ' . $value . '
";
}
result:
[0] => l810q00
[2] => l810u00
(the first line may display [1] instead of [0] for PHP 4.0.1p3, but you'll get
the same order of values and two lines, as expected). When calling array_values
() on the result, you're building a new array with the same values in the same
order, but with renumbered keys (without holes in numeric keys).
===============================================================================
If you're doing numeric arrays etc. I found flip-flip to work much better than
array_unique:
');
//try my flip-flip
$start2=microtime_float();
array_flip(array_flip($final));
$stop2=microtime_float();
echo($stop2-$start2);
?>
Running this with only ints in the array (as above) I get runtimes such as:
1.6195669174194 (using unique)
0.017037868499756 (using flip flip)
which is two orders of magnitude faster!
Appending a string:
($final[]='test'.$i%13;)
gives:
0.42909598350525 (using unique)
0.023258924484253 (using flip-flip)
Which is not AS great, but still 20x faster than unique.
In both cases the flip-flip seems to use less memory than the unique.
Granted the flip-flip doesn't work for all cases, but if you're doing simple
stuff like this, the flip-flip will give you better run times.
~JF
===============================================================================
It seems that array_unique creates an exact copy of the original array and then
elimitates duplicate values. It does NOT change the "internal references" of
the array. For example:
");
echo ("Number of elements in test_beta = $numValues ");
?>
will give you the following output:
test_beta[0] =
test_beta[1] = aa
test_beta[2] =
test_beta[3] =
test_beta[4] =
test_beta[5] = bb
test_beta[6] = cc
test_beta[7] =
Number of elements in test_beta = 3
The point is that you won't get the output you'd expect if you think that the
values of the non duplicate elements are located in the first three array
locations.
");
echo ("Number of elements in test_beta = $numValues ");
?>
will give you:
test_beta[0] =
test_beta[1] = aa
test_beta[2] =
Number of elements in test_beta = 3
Hope that saves u some debugging time!
===============================================================================
this function will return an array with unique value and proper key increment
start from 0.
eg:
normal array_unique will return:
my_array_unique will return:
===============================================================================
===============================================================================
Attention!
If you use array_unique be aware of data-types! (I spent hours of debugging
because of that ...).
For example, if you've got an array containing a '3' as number and another '3'
as string it won't be eliminated by array_unique.
An Example where this can happen, without really thinking about it:
I've got an article-list with product-numbers where the third and fourth digit
is the code for the producer. So I read in the file an process it line by line
and put each producer-code into an array:
------------------------------
-------------------------------
Result is to have all producer-ID's in an array without dupes.
===============================================================================
If you need to have the keys of the duplicates in an array returned, you may
find this function useful:
$value){
if (in_array($value,$count)){
$return[$value][]=$key;
}
}
return $return;
}
?>
Example:
Input:
Array
(
[0] => 44
[1] => 23
[2] => 23
[3] => 23
[4] => 9
[5] => 9
[6] => 9
[7] => 9
[8] => 9
[9] => 9
[10] => 9
[11] => 9
)
Function returns:
Array
(
[23] => Array
(
[0] => 1
[1] => 2
[2] => 3
)
[9] => Array
(
[0] => 4
[1] => 5
[2] => 6
[3] => 7
[4] => 8
[5] => 9
[6] => 10
[7] => 11
)
)
===============================================================================
if you wish to unique the arrays recusively(multi dimensional) no matter how
deep hope this function can help you:
function array_unique_recusive($arr){
foreach($arr as $key=>$value)
if(gettype($value)=='array')
$arr[$key]=array_unique_recusive($value);
return array_unique($arr,SORT_REGULAR);
}
===============================================================================
Hope this can help...
$val) {
$i = array_search($val,$temp);
if(!empty($i) && $key != $i) {
$temp[$i.','.$key] = $temp[$i];
unset($temp[$i]);
}
}
return $temp;
}
?>
this function return an array that is unique, but preserve every key for the
element...
sorry for bad english I'm italian...
$array['asd'] = 'value';
$array['lol'] = 'value';
$array['foo'] = 'val';
$array['bar'] = 'val';
var_dump(array_unique_key_group($array));
// will be output
array(2) { ["asd,lol"]=> string(5) "value" ["foo,bar"]=> string(3) "val" }
===============================================================================
The shortest way i found to remove duplicate array from a column,
For example if you parse Multiple XML sources, you can remove duplicate items
that contain the same link.
$rien)
$new[] = $array[$k];
return $new;
}
?>
===============================================================================
To get a list of the duplicated values in an array, array_unique isn't much
help. Instead, use array_filter in conjunction with a callback function, as
below:
1) return
true;');
$result = array_keys (array_filter (array_count_values($array),
$checkKeysUniqueComparison));
?>
These two lines therefore will create $result, an array of duplicated values in
the array $array, once each. E.g. the array
$array = array ("a", "b", "a", "b", "x", "y", "z", "x");
gives the result
Array([0] => a [1] => b [2] => x)
===============================================================================
array_unique only compares with the string,
But to compare with various types of variables I used like this:
$v) {
foreach ($array as $k2 => $v2) {
if (($v2 == $v) && ($k != $k2)) {
unset($array[$k]);
}
}
}
return $array;
}
$a = [];
$a[] = (object)['nome' => 'Bob'];
$a[] = (object)['nome' => 'Peter'];
$a[] = (object)['nome' => 'Jhon'];
$a[] = (object)['nome' => 'James'];
$a[] = (object)['nome' => 'David'];
$a[] = (object)['nome' => 'Bob']; // repeated
if ($a[0] == $a[5]) { // true
echo 'yes';
} else {
echo 'not';
}
echo "\n\n";
$a = arrayUnique($a);
print_r($a);
?>
===============================================================================
I made an array_unique function to handle deep arrays:
outputs
Array
(
[0] => 123
[1] => 456
[2] => 789
)
===============================================================================
Let's implement array_unique_callback() !
Function:
Usage:
array(
'name' => 'Foo - Ltd.',
'phone' => 'XXX-YYY-ZZZ',
'category' => 'supplyment',
),
1 => array(
'name' => 'Bar - Ltd.',
'phone' => 'xxx-yyy-zzz',
'category' => 'supplyment',
),
2 => array(
'name' => 'Baz - Ltd.',
'phone' => 'AAA-BBB-CCC',
'category' => 'alcohol',
),
);
$companies = array_unique_callback(
$companies,
function ($company) {
return $company['category'];
}
);
print_r($companies);
?>
Result:
Array
(
[0] => Array
(
[name] => Foo - Ltd.
[phone] => XXX-YYY-ZZZ
[category] => supplyment
)
[2] => Array
(
[name] => Baz - Ltd.
[phone] => AAA-BBB-CCC
[category] => alcohol
)
)
===============================================================================
Prior to 5.2.9 you may create a list of unique objects this way:
===============================================================================
Following code copies unique values from MyArray to TempArray.
Then copies non-empty elements from TempArray to UniqueArray.
Not the most elegant solution, but it works.
===============================================================================
I had to write a bunch of results to an array with a high probability of
duplicates.
The array was written to the file in chunks, using a for loop. It occurred to
me that I often had blank lines in my file.
Because this function preserve keys, I had gaps in my numeric keys. If you
don't want to preserve keys, like me, you can use the following function.
===============================================================================
array_unique for multidimensional arrays. similar to the DISTINCT in SQL
function.
the function can group, sum and count keys
$sub_array){
$puffer = NULL;
#group keys
foreach ($group_keys as $group_key){
$puffer .= $sub_array[$group_key];
}
$puffer = serialize ($puffer);
if (!in_array ($puffer, $existing_sub_keys)){
$existing_sub_keys[$key] = $puffer;
$output[$key] = $sub_array;
}
else{
$puffer = array_search ($puffer, $existing_sub_keys);
#sum keys
foreach ($sum_keys as $sum_key){
if (is_string ($sum_key)) $output[$puffer][$sum_key] += $sub_array[
$sum_key];
}
#count grouped keys
if (!array_key_exists ($count_key, $output[$puffer])) $output[$puffer][
$count_key] = 1;
if (is_string ($count_key)) $output[$puffer][$count_key]++;
}
}
return $output;
}
?>


Class: UserSshKey
- Inherits:
- SshKey show all
- Includes:
- Mongoid::Document
- Defined in:
- /home/fedora/origin-server/controller/app/models/user_ssh_key.rb
Overview
Class representing a CloudUser level ssh key. These keys are provided by the user and used for all ssh and git operations.
Constant Summary
Constant Summary
Constants inherited from SshKey
SshKey::KEY_NAME_MAX_LENGTH, SshKey::KEY_NAME_MIN_LENGTH, SshKey::KEY_NAME_REGEX, SshKey::VALID_SSH_KEY_TYPES
Instance Attribute Summary (collapse)
-
- (CloudUser) cloud_user
readonly
The user this key belongs to.
Attributes inherited from SshKey
Method Summary
Methods inherited from SshKey
check_name!, #does_not_start_with_dot, get_valid_ssh_key_types, #to_key_hash, #to_obj, validation_map
Methods included from AccessControlled
Instance Attribute Details
- (CloudUser) cloud_user (readonly)
The user this key belongs to.
6 7 8 9 |
# File '/home/fedora/origin-server/controller/app/models/user_ssh_key.rb', line 6 class UserSshKey < SshKey include Mongoid::Document :cloud_user, class_name: CloudUser.name end |


I am Logan Cypser, I am 15 years old and I attend Albemarle High School and I am a part of the Math Club as well as the Track Team. I am fluent in MATLAB and Python and my current passions include deep learning, machine learning, programming, computer science, and running.
I am currently working on my science fair project, it uses
Sed faucibus felis purus, sed convallis leo dictum vehicula.
Education
- ABC degree from XYZ University.
- ABC degree from XYZ University.
- ABC degree from XYZ University.
Roles
Founder, ABC Organisation
Skills
- Programming -
Matlab
/Python
/Swift
- Web Development -
HTML
/SCSS
/JavaScript
/Jekyll
/Node.Js
- Data Science -
Machine Learning
/Microsoft Excel
/R
- Engineering -
Raspberry Pi
/Fusion 360
/Arduino
Achievements
-
Proin pellentesque malesuada mauris, quis aliquam augue vestibulum ac. Vestibulum ut feugiat nibh. Sed faucibus felis purus, sed convallis leo dictum vehicula.
-
Proin pellentesque malesuada mauris, quis aliquam augue vestibulum ac. Vestibulum ut feugiat nibh. Sed faucibus felis purus, sed convallis leo dictum vehicula.
-
Proin pellentesque malesuada mauris, quis aliquam augue vestibulum ac. Vestibulum ut feugiat nibh. Sed faucibus felis purus, sed convallis leo dictum vehicula