Skip to content

Instantly share code, notes, and snippets.

View ar2rsawseen's full-sized avatar
🏠
Working from home

Arturs Sosins ar2rsawseen

🏠
Working from home
View GitHub Profile
@ar2rsawseen
ar2rsawseen / getSources.js
Created September 14, 2015 07:28
Get sources from Countly DB
var stores = {};
db.stores.find({meta:{$exists:true}}).forEach(function(doc){
if(doc && doc.meta && doc.meta.stores){
for(var i = 0; i < doc.meta.stores.length; i++){
if(!stores[doc.meta.stores[i]])
stores[doc.meta.stores[i]] = 1;
else
stores[doc.meta.stores[i]]++;
}
@ar2rsawseen
ar2rsawseen / generateRequests.js
Created September 14, 2015 07:29
Generate requests for Countly
var request = require('request');
function makeRequest(cnt){
var options = {
uri: 'http://localhost/i?app_key=ccab3e6e1b5ca7b42fc2194b57358b115edb45fc&device_id='+Math.random()+'&begin_session=1&events=[{%22key%22:%22click%22,%22count%22:1,%22segmentation%22:{%22message%22:%22a%22}},{%22key%22:%22go%22,%22count%22:1,%22segmentation%22:{%22message%22:%22b%22}},{%22key%22:%22do%22,%22count%22:1,%22segmentation%22:{%22message%22:%22c%22}}]',
method: 'GET'
};
request(options, function (error, response, body) {
if(!error){
try{
@ar2rsawseen
ar2rsawseen / expireData.js
Created September 14, 2015 07:30
Expire old data using TTL indexes
//run on mongodb server as
//mongo < expireData.js
var COUNTLY_DRILL = 'countly_drill',
COUNTLY = 'countly',
EXPIRE_AFTER = 31536000,
INDEX_NAME = "cd_1";
var PROCESS = [
/^drill_events\.*/,
@ar2rsawseen
ar2rsawseen / default
Last active February 3, 2016 13:37
Nginx https configuration
server {
listen 80;
server_name localhost;
access_log off;
rewrite ^ https://yourdomain.com$request_uri? permanent;
}
server {
listen 443;
server_name localhost;
@ar2rsawseen
ar2rsawseen / sharp-preinstall.sh
Created November 9, 2016 08:09
Old preinstall script for sharp, just in case
#!/bin/sh
# Use of this script is deprecated
echo
echo "WARNING: THIS SCRIPT WILL STOP WORKING AT THE END OF 2016"
echo
echo "WARNING: THIS SCRIPT IS NO LONGER REQUIRED ON MOST 64-BIT LINUX SYSTEMS WHEN USING SHARP V0.12.0+"
echo
echo "See http://sharp.dimens.io/page/install#linux"
@ar2rsawseen
ar2rsawseen / deleteEventSegmentKeys.js
Last active March 13, 2019 18:44
To delete or rename segment keys in Countly
//place script in countly root folder
//Use this script to delete or update segment Keys.
var pluginManager = require('./plugins/pluginManager.js'),
crypto = require('crypto'),
Promise = require("bluebird"),
countlyDb = pluginManager.dbConnection(),
countly_drill = pluginManager.dbConnection("countly_drill");
@ar2rsawseen
ar2rsawseen / deleteEventSegmentValues.js
Created March 13, 2019 18:46
To delete or rename segment values in Countly
//place script in countly root folder (if anywhere else fix path to pluginManager and common)
//Use this script to delete or update segment Values.
var pluginManager = require('./plugins/pluginManager.js'),
crypto = require('crypto'),
async = require('async'),
Promise = require("bluebird"),
common = require('./api/utils/common.js'),
countlyDb = pluginManager.dbConnection(),
countly_drill = pluginManager.dbConnection("countly_drill");