Skip to content

Instantly share code, notes, and snippets.

View bakermeoe's full-sized avatar
🎯
Focusing

bakermeoe bakermeoe

🎯
Focusing
View GitHub Profile
@bakermeoe
bakermeoe / projects.py
Created December 9, 2020 06:41
How to iterate through dict in Django template
{% for key, value in test_codes_dict.items %}
<option value="{{ key }}">{{ value }}</option>
{% endfor %}
@bakermeoe
bakermeoe / index.html
Last active December 7, 2020 09:32
read csv file data in Django
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
<meta name="viewport" content="width=device-width" />
<title>ATE-Dashboard</title>
@bakermeoe
bakermeoe / answer4.js
Last active March 21, 2019 16:56
Question 4 (Please explain what is the bug in the following Javascript function, and how to correct it.)
function createArrayOfFunctions(y){
var arr = [];
x = 1
for (let i = 0; i < y ; i++){
arr[i] = function(x){
return x + i;
}
}
return arr;
@bakermeoe
bakermeoe / answer3.py
Last active March 21, 2019 15:53
Question 3 (Write a function that takes an array of integers as input. For each integer, output the next fibonacci number. Solution that work both cpu and memory efficient are appreciated.)
import time
def recursiveFibonacci(number, fn1, fn2):
fnNext = fn1 + fn2
fn1 = fn2
if number < fnNext:
print(fnNext)
else:
recursiveFibonacci(number, fn1,fnNext)
@bakermeoe
bakermeoe / answer2.md
Last active March 18, 2019 12:33
Question 2 (What is the computational complexity of your answer in Question 1? Can you explain why?)

Answer 2
What is the computational complexity of your answer in Question 1? Can you explain why?

The computational complexity of Question 1 is O(n2).

Explanation:

for i in range(len(arr2)):
@bakermeoe
bakermeoe / answer1.py
Last active March 18, 2019 12:32
Question 1 (Write a function that takes two arrays as input, each array contains a list of A-Z; Your program should return True if the 2nd array is a subset of 1st array, or False if not.)
def isSubset(arr1, arr2):
count = 0
flagSubset = False
for i in range(len(arr2)):
for j in range(len(arr1)):
if(arr2[i].strip().upper() == arr1[j].strip().upper()):
count+=1
break
@bakermeoe
bakermeoe / CouchDB Snippet Replicaation Command
Created March 7, 2018 03:12
1. replication from local to server (or anything else)
curl -H 'Content-Type: application/json' -X POST http://localhost:5984/_replicate -d ' {"source": "http://localhost:5984/bec-ember-three/", "target": "http://128.199.160.40:5984/bec-ember-recover"}'
curl -X POST http://128.199.160.40:5984/_replicate -H "Content-Type: application/json" -d '{"source": "test_database", "target":"bec-practice", "doc_ids": ["practices"]}'