Skip to content

Instantly share code, notes, and snippets.

CREATE TABLE `setfive_list_ip` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`ip` VARCHAR(15) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
mysql> SELECT COUNT(*) FROM setfive_list_ip;
+----------+
| count(*) |
mysql> EXPLAIN SELECT * FROM setfive_list_ip WHERE ip = "174.183.170.87";
+----+-------------+-----------------+------+---------------+------+---------+------+---------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-----------------+------+---------------+------+---------+------+---------+-------------+
| 1 | SIMPLE | setfive_list_ip | ALL | NULL | NULL | NULL | NULL | 7077562 | Using where |
+----+-------------+-----------------+------+---------------+------+---------+------+---------+-------------+
1 row in set (0.00 sec)
@adatta02
adatta02 / gist:9224006
Created February 26, 2014 05:27
Playing with phantom-cluster
var phantomCluster = require("./node_modules/phantom-cluster/index");
var cluster = require("cluster");
var engine;
engine = new phantomCluster.createQueued({
workers: 4,
workerIterations: 4,
phantomBasePort: 8888,
});
public function add
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /usr/share/php/symfony/util/sfToolkit.class.php on line 362
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /usr/share/php/symfony/util/sfToolkit.class.php on line 362
GroupsListColumnQuery(Doctrine_Query $query, $field, $values)
$query = $this->getEntityManager()
->getRepository("ALLoopBundle:User")
->createQueryBuilder('u')
->select('u','uc')
->leftJoin("u.userCourses", "uc")
->innerJoin("u.userCourses", "ux", "WITH", "ux.course = :course")
->andWhere("u.userType = 1")
->orderBy("u.lastName", "ASC")
->setParameter("course", $course);
@adatta02
adatta02 / gist:9245063
Created February 27, 2014 05:47
Take screenshots of a list of domains using PhantomJS and NodeJS
var Q = require("q");
var FS = require("fs");
var phantom = require("phantom");
var DomainScraper = function(){
this.domainList = [];
this.scrapeResults = [];
this.addResult = function(result){
phantom.create(function(ph) {
ph.createPage(function(page) {
page.open('http://www.mdscollections.com/cat_mds_accessories.cfm',
function(status) {
console.log('Opened site? %s', status);
another_funny(page, ph);
});
});
});
@adatta02
adatta02 / gist:9245203
Created February 27, 2014 06:05
Shell code for using PhantomJS-Node with Deferreds
var Q = require("q");
var phantom = require("phantom");
var DomainScraper = function(){
this.createPhantom = function(){
var df = Q.defer();
phantom.create(function(ph){
df.resolve(ph);
});
<div class="one rate-dot {{ rating >= 1 ? "rated" : "" }}"></div>
<div class="two rate-dot {{ rating >= 2 ? "rated" : "" }}"></div>
<div class="three rate-dot {{ rating >= 3 ? "rated" : "" }}"></div>
<div class="four rate-dot {{ rating >= 4 ? "rated" : "" }}"></div>
<div class="five rate-dot {{ rating >= 5 ? "rated" : "" }}"></div>
{% set rating = item.getAvgRating %}
{% if rating %}
<div class="mini">
{% include 'ALLoopBundle:User:renderRating.html.twig' %}
</div>
{% endif %}
#can become