Skip to content

Instantly share code, notes, and snippets.

@hemache
hemache / hosted_example.txt
Created December 3, 2012 15:52 — forked from makevoid/hosted_example.txt
JQuery DOM HighLighter (it's a basic "Inspect element" simple implementation to mimic what webkit inspector and firebug do)
http://uploads.makevoid.com/jquery_dom_highlighter.html
<?=lang('album', 'album')?>
<select name="album_id">
<?php foreach($user_albums as $user_album): ?>
<option value="<?=$user_album->id?>"><?=$user_album->title?></option>
<?php endforeach ?>
// Error
// -----
Parse error: syntax error, unexpected T_STRING, expecting ']' in /home/localhost/www/application/cache/106a6c241b8797f52e1e77317b96a201.tpl on line 3
// Php: home.php
// -------------
$home = $this->template->load('home');
$home->assign('name', 'FOOBAR');
$home->assign('me', array('good'=>'LAKA'));
$home->render();
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
define('DS', DIRECTORY_SEPARATOR, TRUE);
class Template {
public $template_dir;
public $template_cache;
public $template_expiry;
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)
<?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
@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;
}
@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);
<?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: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);