Skip to content

Instantly share code, notes, and snippets.

View lamprosg's full-sized avatar

Lampros Giampouras lamprosg

  • Athens, Greece
View GitHub Profile
@lamprosg
lamprosg / horizontal.html
Created April 21, 2012 19:10
CSS Horizontal Menu
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Horizontal drop menu</title>
<style type="text/css">
.menu {
padding: 0;
@lamprosg
lamprosg / demo_workers.js
Created April 22, 2012 09:43
HTML5 Web Workers example
var i=0;
function timedCount()
{
i=i+1;
postMessage(i); //posts a message back to the HTML page.
setTimeout("timedCount()",500);
}
timedCount();
@lamprosg
lamprosg / address.xml
Created April 24, 2012 06:45
PHP simplexml
<?xml version="1.0"?>
<users>
<user>
<firstname>John</firstname>
<surname>Brady</surname>
<address>1 Bunch St</address>
<city>Downtown</city>
<country>America</country>
<contact>
<phone type="mobile">4444 4444</phone>
@lamprosg
lamprosg / latest_tweet.html
Created July 18, 2012 10:54
Latest Tweet using jQuery
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function ()
{
$.getJSON("http://twitter.com/statuses/user_timeline/USERNAME.json?callback=?", function(data) {
$(".show_tweet").html(data[0].text);
});
});
</script>
@lamprosg
lamprosg / get.php
Created July 18, 2012 20:50
LIST ALL FILES IN A DIRECTORY
//path to directory to scan
$directory = "../images/team/harry/";
//get all image files with a .jpg extension.
$images = glob($directory . "*.jpg");
//print each file name
foreach($images as $image)
{
echo $image;
@lamprosg
lamprosg / post-to-twitter.php
Created July 19, 2012 09:25
Simple post message to twitter with PHP
<?php
$url = 'http://twitter.com/statuses/update.xml';
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, "$url");
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message");
curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
@lamprosg
lamprosg / main.php
Created July 22, 2012 21:05
Unzip a Zip File in PHP
//Use the code as following:
<?php
include 'unzip.php';
if(unzip('zipedfiles/test.zip','unziped/myNewZip'))
echo 'Success!';
else
echo 'Error';
?>
@lamprosg
lamprosg / main.php
Created July 22, 2012 21:11
Resize image on the fly in PHP
<?php
//How to use it
//Just call timthumb.php with appropriate arguments, For example:
<img src="/script/timthumb.php?src=/some/path/myimage.png&w=100&h=80" alt="resized image" />
/* http://viralpatel.net/blogs/resize-image-dynamically-php/ */
?>
@lamprosg
lamprosg / cycle.js
Created August 6, 2012 15:13
JQuery Cycle Plugin – Basic Example
$('#slide1').cycle({
fx: 'scrollDown',
speed: 300,
timeout: 2000
});
/*Effect you can Choose and apply
* blindX
* blindY
@lamprosg
lamprosg / distance.php
Created August 6, 2012 15:16
Distance between 2 points, with lat and lng coordinates
<?php function distance($lat1, $lon1, $lat2, $lon2) {
$pi80 = M_PI / 180;
$lat1 *= $pi80;
$lon1 *= $pi80;
$lat2 *= $pi80;
$lon2 *= $pi80;
$r = 6372.797; // mean radius of Earth in km
$dlat = $lat2 - $lat1;