Skip to content

Instantly share code, notes, and snippets.

@pingyen
pingyen / pageList.html
Last active Aug 29, 2015
Page List Display Logic
View pageList.html
<script>
for(var page = 1; page <= 20; ++page) {
for(var pageNum = 1; pageNum <= 20; ++pageNum) {
if (page <= pageNum) {
console.log(getPageDetail(page, pageNum));
}
}
}
@pingyen
pingyen / fetchXuiteVlogs.php
Created Mar 17, 2015
Xuite Vlog Downloader
View fetchXuiteVlogs.php
<?php
$user = 'demo';
$videos = array();
for ($i = 1; $i <= 3; ++$i) {
foreach (array_slice(explode('<div class="media_thumb">', file_get_contents('http://vlog.xuite.net/' . $user . '*' . $i)), 1) as $token) {
$hq = strpos($token, '<div class="media_hq">') !== false;
$token = substr($token, strpos($token, '<a href="/play/') + 15);
View googleCrawler.php
<?php
$q = 'demo';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.google.com.tw/search?q=' . rawurlencode($q) . '&tbm=nws&tbs=qdr:d');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.91 Safari/537.36');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$html = curl_exec($ch);
@pingyen
pingyen / getBoxFileDetails.js
Created Mar 17, 2015
Getting Box File Details
View getBoxFileDetails.js
var folderID = '1234567890',
pageNum = 100;
var jsons = [],
files = [];
for (var i = 0; i < pageNum; ++i) {
jsons.push($.getJSON('https://app.box.com/index.php?rm=box_item_list&q[sort]=name&q[direction]=DESC&q[id]=d_' + folderID + '&q[page_num]=' + i + '&q[page_size]=20&q[theme_id]=1&q[collection_id]=0'));
}
View pttCrawler.php
<?php
require('phpQuery/phpQuery.php');
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, 'facebookexternalhit/1.1 (+https://www.facebook.com/externalhit_uatext.php)');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$articles = array();
@pingyen
pingyen / fetchXuitePhotos.php
Created Mar 17, 2015
Xuite Photo Downloader
View fetchXuitePhotos.php
<?php
$user = 'demo';
$html = '';
for ($i = 1; $i <= 100; ++$i) {
$html .= file_get_contents("http://photo.xuite.net/$user*$i");
}
$tokens = array_slice(explode('<p class="album_info_title">', $html), 1);
@pingyen
pingyen / apple-touch-icon.html
Created Mar 18, 2015
HTML to Image Example
View apple-touch-icon.html
<style>
div {
background-color: #005e81;
color: #FFF;
font-weight: bold;
font-size: 240px;
font-family: sans-serif;
width: 540px;
height: 528px;
padding-top: 12px;
@pingyen
pingyen / fbUserDump.php
Last active Aug 29, 2015
Download Facebook User Feed
View fbUserDump.php
<?php
$access_token = isset($argv[1]) ? $argv[1] : 'abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456';
$user_id = 'me';
/* feed */
$until = time();
$since = intval(substr(array_values(array_filter(scandir(__DIR__ . '/feed/', true), function($val) { return substr($val, -5) === '.json'; }))[0], 0, -5));
@pingyen
pingyen / fbGroupDump.php
Last active Aug 29, 2015
Download Facebook Group Feed, Memebers, & About
View fbGroupDump.php
<?php
ini_set('date.timezone', 'Asia/Taipei');
$access_token = isset($argv[1]) ? $argv[1] : 'abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456';
$group_id = 123456789012345;
/* feed */
@pingyen
pingyen / emscripten.txt
Created Jun 9, 2015
Emscripten Installation Guide
View emscripten.txt
$ sudo apt-get install python-software-properties
$ sudo apt-add-repository ppa:chris-lea/node.js
$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$ sudo apt-get update
$ sudo apt-get install nodejs default-jre
$ sudo apt-get install gcc-4.8 g++-4.8
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 20
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 20
$ wget http://www.cmake.org/files/v3.2/cmake-3.2.3-Linux-x86_64.tar.gz
$ tar zxvf cmake-3.2.3-Linux-x86_64.tar.gz
You can’t perform that action at this time.