Skip to content

Instantly share code, notes, and snippets.

View ppeiris's full-sized avatar
🏋️‍♂️
Working on machine learning projects

Prabath Peiris ppeiris

🏋️‍♂️
Working on machine learning projects
View GitHub Profile
#0 /var/ftridp/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(640): Zend\ServiceManager\AbstractPluginManager->createFromInvokable('logincontroller...', 'Login\\Controlle...')
#1 /var/ftridp/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(597): Zend\ServiceManager\ServiceManager->doCreate('Login\\Controlle...', 'logincontroller...')
#2 /var/ftridp/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(530): Zend\ServiceManager\ServiceManager->create(Array)
#3 /var/ftridp/vendor/zendframework/zend-servicemanager/src/AbstractPluginManager.php(161): Zend\ServiceManager\ServiceManager->get('Login\\Controlle...', true)
#4 /var/ftridp/vendor/zendframework/zend-mvc/src/DispatchListener.php(94): Zend\ServiceManager\AbstractPluginManager->get('Login\\Controlle...')
#5 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#6 /var/ftridp/vendor/zendframework/zend-eventmanager/src/EventManager.php(490): call_user_func(Array, Object(Zend\Mvc\MvcEven
@ppeiris
ppeiris / useful_pandas_snippets.py
Created February 9, 2016 19:53 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
#List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
#Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
#Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(value_list)]
# Codeception Test Suite Configuration
# suite for acceptance tests.
# perform tests in browser using the Selenium-like tools.
# powered by Mink (http://mink.behat.org).
# (tip: that's what your customer will see).
# (tip: test your ajax and javascript by one of Mink drivers).
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
<?php
namespace OappAccessControl;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use Zend\Permissions\Acl\Acl as AccessControlList;
use Zend\Permissions\Acl\Role\GenericRole as Role;
use Zend\Permissions\Acl\Resource\GenericResource as Resource;
@ppeiris
ppeiris / blog_zf2index.php
Created November 13, 2013 17:48
updated zf2 index.php file to include the development.config.php modules
<?php
/**
* This makes our life easier when dealing with paths. Everything is relative
* to the application root now.
*/
chdir(dirname(__DIR__));
// Decline static file requests back to the PHP built-in webserver
if (php_sapi_name() === 'cli-server' && is_file(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) {
return false;
@ppeiris
ppeiris / blog_dev.conf.php
Created November 13, 2013 17:37
dev config file for zf2
<?php
/** Modules are in this file should only be activated in development env */
return array(
'modules' => array('ZfTools',
'ZF\Apigility\Admin'
),
);
<?php
class yourclass implements ServiceLocatorAwareInterface
{
protected $serviceLocator;
public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
{
$this->serviceLocator = $serviceLocator;
<?php
$account = $this->entityManager->getRepository('\Entity\Tables\tAccounts');
/** Find the account from tAccounts table */
$record = $account->findOneBy(array('userEmail' => $email));
if ($record) { // There is an active account for given email.
/** Generate a unique token */
$token = uniqid().uniqid();
/** create a new tAccountPasswordReset object and fill the info */
$newReset = new \Entity\Tables\tAccountPasswordReset();
<?php
/** Create an object of tAccounts */
$account = $this->entityManager->getRepository('\Entity\Tables\tAccounts');
/** Find a record */
$record = $account->findOneBy(array('userEmail' => $email));
if ($record) {
/** get all the records in the tAccountPasswordReset table that link via foreign key (accountId) */
$resetRecords = $record->getPasswordResets();
}
<?php
namespace Entity\Tables;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity
*/
class tAccountPasswordReset {