Skip to content

Instantly share code, notes, and snippets.

@hemache
hemache / gist:3241511
Created August 2, 2012 22:40
linkParser
var patt_link = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
var link_anchor = '<a href="$1" target="_blank">$1</a>';
var patt_youtube_match = http://(?:www\.)?youtu(?:be\.com/watch\?v=|\.be/)(\w*)(&(amp;)?[\w\?=]*)?;
var patt_youtube_replace = /https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com\S*[^\w\-\s])([\w\-]{11})(?=[^\w\-]|$)(?![?=&+%\w]*(?:['"][^<>]*>|<\/a>))[?=&+%\w-]*/ig;
var youtube_iframe = '<iframe width="560" height="315" src="http://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>';
function linkText(text)
/* Arabic Specification */
/* New line add ! */
@import url(http://fonts.googleapis.com/earlyaccess/droidarabickufi.css);
.btn {
font-family: 'Droid Arabic Kufi';
}
html, body {
background-color: #eee;
@hemache
hemache / README.markdown
Created September 20, 2012 23:29
hello world

hello

boo

@hemache
hemache / gist:3760628
Created September 21, 2012 09:39
counttimerdown
<?php
mysql_query('INSERT INTO mytable (counttimer)
VALUES ("01:11:11")');
$res = mysql_query('SELECT * FROM mytable LIMIT 1');
$row = mysql_fetch_row($res);
@hemache
hemache / gist:3760659
Created September 21, 2012 09:46
counttimerdown no sleep
<?php
mysql_query('INSERT INTO mytable (counttimer)
VALUES ("01:11:11")');
$res = mysql_query('SELECT * FROM mytable LIMIT 1');
$row = mysql_fetch_row($res);
<?php
$responseIDs = array(
"<form action='".$_SERVER['PHP_SELF']."' method='post' style='float: left;'>
الاسم : <input name='TxtLogin' type='text' maxlength='19' style='width: 90px;'/>
الكلمة السرية : <input name='TxtPassword' type='password' maxlength='19' style='width: 90px;'/>
<input name='BtnLogin' type='submit' value='دخول'/>
</form>",
"<form action='".$_SERVER['PHP_SELF']."' method='post' style='float: left;'>
الاسم : <label>".$_SESSION['Login']."</label>
@hemache
hemache / gist:3982480
Created October 30, 2012 19:37
php image display from database
...
if (!$result) {
print 'Error: '. mysql_error();
exit;
}
else
{
$row = mysql_fetch_row($result);
@hemache
hemache / gist:3987128
Created October 31, 2012 13:49
php database image
<?php
function get_image()
{
$query = "SELECT Image FROM Mini_Article WHERE id= 4";
$result = mysql_query($query) or exit("mysql error");
$row = mysql_fetch_row($result);
$image_data = $row[0]; // Image col
return $image_data;
}
<?php
require_once('libs/curl/curl.php'); // https://github.com/shuber/curl
class Youtube extends Curl
{
public $params = array(
'key' => 'AIzaSyD2g6U5OzaLLvzEBBacZBhfaBIKeoZnKFM', // API Key
'maxResults' => 50, // Max items in result set
'part' => 'snippet' // https://developers.google.com/youtube/v3/getting-started#part
from django.shortcuts import render_to_response
# - - -
# views.py
# - - -
def search(request):
if 'q' in request.GET:
query = request.GET['q']
results = Adv.objects.filter(title__icontains=query, city__slug__icontains=query)