This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * @param array $data array of "key => weight" data to get random key from, all weights must be positive integers | |
| * @return mixed key from $data array choosen by weighted random | |
| */ | |
| function weightRandom(array $data) | |
| { | |
| $c = count($data); | |
| if (!$c) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| failed (104: Connection reset by peer) while reading response header from upstream, client: | |
| If you are getting the above error in nginx logs running in from of upstream servers you may consider doing this as it worked for me: | |
| check the ulimit on the machines and ensure it is high enough to handle the load coming in. 'ulimit' on linux, I am told determines the maximum number of open files the kernel can handle. | |
| The way I did that? | |
| modifying limits: for open files: | |
| -------------------------------- | |
| add or change this line in /etc/systcl.conf | |
| fs.file-max = <limit-number> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| reload() { | |
| source ${BASH_SOURCE[0]} | |
| } | |
| alias r=reload | |
| get-image-field() { | |
| local imageId=$1 | |
| local field=$2 | |
| : ${imageId:? reuired} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /etc/php5/fpm/php-fpm.conf | |
| error_log = syslog | |
| syslog.ident = php-fpm | |
| This will log to syslog PHP-FPM stuff that usually gets logged to /var/log/php5-fpm.log and is not that interesting: | |
| ... php-fpm[3537]: [NOTICE] fpm is running, pid 3537 | |
| ... php-fpm[3537]: [NOTICE] ready to handle connections | |
| ... php-fpm[3537]: [NOTICE] Finishing ... |
TLDR: The cascade={"remove"} is like a "software" onDelete="CASCADE", and will remove objects from the database only when an explicit call to $em->remove() occurs. Thus, it could result in more than one object being deleted. orphanRemoval can remove objects from the database even if there was no explicit call to ->remove().
I answered this question a few times to different people so I will try to sum things up in this Gist.
Let's take two entities A and B as an example. I will use a OneToOne relationship in this example but it works exactly the same with OneToMany relationships.
class A
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Steps we will take: | |
| # 1. Change boot2docker image type (this will take long) | |
| # 2. Resize image | |
| # 3. Resize partion (using GParted) | |
| # | |
| # Also see: https://docs.docker.com/articles/b2d_volume_resize/ | |
| # Stop boot2docker | |
| boot2docker stop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Hi | |
| After literally hours of trial and error (I'm not a Linux guy but love playing with my Raspberry Pi's), I have FINALLY got shairport-sync running on ArchLinux Arm 7 on my Raspberry Pi 2. I used numerous different sources to find all the different workarounds. I documented it and would like to give something back to the community... so here it is. I hope it's helpful. | |
| Disclaimer: I'm sure I could have been a lot more efficient in my approach but I hope this will serve as a starting point for others. | |
| 1) RaspberryPi.org are not offering an ArchLinux image for Arm7 yet but some friendly guy has created his own and kindly put it on Mega.co.nz for all to use. Download the ArchLinux Arm 7 image for Raspberry Pi 2 from here: https://mega.co.nz/#!2JZS0CqD!KxlXr9B6URZ79zTP23vKVdrdOGVOYIeasjcjcBMoPzo | |
| 2) Write to a formatted SD card (at least 4GB) using Win32DiskImager. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Acme\Serializer\Normalizer; | |
| use Doctrine\Common\Collections\ArrayCollection; | |
| use Doctrine\Common\Collections\Collection; | |
| use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; | |
| use Symfony\Component\Serializer\Normalizer\NormalizerInterface; | |
| use Symfony\Component\Serializer\Normalizer\SerializerAwareNormalizer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var $button = $('.js-filter-button'); | |
| $button.on('click', function(event) { | |
| event.preventDefault(); | |
| var $this = $(this); | |
| var $form = $this.closest('form'); | |
| var emptyTextBoxes = $form.find('input:text, input:radio, input:checkbox, select').filter(function() { | |
| return this.value == ""; | |
| }); |

