Skip to content

Instantly share code, notes, and snippets.

View tarlepp's full-sized avatar
💭
örrr

Tarmo Leppänen tarlepp

💭
örrr
  • Pinja
  • Jyväskylä, Finland
View GitHub Profile
@ciaranmcnulty
ciaranmcnulty / Dockerfile
Last active June 15, 2023 01:14
PHP Dockerfile with composer target
FROM php:7.2.10-fpm-alpine3.8 AS base
# Stuff needed in all layers
RUN apk add --no-cache gettext fcgi icu-dev
RUN docker-php-ext-install bcmath
FROM base AS dependencies
COPY --from=composer:1.7 /usr/bin/composer /usr/bin/composer
COPY composer.json /app/composer.json
@ostrolucky
ostrolucky / ColumnHydrator.php
Last active January 3, 2022 11:53
Doctrine ColumnHydrator
<?php
declare(strict_types=1);
namespace App\ORM\Hydration;
use Doctrine\ORM\Internal\Hydration\ArrayHydrator;
/**
* Returns one-dimensional scalar array from query: mixed[][] => mixed[]
@simshaun
simshaun / TextTypeExtension.php
Created February 21, 2017 02:10
Symfony TextTypeExtension
<?php
namespace PlatformBundle\Form\Extension;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;
Development environment installation guide (PHP, Node, etc.), purpose of this guide is to
complish "working" development environment where you have common Open Source tools at your
use without any hahshle.
BASIC INSTALLATION:
1) Donwloand and install VirtualBox / VMWare
- Use which you want, guide is based to VirtualBox
- Difference between these two should not be so huge after all
2) Downloadn latest Ubuntu LTS version
- In this time it was 16.04
@bebraw
bebraw / active.md
Created December 12, 2015 12:31
Most active GitHub users in Finland (2015)

Most active GitHub users in Finland (git.io/top)

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Fri, 12 Dec 2014 12:29:07 GMT till Sat, 12 Dec 2015 12:29:07 GMT.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
 .filter(user =&gt; user.followers &gt; 12)

Angular2 + JSPM cheat sheet

First time setup

  • install jspm beta: npm install -g jspm@beta
  • set up your project: jspm init
  • install dependencies: jspm install angular2 reflect-metadata zone.js es6-shim

This will create a jspm_packages folder, and a config.js file.

Open the config.js file - this file manages options for the System.js loader - tweak it as appropriate

@dinana
dinana / useDeepPopulate.js
Last active June 13, 2019 08:33
Util Sails Service with PopulateDeep function
User.find(id).populate('preferences').exec(function (err, user) {
if(err) {
sails.log.error("ERR:", err);
}
sails.services['util'].populateDeep('user', user[0], 'preferences.nestedPreferences', function (err, newUser) {
if (err) {
sails.log.error("ERR:", err);
}
console.log(newUser);
});

What's the difference between cascade="remove" and orphanRemoval=true in Doctrine 2

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

Most active GitHub users in Finland programming in JavaScript

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Thu, 12 Dec 2013 15:54:31 GMT till Fri, 12 Dec 2014 15:54:31 GMT.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
 .filter((user) -&gt; user.followers &gt; 11)
var connections = {}
, userService;
userService = {
/**
* Update the ID of the socket connection for a user.
*
* @param {String} userId
* @param {String} socketId