Skip to content

Instantly share code, notes, and snippets.

@kabdessamad1
kabdessamad1 / mysql-docker.sh
Created October 29, 2018 18:00 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
<?php
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
class AppKernel extends Kernel
{
{{ form_start(form) }}
<div class="form-group">
{{form_label(form.name, "Username") }}
{{ form_widget(form.name, {'attr' : {'class':'form-control'}}) }}
</div>
{{ form_end(form) }}
@kabdessamad1
kabdessamad1 / countries.php
Created September 23, 2015 12:21 — forked from JeffreyWay/countries.php
Country Names + Codes
[
"United States" => "us",
"Afghanistan" => "af",
"Albania" => "al",
"Algeria" => "dz",
"American Samoa" => "as",
"Andorra" => "ad",
"Angola" => "ad",
"Anguilla" => "ai",
"Antarctica" => "aq",
@kabdessamad1
kabdessamad1 / config.yml
Last active August 29, 2015 14:26
enable twig text extension
// app/config/config.yml
...
services:
twig.extension.text:
class: Twig_Extensions_Extension_Text
tags:
- { name: twig.extension }
@kabdessamad1
kabdessamad1 / base.html.twig
Created August 3, 2015 18:26
install twitter Bootstrap and jQuery to Symfony2
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>{% block title %}Welcome!{% endblock %}</title>
{% block stylesheets %}
{% stylesheets filter='cssrewrite'
'%kernel.root_dir%/../vendor/twbs/bootstrap/dist/css/bootstrap.css'
'%kernel.root_dir%/../vendor/twbs/bootstrap/dist/css/bootstrap-theme.css'
'@WbttcBlogBundle/Resources/public/css/custom.css'
@kabdessamad1
kabdessamad1 / Service.php
Created July 16, 2015 19:22
Populate a php object from db using doctrine dbal and silex
<?php
namespace Webomattic\Entity;
class Service {
private $id;
private $service;
private $description;
private $icon;
<?php
try{
$dbh = new PDO('mysql:host=localhost;dbname=mydb','root','root');
$data = $dbh->query('SELECT * from users');
$users = $data->fetchAll(PDO::FETCH_ASSOC);
$fp = fopen('users.csv','w');
foreach($users as $line){
fputcsv($fp, $line);
<bean id="templateResolver"
class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".html" />
<property name="templateMode" value="HTML5" />
</bean>
<bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">
<property name="templateResolver" ref="templateResolver" />
</bean>
@kabdessamad1
kabdessamad1 / web.xml
Created March 9, 2015 10:23
spring initial web xml config
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<display-name>First spring mvc application</display-name>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>