Skip to content

Instantly share code, notes, and snippets.

@binodpanta
binodpanta / solution.js
Created April 4, 2020 23:44
solution for localytics
const path = require('path');
const fs = require('fs');
const _ = require('lodash');
//
// salesMap : categoryMap = { category: [ price1, price2 ] }
// salesMap = { category: [ avgSalesPrice ] }
//
/**
* @param {Array} categoriesRawData input array of categories [ { item: name, category: cat } ]
@binodpanta
binodpanta / vuejs-aws-s3-image-upload.js
Last active October 11, 2021 09:40
A simple and effective method to upload image files to AWS S3. I will create a Vue component at some point.
import axios from 'axios';
import AWS from "aws-sdk";
/** Steps to use this:
* Refer to this doc from AWS on how to create S3 supporting Identity to use in this component. https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/s3-example-photo-album.html
* (1) Create Cognito identity pool (see this) and grab the ID of the pool
* (2) Ensure the IAM created by cognito has access to your S3 bucket
* (3) Use this vue component as a uploader component to upload one image. We can rewrite it to support multi images easily.
*
* Once done through with the Prerequisite tasks part of the above, just grab the cognito Identity pool id and come here.
@binodpanta
binodpanta / rinkebyaddress.txt
Created October 26, 2017 01:32
rinkebyaddress
0xA7aA4C344e38ab5d57687608E198cEAC09027ea4
@binodpanta
binodpanta / tweettracker.rb
Last active August 29, 2015 14:14
Track Tweets on your console in colored formatted display using Ruby, Rake and Awesome print
# If you use Rails, just add a lib/tasks/tweets.rb or something and paste this code there, then run rake tweets:tweet1 to run it
# This stops after 50 tweets but you don't have to! Now sit back and watch your custom twitter feed live on your console!
require 'tweetstream'
require 'awesome_print'
namespace :tweets do
desc "Tracks tweets with specified strings and stores them in db"
task tweet1: :environment do
// An attempt to solve the sum of primes problems posted at http://projecteuler.net/problem=10
// References: http://stackoverflow.com/questions/15750574/js-prime-numbers-script-explanation
// Runs in about 89.4s on my Windows dual-core laptop, Win 7, Intel Core 2 Duo (x2GHz), 4GB RAM, using nodejs
// My output:
// 142913828922
// primes found 148933
// [Finished in 89.4s]
// Verified against answer on projecteuler.net