Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf8 -*-
from django import forms
from cars import models
from django.contrib.humanize.templatetags.humanize import intcomma
# Insert an empty value which represent ANY choice
for attr in dir(models):
if attr.endswith('_CHOICES'):
CHOICES = list(getattr(models, attr))
CHOICES.insert(0, ('', 'Any'))
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Istighfar</title>
<style type="text/css">
.cases{
overflow: visible;
}
.cases .case{
<?php
function count_words($needed_word, $string)
{
$words = str_word_count($string, 1);
$words_count = array_count_values($words);
// Use multibyte string to lower
return $words_count[mb_strtolower($needed_word)];
}
@hemache
hemache / header.php
Last active December 16, 2015 14:19
<? if(cliprz::system(config)->get('language','direction') == 'rtl'): ?>
<link rel="stylesheet" type="text/css" href="<?=assets('bootstrap/css/bootstrap.rtl.css')?>" />
<link rel="stylesheet" type="text/css" href="<?=assets('bootstrap/css/bootstrap-responsive-rtl.css')?>">
<? else: ?>
<link rel="stylesheet" type="text/css" href="<?=assets('bootstrap/css/bootstrap.css')?>" />
<link rel="stylesheet" type="text/css" href="<?=assets('bootstrap/css/bootstrap-responsive.css')?>">
import itertools
lines = list()
lines.append(open('1.txt').readlines())
lines.append(open('2.txt').readlines())
combinations = list(itertools.product(*lines))
with open('result.txt', 'w') as result:
for combination in combinations:
#!/bin/bash
# Source: http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
# Install stuff #
#################
# Install development tools and some misc. necessary packages
yum -y groupinstall "Development tools"
yum -y install zlib-devel # gen'l reqs
#!/usr/bin/env python
#
# Extracts email addresses from one or more plain text files.
#
# Notes:
# - Does not save to file (pipe the output to a file if you want it saved).
# - Does not check for duplicates (which can easily be done in the terminal).
#
# (c) 2013 Dennis Ideler <ideler.dennis@gmail.com>
@hemache
hemache / ravha.c
Last active January 1, 2016 15:19
Gist for ravha !
#include <stdio.h>
#include <conio.h>
void main()
{
int i;
char ville[20];
int nbr_visi_tang, nbr_visi_tet, nbr_visi_aga, nbr_visi_tan;
int age;
int tot_tang, tot_aga, tot_tet, tot_tan, tot_gen;
<?php
require './vendor/autoload.php';
// Prepare app
$app = new \Slim\Slim(array(
'templates.path' => './templates',
));
<html>
<head></head>
<body>
<table border="1">
<tr>
<th>Colonne date</th>
<th>Autre colonne</th>
</tr>
<tr>
<td><span class="date"></span></td>