Skip to content

Instantly share code, notes, and snippets.

@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')?>">
<?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)];
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Istighfar</title>
<style type="text/css">
.cases{
overflow: visible;
}
.cases .case{
# -*- 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'))
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(\w+)\.php\?id=([0-9]+)$ page-router.php?name=$1&id=$2 [QSA,L]
</IfModule>
@hemache
hemache / filter.py
Last active December 10, 2015 07:18
#!/usr/bin/env python
from time import strftime, strptime, mktime
file_name = 'names.lst'
trash_file_name = 'old_names.lst'
filter_date = strftime('%d-%m-%Y') #'01-01-2012'
def timestamp(strtime, format = '%d-%m-%Y'):
return mktime(strptime(strtime, format))
@hemache
hemache / .htaccess
Created December 20, 2012 20:11
Codeigniter htaccess
Options -Indexes
Options +FollowSymLinks
# Set the default file for indexes
DirectoryIndex index.php
<IfModule mod_rewrite.c>
# mod_rewrite rules
RewriteEngine on
@hemache
hemache / gist:4259741
Created December 11, 2012 16:06
redirect after login
/* page.php?xxxx */
$next = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
session_start();
$_SESSION['next'] = $next;
printf('<a href="login.php">login</a>', $next);
/* login.php */
session_start();
$next = $_SESSION['next'];
/* ... */
@hemache
hemache / gist:4259698
Created December 11, 2012 16:04
redirect after login
/* page.php?xxxx */
$next = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
printf('<a href="login.php?next=%s">login</a>', $next);
/* login.php */
$next = $_GET['next'];
/* ... */
// حول المتسخدم الى الرابط الذي جاء منه
<form action="<?=$_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data">
<?
$num_files = 5;
while($num_files){
echo '<input type="file" name="file[]" /> <br>';
$num_files --;
}
?>
<input type="submit" name="upload" />