This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getId(url) { | |
var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/; | |
var match = url.match(regExp); | |
if (match && match[2].length == 11) { | |
return match[2]; | |
} else { | |
return 'error'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("eeprom") | |
GPIO_PIN = 7 --interrupt pin | |
id=0 | |
device = 0x50 -- address of EEPROM | |
memadr=0x00 -- let's read from begining | |
sda, scl = 4,5 | |
i2c.setup(id, sda, scl, i2c.SLOW) | |
buffer = adc.read(0) | |
--string.sub (buffer, 1 , 40) | |
--string.sub (buffer, 4 , 11) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
class Api extends CI_Controller { | |
function __construct(){ | |
parent:: __construct(); | |
$this->output->set_header("Access-Control-Allow-Origin: * "); | |
$this->output->set_header("Access-Control-Expose-Headers: Access-Control-Allow-Origin"); | |
$this->output->set_header("HTTP/1.0 200 OK"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Options +FollowSymlinks | |
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule .* index.php/$0 [PT,L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function makeThumbnails($updir, $img, $id) | |
{ | |
$thumbnail_width = 134; | |
$thumbnail_height = 189; | |
$thumb_beforeword = "thumb"; | |
$arr_image_details = getimagesize("$updir" . $id . '_' . "$img"); // pass id to thumb name | |
$original_width = $arr_image_details[0]; | |
$original_height = $arr_image_details[1]; | |
if ($original_width > $original_height) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dir = new DirectoryIterator(dirname(__FILE__)); | |
$count=0; | |
foreach ($dir as $fileinfo) { | |
if (!$fileinfo->isDot()) { | |
$output= shell_exec('convert -resize 50% '.$fileinfo->getFilename().' '.$count.'.jpg'); | |
} | |
$count++; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* QR Code + Logo Generator | |
* | |
* http://labs.nticompassinc.com | |
*/ | |
$data = isset($_GET['data']) ? $_GET['data'] : 'http://labs.nticompassinc.com'; | |
$size = isset($_GET['size']) ? $_GET['size'] : '200x200'; | |
$logo = isset($_GET['logo']) ? $_GET['logo'] : FALSE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_POST, true); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, array('file' => '@/path/to/file.txt')); | |
curl_setopt($ch, CURLOPT_URL, 'http://server2/upload.php'); | |
curl_exec($ch); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MoonPhase { | |
private $timestamp; | |
private $phase; | |
private $illum; | |
private $age; | |
private $dist; | |
private $angdia; | |
private $sundist; | |
private $sunangdia; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static double EARTH_RADIUS = 6378100;// radius of earth in meters | |
public static double gpsdistance (double lat1, double long1, double lat2, double long2) | |
{ | |
//in meters :D | |
double degToRad= Math.PI / 180.0; | |
double phi1 = lat1 * degToRad; | |
double phi2 = lat2 * degToRad; | |
double lam1 = long1 * degToRad; | |
double lam2 = long2 * degToRad; |
NewerOlder