Skip to content

Instantly share code, notes, and snippets.

View ivanji's full-sized avatar
🎯
Focusing

Ivan J ivanji

🎯
Focusing
View GitHub Profile
@ivanji
ivanji / onlyDuplicates.js
Created February 12, 2019 21:49
Provide only duplicates within text
/**
Given a string, remove any characters that are unique from the string.
Example:
input: "abccdefee"
output: "cceee"
*/
@ivanji
ivanji / permutations.js
Created February 12, 2019 21:45
Create String Permutations
// create all permutations of an input string and remove duplicates, if present
function permutations(string) {
var nums = Array.from(string);
var permutations = [];
function swap(a, b) {
var tmp = nums[a];
nums[a] = nums[b];
function order(words){
/**
* Your task is to sort a given string.
* Each word in the string will contain a single number.
* This number is the position the word should have in the result.
* Note: Numbers can be from 1 to 9. So 1 will be the first word (not 0).
* If the input string is empty, return an empty string. The words in the input String will only contain valid consecutive numbers.
*
function humanReadable(seconds) {
var readable = ["00", "00", "00"];
// TODO
if (seconds > 359999 || seconds < 0) {
console.log("exiting...")
return;
}
var min = 60; //* 60 = 1 hour
var hour = 3600; //* 24 = 1 day
var day = 86400; //
@ivanji
ivanji / cloudformation-dynamoDB.yml
Created January 4, 2019 04:44 — forked from DavidWells/cloudformation-dynamoDB.yml
Example of dynamo cloudformation with GSI and LSI
---
AWSTemplateFormatVersion: '2010-09-09'
Resources:
myDynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: Album
AttributeType: S
- AttributeName: Artist
@ivanji
ivanji / AWS Instance Bootstrap
Last active August 4, 2016 05:08 — forked from mikepfeiffer/gist:4d9386afdcceaf29493a
EC2 UserData script to install CodeDeploy agent
#!/bin/bash
yum update -y
yum install -y httpd24 php56
cd /home/ec2-user/
aws s3 cp 's3://aws-codedeploy-us-west-2/latest/codedeploy-agent.noarch.rpm' . --region us-west-2
yum -y install codedeploy-agent.noarch.rpm
chown -R root:www /var/www
chmod 2775 /var/www