Skip to content

Instantly share code, notes, and snippets.

<?php
/*
* Converts CSV to JSON
* Example uses Google Spreadsheet CSV feed
* csvToArray function I think I found on php.net
*/
header('Content-type: application/json');
// Set your CSV feed
# Start the old vagrant
$ vagrant init centos-6.3
$ vagrant up
# You should see a message like:
# [default] The guest additions on this VM do not match the install version of
# VirtualBox! This may cause things such as forwarded ports, shared
# folders, and more to not work properly. If any of those things fail on
# this machine, please update the guest additions and repackage the
# box.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wcreatic</groupId>
<artifactId>firstSpringMvc</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>firstSpringMvc Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
@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>
<?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);
@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;
@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 / 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 / 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",
<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>