Skip to content

Instantly share code, notes, and snippets.

View mythicalprogrammer's full-sized avatar
💭
working on side project private repo

Anthony Doan mythicalprogrammer

💭
working on side project private repo
View GitHub Profile
# Our .tmux.conf file
# Setting the prefix from C-b to C-a
set -g prefix C-a
# Free the original Ctrl-b prefix keybinding
unbind C-b
#setting the delay between prefix and command
set -sg escape-time 1
@mythicalprogrammer
mythicalprogrammer / interval_interview_question.rb
Created June 24, 2013 12:39
set1 = [[1,2],[5,7],[9,12]] set2 = [[3,4],[5,6],[13,17]] Merge the two set of interval Interview question, where the answer should be: [[1, 7], [9, 17]] There probably a corner case I'm missing somewhere. It's too early in the morning to think wah.
set1 = [[1,2],[5,7],[9,12]]
set2 = [[3,4],[5,6],[13,17]]
puts set1.inspect
puts set2.inspect
puts "combind the two set"
set3 = set1 + set2
puts set3.inspect
@mythicalprogrammer
mythicalprogrammer / perfect_square.rb
Created June 20, 2013 03:50
Given an integer input, return the total number of all perfect square square. Note 2^2+3^2 and 3^2+2^2 is counted as one.
require 'set'
number = gets
number = number.to_i
max = Math.sqrt(number).to_i
set = Set.new
n_perf = 0
for i in 0..max
@mythicalprogrammer
mythicalprogrammer / interview_q1.rb
Created June 20, 2013 03:47
Interview Question 1. given three parameters, first one the string, 2nd one is the letter where the sorted string will start, 3rd the index within the given sorted string
str_parse = gets.chomp
s_char = gets.chomp
f_char = gets.chomp
alpha = "abcdefghijklmnopqrstuvwxyz".chars
iter = alpha.find_index(s_char)
while iter >= 0
substr_arg1 = str_parse.chars.find_index(alpha[iter])
if (substr_arg1.nil?)
@mythicalprogrammer
mythicalprogrammer / server.js
Created June 12, 2013 19:09
Mongoose Connect to DB (named rift) and querying for a user by email.
var mongoose = require('mongoose'),
Admin = require('./models/admin');
var connStr = 'mongodb://localhost:27017/rift';
mongoose.connect(connStr, function(err) {
if (err) throw err;
console.log('Successfully connected to Mongo');
});
Admin.findOne({ email:'Anthony@rift.info' },
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
var AdminSchema = new Schema({
name: { type: String, required: true},
email: { type: String, required: true, index: { unique: true } },
password: { type: String, required: true }
});
// CRUD operations might be built in not sure... do research!
var a = 1,
b = 2,
temp = 0,
total = 2;
while (total < 4000001) {
temp = a + b;
@mythicalprogrammer
mythicalprogrammer / euler_prob_1.js
Created May 8, 2013 21:11
Javascript Euler Problem #1
var total = 0;
for (var i = 1; i < 1001; i++ ) {
if (i%3 === 0 || i%5 === 0) {
total += i;
}
}
console.log(total);