Skip to content

Instantly share code, notes, and snippets.

require 'posix-spawn'
require 'rbconfig'
##
# Wrapper for the Pygments command line tool, pygmentize.
#
# Pygments: http://pygments.org/
#
# Assumes pygmentize is in the path. If not, set its location
# with Albino.bin = '/path/to/pygmentize'
auto: true
destination: ./web
exclude: sass, config.rb
permalink: /:categories/:title.html
markdown: redcarpet2
redcarpet:
extensions: ["no_intra_emphasis", "fenced_code_blocks", "autolink", "strikethrough", "superscript", "with_toc_data"]

Configure a site for automatic deployment via Git

Go on the production serveur, then create two folders:

  • one for the git repo that will receive updates and deploy it automatically, for example: /home/user/git/livesite.git/
  • one that will be the live site folder and contain all the website files, say /home/user/www/livesite/

Go to the git repo folder

$ cd /home/user/git/livesite.git/

Fixing issues when installing Gitlab

$ sudo apt-get install -y postgresql-9.2 postgresql-server-dev-9.2

fails

Solution:

$ sudo add-apt-repository ppa:pitti/postgresql

$ sudo apt-get install -y postgresql-9.2 postgresql-server-dev-9.2

How to login a user programatically in Symfony2

First, insert use statement at the top of the file:

<?php

use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
<!-- Customize data-prototype attribute for embedded form collection in Symfony2 -->
<!-- form.html.twig -->
<div id="playerFields" data-prototype="{% filter escape %}{% include 'AcmeTeamBundle:Team:prototype.html.twig' with {'form': form.players.get('prototype')} %}{% endfilter %}"></div>
<!-- prototype.html.twig -->
<div>
<!-- Customize form element rendering as you wish like any other form element -->
{{ form_label(form.name) }}
$('SELECTOR').click(function(e) {
e.preventDefault();
if(confirm("MESSAGE TO DISPLAY TO USER") === true) {
window.location.href = $(this).attr('href');
} else {
// User Cancelled
}
});
<?php
$form = $this->get('form.factory')->createNamedBuilder('profil_candidat', 'form', null, array(
'constraints' => $collectionConstraint,
))
->add('name', 'text')
->add('email', 'email')
->getForm();
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain-name.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain-name.com$
RewriteCond %{REQUEST_URI} !folder/
RewriteRule (.*) /folder/$1 [L]
@tobalsan
tobalsan / wp-custom-widget.php
Last active August 29, 2015 14:04
WordPress: register custom widget
add_action( 'widgets_init', create_function( '', 'register_widget( "My_Widget_Recent_Posts" );' ) );