This file contains hidden or 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
| StringWriter sw = new StringWriter(); | |
| PrintWriter pw = new PrintWriter(sw); | |
| t.printStackTrace(pw); | |
| sw.toString(); |
This file contains hidden or 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 new index with ttl, the key must be date type and can not be a compound index. | |
| > db.teste_ttl_idx.ensureIndex({ttl: 1}, {expireAfterSeconds: 5}); | |
| - Insert new documents | |
| > db.teste_ttl_idx.insert({ttl: new Date()}); | |
| > db.teste_ttl_idx.insert({ttl: new Date()}); | |
| > db.teste_ttl_idx.insert({ttl: new Date()}); | |
| - You can do a find all to check if the elements were inserted and if they will be removed in the next 5 seconds after their creation. |
This file contains hidden or 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
| 1 - Make sure to set the Linux kernel overcommit memory setting to 1. Add vm.overcommit_memory = 1 to /etc/sysctl.conf and then reboot or run the command sysctl vm.overcommit_memory=1 for this to take effect immediately. | |
| 2 - Make sure to setup some swap in your system (we suggest as much as swap as memory). If Linux does not have swap and your Redis instance accidentally consumes too much memory, either Redis will crash for out of memory or the Linux kernel OOM killer will kill the Redis process. | |
| 3 - Connector Configs | |
| final int numClients = 150; | |
| final JedisPoolConfig config = new JedisPoolConfig(); | |
| // Tests whether connection is dead when connection retrieval method is called |
This file contains hidden or 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
| ## Default setup: http://pkg.jenkins-ci.org/debian/ | |
| ## Setup with oracle-jdk, mvn3, git, nginx and useful jenkins plugins | |
| Remove OpenJDK first if installed by this command: | |
| sudo apt-get purge openjdk* | |
| Then add the Webupd8 Team PPA repository and then reload the packages: | |
| sudo add-apt-repository ppa:webupd8team/java | |
| sudo apt-get update |
This file contains hidden or 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
| db.website_performance.aggregate( | |
| [ | |
| { $match : { 'domain' : { $in: ['xxx.com','porntube.com']} } }, | |
| { $group: { | |
| _id: '$domain', | |
| sum_impressions: { $sum: "$impressions" }, | |
| sum_bids: { $sum: "$bids" }, | |
| sum_clicks: {$sum: "$clicks"}, | |
| sum_leads: {$sum: "$leads"}, | |
| sum_actual_cost: {$sum: "$actual_cost"}, |
This file contains hidden or 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
| db.website_performance.aggregate( | |
| [ | |
| { | |
| $match : { 'domain' : { $in: []} } | |
| }, | |
| { | |
| $group: { | |
| _id: "$domain", | |
| sum_impressions: { $sum: "$impressions" }, | |
| sum_bids: { $sum: "$bids" } } |
This file contains hidden or 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
| SELECT cfr.DATE, cfr.USER_ID, cfr.CAMPAIGN_ID, SUM(cfr.SPENT_BUDGET) + IFNULL(cfpr.ACTUAL_COST,0) AS SPENT_BUDGET | |
| FROM CONSOLIDATE_FINANCIAL_REPORT cfr | |
| LEFT JOIN CONSOLIDATE_FINANCIAL_PARTNER_REPORT cfpr on cfpr.CAMPAIGN_ID = cfr.CAMPAIGN_ID and cfpr.DATE = cfr.DATE | |
| WHERE cfr.DATE = '2013-03-26 00:00:00' AND cfr.USER_ID = 766 | |
| GROUP BY 1,2,3 | |
| ORDER BY 1,2,3; |
This file contains hidden or 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
| public String normalize(String word) { | |
| if (word == null || word.trim().isEmpty()) | |
| return word; | |
| word = word.replaceAll("[ÂÀÁÄÃ]", "A"); | |
| word = word.replaceAll("[âãàáä]", "a"); | |
| word = word.replaceAll("[ÊÈÉË]", "E"); | |
| word = word.replaceAll("[êèéë]", "e"); | |
| word = word.replaceAll("ÎÍÌÏ", "I"); |
This file contains hidden or 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
| db.website_performance.aggregate( | |
| [ | |
| { | |
| $group: { | |
| _id: "$domain", | |
| sum_impressions: { | |
| $sum: "$impressions" | |
| }, | |
| sum_bids: { | |
| $sum: "$bids" |
This file contains hidden or 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 map_func = function() { | |
| var imps = this.impressions; | |
| var clicks = this.clicks; | |
| emit(this.domain, {'impressions': imps, 'clicks': clicks }); | |
| }; | |
| var reduce_func = function(key, values) { |