Skip to content

Instantly share code, notes, and snippets.

View delineas's full-sized avatar
🚀
Launching...

Daniel Primo delineas

🚀
Launching...
View GitHub Profile
### Keybase proof
I hereby claim:
* I am delineas on github.
* I am delineas (https://keybase.io/delineas) on keybase.
* I have a public key whose fingerprint is DDA9 FC8B E52C 5412 5E52 C256 BA12 F30A 4647 1FF5
To claim this, I am signing this object:
<?php
namespace Acme;
/**
* Dummy class
*
*/
class Parser
{
@delineas
delineas / controller.php
Created June 11, 2015 00:57
Silex CSV generator
$app->match('/export', function() use($app) {
$records = $app['db']->fetchAll("SELECT * FROM formdata");
$file = "/tmp/formdata.csv";
$output = fopen($file, "w");
fputcsv($output, array('name','surname','province'), ',');
foreach ($records as $row)
fputcsv($output, $row, ',');
@delineas
delineas / template-full-width.php
Created October 13, 2015 11:19
Wordpress Select dropdown filter by month
<?php
// /wp-content/themes/Karma/template-full-width.php
// Below line #41 <main role="main" id="content" class="content_full_width">
<div class="select-archive-dropdown" style=“text-align: right;margin-bottom: 15px;”><select name="archive-dropdown" onChange='document.location.href=this.options[this.selectedIndex].value;'>
<option value=""><?php echo attribute_escape(__('Select Month')); ?></option>
<?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?> </select>
</div>
@delineas
delineas / mamp.md
Last active November 3, 2015 19:22 — forked from jfloff/mamp.md
How to get MAMP to work with SSL ... Yes really.

First of all you need to be able to run MAMP in port 80. This is a "heat check" if you don't have any process jamming http ports. You can check it like this:

sudo lsof | grep LISTEN

If you do happen to have any process with something like this *:http (LISTEN), you are in trouble. Before with adventure check if it isn't MAMP itself (yeah, you should close that beforehand)

ps <pid of that process>

If you don't see MAMP, you are in good hands, I have just the thing for you:

@delineas
delineas / command-line-sips.bash
Created November 4, 2015 00:02
Resize JPG images with sips command line Mac OS X
find /path/to/images -type f -name '*.jpg' -exec sips --resampleHeightWidthMax 800 --setProperty formatOptions 50 *.jpg {} \;
@delineas
delineas / UserMigration.php
Created November 9, 2015 20:50
OroCRM example for user migration
<?php
namespace Ecowala\UserCRMBundle\Migrations\Schema\v1_1;
use Doctrine\DBAL\Schema\Schema;
use Oro\Bundle\EntityExtendBundle\EntityConfig\ExtendScope;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;
class UserMigration implements Migration
@delineas
delineas / settings.local.php
Created December 15, 2015 12:28
Drupal git branch different database
<?php
$databases = array (
'default' =>
array (
'default' =>
array (
'driver' => 'mysql',
'username' => 'root',
'password' => 'root',
'port' => '',
@delineas
delineas / eval_code.php
Created December 21, 2015 13:34
Drupal 7 Panels Visibility Rule: Body Content Counts More 1000 Chars
<?php
// Insert in input box without <?php tags
if(isset($contexts['argument_entity_id:node_1']->data->body['und'][0]['value'])){
if(strlen(strip_tags($contexts['argument_entity_id:node_1']->data->body['und'][0]['value'])) > 1000 ) {
return TRUE;
}
else {
return FALSE;
}
}
@delineas
delineas / README.md
Created January 5, 2016 08:26 — forked from tjamps/README.md
Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

The API we are creating in this gist will follow these rules :

  • The API only returns JSON responses
  • All API routes require authentication
  • Authentication is handled via OAuth2 with password Grant Type only (no need for Authorization pages and such).
  • API versioning is managed via a subdomain (e.g. v1.api.example.com)

The API will be written in PHP with the Symfony 2 framework. The following SF2 bundles are used :