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
  • 12:27 (UTC +03:00)
View GitHub Profile
@jgornick
jgornick / criteria-to-query-builder.php
Created January 28, 2014 16:57
Doctrine: Criteria Array to Doctrine QueryBuilder
<?php
/**
* Recursively takes the specified criteria and adds too the expression.
*
* The criteria is defined in an array notation where each item in the list
* represents a comparison <fieldName, operator, value>. The operator maps to
* comparison methods located in ExpressionBuilder. The key in the array can
* be used to identify grouping of comparisons.
*
@johnkary
johnkary / LikeQueryHelpers.php
Last active April 22, 2022 08:09
Proper DQL escaping for LIKE queries with Doctrine 2.
<?php
namespace Foo;
/**
* Methods for safe LIKE querying.
*/
trait LikeQueryHelpers
{
/**
@Kuirak
Kuirak / client
Last active August 29, 2015 14:00
$sailsSocket.subscribe('event',function(message){
if(message.verb ==='created'){
$scope.events.push(message.data);
}
});
$sailsSocket.get('/api/event/subscribe').success(function(data){
console.log("Subscribed")
});
$sailsSocket.get('/api/event').success(function(data){
$scope.events =data;
var connections = {}
, userService;
userService = {
/**
* Update the ID of the socket connection for a user.
*
* @param {String} userId
* @param {String} socketId

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)

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
@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);
});

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

@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)
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