Skip to content

Instantly share code, notes, and snippets.

View arun057's full-sized avatar

Arunram Kalaiselvan arun057

  • PlaceIQ
  • New York, NY
View GitHub Profile
-- Imported data into postgresql running locally. For larger data sets I would go the map reduce route, seemed overkill here.
-- All of the questions are answered with sql - I did end up double checking some of the results with python - happy to provide that code on request.
-- Consider only the rows with country_id = "BDV" (there are 844 such rows).
-- For each site_id, we can compute the number of unique user_id's found in these 844 rows.
-- Which site_id has the largest number of unique users? And what's the number?
SELECT x.site_id, COUNT(x.site_id) as site_count
import json
# This is probably super straight forward with either pandas
# or a simple sqlite db. Showing how I would implement it without those
# in this sample.
highest_unique_sales = 0
highest_unique_sales_pids = []
def equalsWhenOneCharRemoved(x, y):
lenX = len(x)
lenY = len(y)
# If the lengths are not different by 1, its automatically not true
if abs(lenX - lenY) != 1:
return False
count = 0
@arun057
arun057 / flattenArray.js
Created February 25, 2019 22:45
Flatten Array
function flattenArray(inputArray) {
var resultArray = [];
for (var i = 0; i < inputArray.length; i++) {
if (typeof(inputArray[i]) == 'number') {
resultArray.push(inputArray[i]);
} else if (Array.isArray(inputArray[i])) {
resultArray = resultArray.concat(flattenArray(inputArray[i]))
}
}

Keybase proof

I hereby claim:

  • I am arun057 on github.
  • I am arunram (https://keybase.io/arunram) on keybase.
  • I have a public key ASCxHYj41fMa1G4SaEXLVGupwBZzGruJHDdOBnWb_opy7Qo

To claim this, I am signing this object:

@arun057
arun057 / web-servers.md
Created August 28, 2017 16:32 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@arun057
arun057 / index.js
Last active August 29, 2015 14:17
requirebin sketch
var playAudio = require('play-audio'),
songs = [
'https://krosskastassets.s3.amazonaws.com/uploads/song/file/file-e1148650-a548-0132-0909-12ba921920f5.mp3',
'https://krosskastassets.s3.amazonaws.com/uploads/song/file/file-ea761b90-a548-0132-f957-12ba921920f5.mp3',
'https://krosskastassets.s3.amazonaws.com/uploads/song/file/file-ba6495e0-a548-0132-4f0b-12ba921920f5.mp3',
'https://krosskastassets.s3.amazonaws.com/uploads/song/file/file-9c305750-a548-0132-2908-12ba921920f5.mp3',
'https://krosskastassets.s3.amazonaws.com/uploads/song/file/file-60d93110-a546-0132-f31c-12ba921920f5.mp3'
];
var playing = playAudio(songs[0]).autoplay().controls().on('ended', function(){
@arun057
arun057 / heatmap.js
Created January 10, 2015 19:28
scripted
// You will perform all your work in this file.
// Paste your API key here
var api_key = "54af01f3afe4e";
/************** TASK 1 **************/
//
// This function should get the whole set of complaint data from the server and then
// update the heatmap with it.
//
@arun057
arun057 / loadoing_screen.as
Created December 10, 2014 20:49
Fancy Loading screen
// https://www.reddit.com/r/gifs/comments/2on8si/connecting_to_server_so_mesmerizing/cmow0sz
private const NUM_BALL:int = 24;
private var loadingBall:Vector.<Shape> = new Vector.<Shape>(NUM_BALL);
private var timeStep:int = 0;
private const BALL_HEIGHT:int = 40;
public function animateBalls(e:Event):void
{
for (var i:int = 0; i < NUM_BALL; i++ )
# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront