Skip to content

Instantly share code, notes, and snippets.

@alfchee
alfchee / Install-Docker-on-Linux-Mint.sh
Created February 18, 2017 00:51 — forked from sirkkalap/Install-Docker-on-Linux-Mint.sh
Install Docker on Linux Mint
##########################################
# To run:
# curl -sSL https://gist.githubusercontent.com/sirkkalap/e87cd580a47b180a7d32/raw/d9c9ebae4f5cf64eed4676e8aedac265b5a51bfa/Install-Docker-on-Linux-Mint.sh | bash -x
##########################################
# Check that HTTPS transport is available to APT
if [ ! -e /usr/lib/apt/methods/https ]; then
sudo apt-get update
sudo apt-get install -y apt-transport-https
fi
@alfchee
alfchee / 00.howto_install_phantomjs.md
Created November 9, 2016 21:49 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
@alfchee
alfchee / twitter.js
Created November 9, 2016 21:27 — forked from cjoudrey/twitter.js
Lazy-rendering in PhantomJS
// This example shows how to render pages that perform AJAX calls
// upon page load.
//
// Instead of waiting a fixed amount of time before doing the render,
// we are keeping track of every resource that is loaded.
//
// Once all resources are loaded, we wait a small amount of time
// (resourceWait) in case these resources load other resources.
//
// The page is rendered after a maximum amount of time (maxRenderTime)
@alfchee
alfchee / sort_li.js
Created October 26, 2016 22:30
Use jQuery to sort <li> elements that posses a data-index property
// selecting the ul and children
var $categories = this.$el.find('ul.sortable'),
$categoriesli = $categories.children('li');
// sorting the list
$categoriesli.sort(function(a,b){
var an = $(a).find('div.sort-arrows').data('index'),
bn = $(b).find('div.sort-arrows').data('index');
if(an > bn) {
@alfchee
alfchee / Draggable.js
Created March 22, 2016 06:48 — forked from Rob-ot/Draggable.js
Draggable and dropable views for backbone, uses html5 drag and drop api, requires jquery and underscore, not tested in IE yet
return View.extend({
initialize: function () {
this.el.attr("draggable", "true")
this.el.bind("dragstart", _.bind(this._dragStartEvent, this))
},
_dragStartEvent: function (e) {
var data
if (e.originalEvent) e = e.originalEvent
e.dataTransfer.effectAllowed = "copy" // default to copy
@alfchee
alfchee / CSSSlider.html
Created October 17, 2015 17:27
Demo of a Slider only with CSS3, nothing of JavaScript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Slider CSS</title>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if gte IE 9]>
<?php
class Crawler
{
protected $_url;
protected $_depth;
protected $_seen = array();
protected $_host;
protected $_sitemap;
protected $_curl;
protected $_limitUrls;
public function recursiveCall($url, $depth)
{
if(!$this->isValid($url,$depth)) {
return;
}
$this->_seen[$url] = true;
$request = new AsyncWebRequest($url);
if($request->start()) {
while($request->isRunning()) {
@alfchee
alfchee / ThreadingPHP
Created October 7, 2015 17:40
Chunks de código de intento de PHP asíncrono o con threadings para obtener contenido de un site
use GuzzleHttp\Client;
$request = new AsyncWebRequest($this->_url,$url);
if($request->start()) {
while($request->isRunning()) {
usleep(30);
}
if($request->join()) {
@alfchee
alfchee / topkeywords.js
Created October 6, 2015 21:31 — forked from elliotbonneville/topkeywords.js
Find top keywords associated with a Google search with this Node.js application.
var request = require("request"),
cheerio = require("cheerio"),
url = "https://www.google.com/search?q=data+mining",
corpus = {},
totalResults = 0,
resultsDownloaded = 0;
function callback () {
resultsDownloaded++;