DB::enableQueryLog();
dd(DB::getQueryLog()); #output last executed queries
DB::table('users')->toSql() #show the generated sql statement
DB::table('users')->getQuery()->wheres #show wheres conditions
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
touch ~/aspell.personal.txt | |
vi ~/aspell.personal.txt # add words per line | |
aspell --lang=en create master /tmp/en-personal.pws < ~/aspell.personal.txt | |
cp /tmp/en-personal.pws /usr/lib/aspell | |
vim /usr/lib/aspell/en_US.multi # add the line: 'add en-personal.pws' |
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
//has to return object | |
module.exports = { | |
key: 'Hello' | |
} |
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
#!/bin/env sh | |
USER=ubuntu | |
SERVER=example.com | |
DESTINATION=/var/www/ics-feed | |
git archive -o latest.zip HEAD | |
scp latest.zip $USER@$SERVER:$DESTINATION | |
ssh $USER@$SERVER " \ | |
mkdir -vp $DESTINATION && cd $DESTINATION \ |
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
ab \ | |
-n 1000 \ | |
-c 20 \ | |
-s 30 \ | |
-p post-data.txt \ | |
-T 'application/x-www-form-urlencoded; charset=UTF-8' \ | |
-v 3 \ | |
-H "X-Requested-With: XMLHttpRequest" \ | |
-H "X-Ajax-Referer: http://example.com" \ | |
-H "Accept-Encoding: gzip, deflate" \ |
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
Model:: | |
/*Select*/ | |
select('col1','col2') | |
->select(array('col1','col2')) | |
->select(DB::raw('businesses.*, COUNT(reviews.id) as no_of_ratings, IFNULL(sum(reviews.score),0) as rating')) | |
->addSelect('col3','col4') | |
->distinct() // distinct select | |
/*From*/ |
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
/*Use Fiddler Proxy*/ | |
curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8888'); | |
/*Use Proxy*/ | |
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); | |
curl_setopt($ch, CURLOPT_PROXY, "IP:PORT"); | |
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "username:password"); |
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
/* | |
Stream / QueryStreams | |
---------------------------- | |
Ref: http://mongoosejs.com/docs/api.html#querystream_QueryStream | |
one chunk == one document | |
*/ | |
readable = Model.where('created').gte(twoWeeksAgo).stream(); |
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
var casper = require('casper').create({ | |
viewportSize: { | |
width: 1024, | |
height: 768 | |
}, | |
pageSettings: { | |
webSecurityEnabled: false | |
}, | |
exitOnError: false, | |
waitTimeout: 70000 |
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
/* | |
Creating Synchronous Readable Stream in NodeJS | |
-------------------------------------------------- | |
When data is pushed synchronously to internal buffer, you'll get the synchronous | |
behaviour of the stream. This would block the rest of the code from being executed in | |
the next event loop iteration. | |
In the example setImmediate should be called immediatley in next event loop iteration. | |
But since the stream is synchronously reading data, it can't execute other callbacks. |
OlderNewer