Skip to content

Instantly share code, notes, and snippets.

View evancauwenberg's full-sized avatar

Evert Van Cauwenberg evancauwenberg

View GitHub Profile
@jakzal
jakzal / KernelAwareTest.php
Last active June 27, 2024 16:20
KernelAwareTest
<?php
require_once dirname(__DIR__).'/../../../../app/AppKernel.php';
/**
* Test case class helpful with Entity tests requiring the database interaction.
* For regular entity tests it's better to extend standard \PHPUnit_Framework_TestCase instead.
*/
abstract class KernelAwareTest extends \PHPUnit_Framework_TestCase
{
@peterbraden
peterbraden / gist:1644678
Created January 20, 2012 02:55
Face Detection in Node.JS
var cv = require('opencv')
var im = new cv.Image("./examples/test.jpg")
, face_cascade = new cv.CascadeClassifier("./examples/haarcascade_frontalface_alt.xml")
var faces = face_cascade.detectMultiScale(im, function(err, faces){
for (var i=0;i<faces.length; i++){
var x = faces[i]
im.ellipse(x.x + x.width/2, x.y + x.height/2, x.width/2, x.height/2);
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Responsive Design Testing</title>
<style>
body { margin: 20px; font-family: sans-serif; overflow-x: scroll; }
.wrapper { width: 6000px; }
.frame { float: left; }
h2 { margin: 0 0 5px 0; }
@kostajh
kostajh / db_update.sh
Created February 28, 2012 21:06
Rebuild script for Drupal Install Profile
# This script facilitates obtaining the latest DB data from the production
# Drupal 5 site.
# The script gets an ordered dump of the D5 database, and commits it to the
# git@git.designhammer.net:mysite_d5.git repository master branch.
# We make use of the rebuild.config file, so please make sure that your
# settings are correct there!
# We also assume that your drush aliases are setup correctly for
# @mysite.dev and @mysite_d5.prod. Please check mysite.aliases.drushrc.example,
# make sure your @mysite.dev alias is set up correctly, rename the file
# to mysite.aliases.drushrc.php and move it into your ~/.drush directory.
@ToulBoy
ToulBoy / "parent child" data
Created February 29, 2012 15:12
Elasticsearch 0.18.6 : My example of "parent child"
curl -s -XPOST localhost:9200/_bulk?pretty=true --data-binary '
{ "index" : { "_index" : "parent_child", "_type" : "store", "_id" : "store1" } }
{ "name" : "auchan", "owner" : "chris" }
{ "index" : { "_index" : "parent_child", "_type" : "department", "_id" : "department1", "parent" : "store1" } }
{ "name" : "toys", "numberOfProducts" : 150 }
{ "index" : { "_index" : "parent_child", "_type" : "product", "_id" : "product1", "parent" : "department1", "routing" : "store1" } }
{ "name" : "gun", "trademark" : "tiger", "price" : 9, "store_id" : "store1" }
'
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active July 27, 2024 16:50
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@darklow
darklow / es_nested_facets_filter.sh
Last active December 31, 2015 07:59
Nested facets filtering by parent in ElasticSearch
#!/bin/bash
# ========================================
# Nested facets filtering by parent in ElasticSearch
# --------------------------------------------------
# I need to get facets of departments for specific person for one movie genre:
# facets for credit.department where genre=comedy, credits.person_id=1
# I am using include_in_parent:true mapping to be able to facet_filter by parent genre
# ========================================
curl -X DELETE localhost:9200/movies
@darklow
darklow / es_aggs_nested.sh
Last active June 19, 2017 06:31
New aggregation framework - filtering by nested object fields
#!/bin/bash
# ========================================
curl -X DELETE localhost:9200/movies
curl -X PUT localhost:9200/movies -d '
{
"mappings": {
"movie": {
"properties": {
"name": { "type": "string" },
@Stoffo
Stoffo / remove_documents_mongodb.js
Created October 29, 2015 12:29
Remove Documents older than x days in MongoDB
var date = new Date();
var daysToDeletion = 120;
var deletionDate = new Date(date.setDate(date.getDate() - daysToDeletion));
printjson(deletionDate);
var db = db.getSiblingDB('db')
db.getMongo().setSlaveOk();
printjson(db.messages.find({insertDate : {$lt : deletionDate}}).count());
@jaytaph
jaytaph / composer.json
Created January 15, 2016 09:30
Using the Symfony security component as standalone
{
"name": "jaytaph/security-example",
"require": {
"symfony/security-core": "~2.8"
},
"authors": [
{
"name": "Joshua Thijssen",
"email": "jthijssen@noxlogic.nl"
}