Skip to content

Instantly share code, notes, and snippets.

<?php
namespace SJevs\LibBundle;
use SJevs\LibBundle\Preg;
/*
* Grabber with Tor functionality
*
@author Sergej Jevsejev
@sergej-brazdeikis
sergej-brazdeikis / gist:2733188
Created May 20, 2012 01:48
PHP Regular expression outputs string or array
<?php
namespace SJevs\LibBundle;
/*
@author Sergej Jevsejev
@url http://sjevsejev.blogspot.com
*/
class Preg
@sergej-brazdeikis
sergej-brazdeikis / gist:2733550
Created May 20, 2012 02:17
vk.com video grabber
<?php
/**
* Vk.com video script
* - it searches for the movie
* - it gets embed code
*
* @author Sergej Jevsejev
* @url http://sjevsejev.blogspot.com
*/
@sergej-brazdeikis
sergej-brazdeikis / gist:2736092
Created May 20, 2012 02:46
vk.com video construct
<?php
function __construct($login, $password, $phoneLast4Digits)
{
$this->$phoneLast4Digits = $phoneLast4Digits;
$this->gb = new Grabber();
$data = $this->gb->post('http://login.vk.com/?act=login',
array(
'act' => 'login',
@sergej-brazdeikis
sergej-brazdeikis / gist:2736455
Created May 20, 2012 02:50
vk.com video search
<?php
/*
* Search video library by title
* @var $title string
* @return array List of videos
*/
public function search($title)
{
$html = $this->gb->get('http://vk.com/video?q='.htmlentities(urlencode($title)).'&section=search');
@sergej-brazdeikis
sergej-brazdeikis / gist:2736766
Created May 20, 2012 02:53
vk.com video play
<?php
/*
* Returns iframe code to play video
* Note: some videos are unable to embed because of particular video settings
*/
public function play($id1, $id2)
{
// getting hash
$hash = $this->gb->getPregOne('http://vk.com/video'.$id1.'_'.$id2, "/hash2[^0-9a-f]*([0-9a-f]*)/");
<?php
$vk = new vk($login, $password, $phoneLast4Digits);
// Get array of the movies
$videos = $vk->search('The Avatar');
// get iframe code for any movie from array
$html = $vk->play($videos[0]['id1'], $videos[0]['id2']);
<?php
include("Mobile_Detect.php");
$detect = new Mobile_Detect();
<?php
if ($detect->isIpad()) {
// code to run for the iPad platform
}
if ($detect->isIphone()) {
// code to run for the iPhone platform
}
if ($detect->isAndroid()) {
@sergej-brazdeikis
sergej-brazdeikis / jquery.html
Created June 10, 2012 16:47
JQuery from CDN
<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>