Skip to content

Instantly share code, notes, and snippets.

@athap
athap / permutations.go
Created February 27, 2016 21:53
Golang: Print all permutation of a string
package main
import "fmt"
/*
Return all permutations of a string
Example,
Find all perm of abc:
@athap
athap / Vim Paste Mode
Created January 19, 2016 02:25
Fix Vim paste indent issue. When copying text using ctrl-c
Before pasting
:set paste
After Paste
:set nopaste
+web:
+ build: .
+ ports:
+ - '9292:9292'
+ volumes:
+ - '.:/var/app'
+ tty: true
+ command: ["rerun", "--force-polling", "foreman", "start"]
FROM ruby:2.2.0
RUN mkdir -p /var/app
COPY Gemfile* /var/app/
WORKDIR /var/app
ENV environment=development
RUN bundle install
@athap
athap / scraper options
Created October 14, 2015 15:45
scraper options
./script/scraper --help
Usage: scraper [options] [sources ...]
Specific Options:
-l, --limit N Limit operations to N listings.
-t, --throttle N Random amount of time to throttle between url gets.
-c, --command [COMMAND] Which types of scraping command you want to run (all harvest collect scrape rescrape all_agents new_agents fix_agents quick_harvest_and_close quick_close validate)
-s, --sourceid id Scrapes a single listing using its source id.
-o, --office office_key(s) Scrapes office's listings using its office key (for MRIS and ListHub scrapers). Can be comma-delimited.
-e, --env [ENVIRONMENT] Which types of evironment you want to run in (prod gamma beta dev)
u = User.find 1
// page 1
c1 = u.comments.where(disabled: 0).limit(50).page(1).per(20)
id1 = c1.map(&:id)
//page2
c2 = u.comments.where(disabled: 0).limit(50).page(2).per(20)
id2 = c2.map(&:id)
@athap
athap / addToTree.js
Created September 6, 2014 17:22
Add to tree
var addToTree = function() {
input = document.getElementById('tree-input');
value = parseInt(input.value);
if(value)
btree.add(value);
else
alert("Wrong input");
};
@athap
athap / btree.js
Created September 6, 2014 17:17
Binary tree lofic
// Represents the btree logic
var BTree = function() {
var c = document.getElementById('my-canvas');
var ctx = c.getContext('2d');
var line = new Line();
this.root = null;
var self = this;
// Getter for root
@athap
athap / line.js
Created September 6, 2014 17:08
Draws a line
// Draws a line from one circle(node) to another circle (node)
var Line = function() {
// Takes
// x,y - starting x,y coordinate
// toX, toY - ending x,y coordinate
this.draw = function(x, y, toX, toY, r, ctx) {
var moveToX = x;
var moveToY = y + r;
var lineToX = toX;
var lineToY = toY - r;
@athap
athap / index.html
Last active August 29, 2015 14:06
Index file
<!DOCTYPE html>
<html>
<head>
<style>
.center {margin: auto; width: 50%;}
<style>
</head>
<body>
<div class='input-box'>
<input id='tree-input' type='number' placeholder='Enter number'>