Skip to content

Instantly share code, notes, and snippets.

View lmammino's full-sized avatar
🦁
Roar!

Luciano Mammino lmammino

🦁
Roar!
View GitHub Profile
@stof
stof / UserManager.php
Created September 4, 2011 14:54
Logging in by email or username with FOSUserBundle
<?php
namespace Acme\UserBundle\Model;
use FOS\UserBundle\Entity\UserManager as BaseUserManager;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
class UserManager extends BaseUserManager
{
public function loadUserByUsername($username)
@guilleferrer
guilleferrer / Date Range Mongo Query
Created January 24, 2012 11:50
Query for a date range using Mongo Timestamps
db.Collection.find({
created_at : {
'$gte': new Timestamp(new Date(2012, 0, 21), 0),
'$lte': new Timestamp(new Date(2012, 0, 22), 0)
})
@leon
leon / TruncateHtmlExtension.php
Created June 2, 2012 11:25
Symfony 2 Twig Extension that truncates html and preserves tags
<?php
/**
Truncate Html string without stripping tags
register in Resources/config/services.yml with:
services:
truncatehtml.twig.extension:
class: Radley\TwigExtensionBundle\Extension\TruncateHtmlExtension
tags:
- { name: twig.extension }
// deparam
//
// Inverse of $.param()
//
// Taken from jquery-bbq by Ben Alman
// https://github.com/cowboy/jquery-bbq/blob/master/jquery.ba-bbq.js
var isArray = Array.isArray || function(obj) {
return Object.prototype.toString.call(obj) == '[object Array]';
};
@liuggio
liuggio / oneliner.sh
Created August 31, 2012 09:22
one liner PROUDLYGIDEA
# a simple user can execute a 'service php5-fpm reload'
# modify
userx ALL=(root) NOPASSWD: /usr/sbin/service php5-fpm reload, /usr/bin/setfacl
#to your /etc/sudoers be careful leave the last line empty
#apache2
userx ALL=(root) NOPASSWD: /usr/sbin/service apache2 restart, /usr/sbin/service apache2 start, /usr/sbin/service apache2 stop, /usr/bin/setfacl
#akc-grep
@sameronline
sameronline / get_image_info.php
Created November 23, 2012 15:19
php function that returns width/height/square space & file size of an image
function get_image_info($sURL) {
try {
$return = array();
$vData = "";
$timer = microtime(true);
$hSock = fopen($sURL, 'rb');
$length = 10240;
if ($hSock) {
while(!feof($hSock)) {
$vData = fread($hSock, $length);
@danvbe
danvbe / 1-Explanations.md
Last active November 14, 2024 02:13
A way to integrate FosUserBundle and HWIOAuthBundle

I have managed to install this… and make it work. I implemented it for Facebook and Google, but you can extend it. My solution it is mostly as described in #116, with a bit of more code presented. The key aspects that lack in the #116 presentation (IMO) are:

  • the registration as service of your custom FOSUBUserProvider (with the necessary parameters)
  • set the service for oauth_user_provider in the security.yml with your custom created service

Here are the steps:

  1. Routing. In routing.yml I have added all the routes for both bundles.
  2. Configuration. I have set the config.yml mostly as it is presented in the HWIOAuthBundle.
  3. Security. I have set the security.yml mostly as it is presented in the HWIOAuthBundle (though my routes are using /login pattern, not /connect). Also, the oauth_user_provider is set for my custom service.
@willurd
willurd / web-servers.md
Last active November 13, 2024 13:44
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@leoj3n
leoj3n / learn-gush.md
Created January 15, 2014 11:10
Using gush on the command-line.

Learning gush!

Create an issue

There needs to be an open issue before a PR can be made. This makes sense because you should always discuss the work you're about to do with team members before you go off and do it. It also gives someone else a chance to "take" the issue and create a PR for it if you're too busy, forget, or w/e.

I created this issue: https://github.com/cordoval/gush/issues/114

Take the issue, fix, and then create a PR