Skip to content

Instantly share code, notes, and snippets.

View dlsniper's full-sized avatar

Florin Pățan dlsniper

View GitHub Profile
@dlsniper
dlsniper / example_parameters.go
Created February 11, 2015 21:36
Example on how to get URL parameters
package main
import (
"fmt"
"net/http"
"github.com/gorilla/mux"
)
func demo(w http.ResponseWriter, r *http.Request) {
@dlsniper
dlsniper / modifiedLog.java
Last active August 29, 2015 14:26
Modified Android Logging sample
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@dlsniper
dlsniper / genpwd.sh
Last active September 1, 2015 20:30
Generate password with bash
#!/usr/bin/env bash
# This generates a password
# The MIT License (MIT)
#
# Copyright (c) 2015 Florin Patan
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@dlsniper
dlsniper / sad2.php
Last active September 21, 2015 12:14
Inno solution for sadness
<?php
class human {
public function stop() {
print("https://youtu.be/DgvePeDIt3Y");
}
}
function sad() {
$return = isset($GLOBALS["sad_called"]) && $GLOBALS["sad_called"] === true ? new human() : true;
@dlsniper
dlsniper / appDevDebugProjectContainer.php
Created March 8, 2012 21:46
Configuration caching issue
/**
* Gets the 'doctrine.orm.default_entity_manager' service.
*
* This service is shared.
* This method always returns the same instance of the service.
*
* @return Doctrine\ORM\EntityManager A Doctrine\ORM\EntityManager instance.
*/
protected function getDoctrine_Orm_DefaultEntityManagerService()
@dlsniper
dlsniper / config.yml
Created March 18, 2012 21:15
Sample Doctrine2 cache in Symfony2
# Doctrine Configuration
doctrine:
dbal:
default_connection: connection1
connections:
connection1:
dbname: database1
connection2:
dbname: database2
connection3:
@dlsniper
dlsniper / benchmark.php
Created January 13, 2013 20:49
isset, array_key_exists and isset || array_key_exists speed test
<?php
$demo = array(
'kernel.root_dir' => '/var/www/personal/symfony/app',
'kernel.environment' => 'prod',
'kernel.debug' => false,
'kernel.name' => 'app',
'kernel.cache_dir' => '/var/www/personal/symfony/app/cache/prod',
'kernel.logs_dir' => '/var/www/personal/symfony/app/logs',
'kernel.bundles' => array(

Awesome PHP Libraries

A list of amazingly awesome PHP libraries that you should consider using (and some other shiny extras).

@dlsniper
dlsniper / README.md
Last active December 12, 2015 03:28
Simple benchmark for Symfony2

You should download each of the three versions of Symfony2 in /var/www/benchmark/sf2<X> where <X> is the minor version. Then

chmod +x benchmark.sh
sudo ./benchmark.sh
@dlsniper
dlsniper / embed.html.twig
Created February 6, 2013 21:35
Translation update demo Use AcmeDemoBundle Put embed.html.twig in Acme/DemoBundle/Resources/views/ Change Acme/DemoBundle/Resources/views/Welcome/index.html.twig accordingly Output is output.yml
{% block msg %}
<p>Congratulations! You have successfully installed a new Symfony application.</p>
{{ 'embed'|trans }}
{% endblock %}