Skip to content

Instantly share code, notes, and snippets.

@siddartha
siddartha / _form.html.erb
Created November 27, 2012 15:19
Categorie
<%= simple_form_for(@category) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :name %>
<%= f.input :description %>
<%= f.input :parent_id %>
</div>
<div class="form-actions">
@siddartha
siddartha / ErreurDebug
Created November 27, 2012 15:44
Category
NoMethodError in Categories#index
Showing /home/mon_beau_path_vers_mon_app/web/annuaire/app/views/categories/index.html.erb where line #17 raised:
undefined method `parent' for #<Category:0x0000000454e6e8>
Extracted source (around line #17):
14: <tr>
15: <td><%= category.name %></td>
@siddartha
siddartha / show_and_write_thumbnail_functions.php
Last active September 23, 2019 16:18
Function to show and/or write thumbnails generated by Mshots from WP.org
<?php
/**
* Display thumbs generate by Wordpress' service Mshot and write
* locally the thumb after generation to have better loading web performance.
*
* Thx @jd_ma for help :)
*/
function show_and_write_thumbnail ($url, $width=200, $height=150) {
@siddartha
siddartha / optiJPG.sh
Created April 7, 2013 10:43
Script SHELL à placer à la racine du dossier d'images à optimiser.
#!/bin/sh
# optiJPG.sh: a sample shell script to launch JPG optimisation
# via: find ./ -type f -name '*.jpg' -exec ./optiJPG.sh {} \;
# TODO define usage function
for f; do
jpegtran -copy none -optimize -perfect -outfile $f $f
echo $f OK..
done
<?php
// http://clients1.google.com/complete/search?hl=fr&output=toolbar&q=gestion%20des%20logs
$q = $argv[1];
$url = "http://clients1.google.com/complete/search?hl=fr&output=toolbar&q=".urlencode($q);
/* gets the data from a URL */
function get_data($url) {
$ch = curl_init();
<?php
// http://clients1.google.com/complete/search?hl=fr&output=toolbar&q=gestion%20des%20logs
$query = urlencode($_GET['q']);
$uri = "http://clients1.google.com/complete/search?hl=fr&output=toolbar&q=".$query;
/* gets the data from a URL */
function get_data($url) {
$ch = curl_init();
# forms.py
from django import forms
from django.contrib.auth.models import User
class ConnexionForm(forms.Form):
username = forms.CharField(label="Nom d'utilisateur", max_length=30)
password = forms.CharField(label="Mot de passe", widget=forms.PasswordInput)
def ajout(request):
if request.method == "POST":
lien_form = LienForm(request.POST)
ancre_form = AncreForm(request.POST)
if lien_form.is_valid():
lien = Lien()
lien.date = lien_form.cleaned_data['date']
lien.url = lien_form.cleaned_data['url']
lien.page = lien_form.cleaned_data['page']
lien.typeLien = lien_form.cleaned_data['typeLien']
#!/usr/bin/env python
# -*- coding: utf-8 -*-
set1 = open('set1.txt','r')
set2 = open('set2.txt','r')
output = open('diff.txt','w')
eachhost1 = set1.read().splitlines()
#print eachhost1
eachhost2 = set2.read().splitlines()
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class Site(models.Model):
user = models.ForeignKey(User)
site = models.CharField(max_length=255)
def __unicode__(self):
return self.site