Skip to content

Instantly share code, notes, and snippets.

View Harshakvarma's full-sized avatar
🎯
Focusing

Harshavardhan Kalidindi Harshakvarma

🎯
Focusing
View GitHub Profile
@Harshakvarma
Harshakvarma / testing.py
Created June 20, 2018 05:14
Python sample loop to test background running
import os
import time
import logging
from datetime import datetime
#logs
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
# create a file handler
@Harshakvarma
Harshakvarma / testing.py
Created June 20, 2018 05:13
Python sample loop
import os
import time
import logging
from datetime import datetime
#logs
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
# create a file handler
@Harshakvarma
Harshakvarma / MixPanelExport.py
Last active June 19, 2018 06:42 — forked from trentniemeyer/MixPanelExport.py
MixPanel Export API in Python 3
I got it working
```python
import base64
import urllib.request
import ssl
try:
import json
except ImportError:
import simplejson as json
@Harshakvarma
Harshakvarma / README.md
Created May 8, 2018 19:29 — forked from twolfson/README.md
Quick and dirty database dump to S3 via Node.js

We are implementing database dumping which is straightforward but can be tedious to setup. Here's our setup:

  1. Create AWS user for db backups (e.g. db-backups-{{app}})
    • Save credentials in a secure location
    • If adding db scrubbing, use a separate user (e.g db-scrubs-{{app}})
  2. Create bucket for S3 access logging (e.g. s3-access-log-{{app}})
  3. Create consistently named bucket for db dumps (e.g. db-backups-{{app}})
    • Enable logging to s3-access-log-{{app}} with prefix of db-backups-{{app}}
  4. Add IAM policy for bucket access
  • Select user -> Choose "Add inline policy"
@Harshakvarma
Harshakvarma / test.js
Created April 16, 2018 19:26
Async/await simple example
const items = [1, 2, 3, 4, 5, 6];
// do something that takes time with the item
function f1(item) {
console.log('[f1] received', item);
return new Promise(function(resolve, reject) {
setTimeout(resolve, 1000);
});
}
@Harshakvarma
Harshakvarma / geo.js
Created April 13, 2018 19:56 — forked from mkhatib/geo.js
A Javascript utility function to generate number of random Geolocations around a center location and in a defined radius.
/**
* Generates number of random geolocation points given a center and a radius.
* @param {Object} center A JS object with lat and lng attributes.
* @param {number} radius Radius in meters.
* @param {number} count Number of points to generate.
* @return {array} Array of Objects with lat and lng attributes.
*/
function generateRandomPoints(center, radius, count) {
var points = [];
for (var i=0; i<count; i++) {
router.post('/addUserSocialProfile', function (req, res) {
var profileData = req.body.social;
var data = {};var output = [];var changed = 0;var now = new Date();
processObject(profileData)
async function processObject(profileData) {
for(var key in profileData){
// console.log(item)
await asyncCall(key, profileData[key])
@Harshakvarma
Harshakvarma / server.js
Created March 8, 2018 20:54 — forked from taion/server.js
GraphQL subscription server with Socket.IO, backed by Redis Pub/Sub
const redisClient = redis.createClient(REDIS_URL);
const listeners = Object.create(null);
function addListener(channel, listener) {
if (!listeners[channel]) {
listeners[channel] = [];
redisClient.subscribe(channel);
}
listeners[channel].push(listener);
@Harshakvarma
Harshakvarma / myscript
Created February 25, 2018 00:38
Custom script for executing shell commands faster
PS3='Select your choice: '
options=("Quit" "pm2 restart App_Backend" "Option 2" "Option 3")
select opt in "${options[@]}"
do
case $opt in
"Quit")
break
;;
"pm2 restart App_Backend")
pm2 restart App_Backend/server/server.js --name=GIG_backend
@Harshakvarma
Harshakvarma / delay.js
Created February 19, 2018 06:39 — forked from daliborgogic/delay.js
Node.js Async/Await delay
'use strict'
const timeout = ms => new Promise(res => setTimeout(res, ms))
function convinceMe (convince) {
let unixTime = Math.round(+new Date() / 1000)
console.log(`Delay ${convince} at ${unixTime}`)
}
async function delay () {