Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View arsho's full-sized avatar

Ahmedur Rahman Shovon arsho

View GitHub Profile
@arsho
arsho / allocation_solution_using_counting_sort.py
Created August 9, 2020 18:52
Google Kick Start 2020 - Round A: Allocation (5pts, 7pts). Time complexity: O(N) for counting sort and O(NlogN) for default sort.
def get_sorted_values(values):
occurrences = [0] * 1001
sorted_values = [0]*len(values)
for value in values:
occurrences[value] += 1
for i in range(1, 1001):
occurrences[i] += occurrences[i-1]
for i in range(len(values)-1, -1, -1):
sorted_values[occurrences[values[i]]-1] = values[i]
occurrences[values[i]] -= 1
@arsho
arsho / dataframe.md
Last active July 15, 2020 04:14
Stackoverflow suggestions for new questions
"<div id=\"54d74ae1-aaa7-4169-8e43-f2c254126761\" class=\"plotly-graph-div\" style=\"height:600px; width:900px;\"></div>\n <script type=\"text/javascript\">\n$(document).ready(function(){\n window.PLOTLYENV=window.PLOTLYENV || {};\n\n if (document.getElementById(\"54d74ae1-aaa7-4169-8e43-f2c254126761\")) {\n Plotly.newPlot(\n '54d74ae1-aaa7-4169-8e43-f2c254126761',\n [{\"marker\": {\"color\": \"black\", \"size\": 4}, \"mode\": \"markers\", \"name\": \"Actual\", \"type\": \"scatter\", \"x\": [\"2020-03-18T00:00:00\", \"2020-03-19T00:00:00\", \"2020-03-20T00:00:00\", \"2020-03-21T00:00:00\", \"2020-03-22T00:00:00\", \"2020-03-23T00:00:00\", \"2020-03-24T00:00:00\", \"2020-03-25T00:00:00\", \"2020-03-26T00:00:00\", \"2020-03-27T00:00:00\", \"2020-03-28T00:00:00\", \"2020-03-29T00:00:00\", \"2020-03-30T00:00:00\", \"2020-03-31T00:00:00\", \"2020-04-01T00:00:00\", \"2020-04-02T00:00:00\", \"2020-04-03T00:00:00\", \"2020-04-04T00:00:00\", \"2020-04-05T00:00:00\", \"2020-04-06T00:00
<script src="https://cdnjs.cloudflare.com/ajax/libs/plotly.js/1.51.1/plotly.min.js" integrity="sha256-qe/oN+ddr+wOzXyDWGSx8glJYbdQk2FwExwyQgNMsdQ=" crossorigin="anonymous"></script>
<script type="text/javascript">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>
<div id="54d74ae1-aaa7-4169-8e43-f2c254126761" class="plotly-graph-div" style="height:600px; width:900px;"></div>
<script type="text/javascript">
$(document).ready(function(){
<?php echo $db->variable ?>
})
</script>
<!---->
@arsho
arsho / day_1_LinearRegressionOnLinearEquation.html
Created April 11, 2020 19:19
Tensorflow Basic Linear Regression on Linear Equation
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="author" content="Ahmedur Rahman Shovon">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<title>Tensorflow Basic Linear Regression on Linear Equation</title>
@arsho
arsho / extract_table.js
Created April 10, 2020 17:55
Extract features and generate readme list from https://www.django-cms.org/en/features/list/
$count_section = 1;
$count_subsection = 1;
$self_service = "Self service";
$third_party = "Via add-ons or third-party services";
$final_string = "";
$(".table tr").each(function(item, data){
$tr = $(this);
if($tr.attr("class") == "active"){
$section_title = $tr.children("td:first").text();
$final_string += $count_section+". #### "+$section_title+":"+"\n";
var count = 0;
$(".child-domains").each(function(index)
{
$this = $(this);
children_length = $this.find('a').length;
count += children_length;
}
);
console.log("Total = ", count);
@arsho
arsho / fix_grub.md
Last active September 22, 2019 13:34
Fix bootloader after deleting Ubuntu partition from Dual boot

Recover Grub after deleting Ubuntu 18.04 partition:

  • Download Windows 8.1 International English (.iso file) from Official website
  • Download Rufus
  • Insert USB 2 pendrive and burn the ISO to pendrive by
    • Select MBR
    • Select Legacy
  • Restart PC and select the pendrive
  • Select English
  • Select repair your computer
  • Choose TroubleShoot > Advanced Options > Command Prompt
@arsho
arsho / python_3.8_features.py
Created May 22, 2019 07:02
Example of New features in Python 3.8. Walrus operator and positional only parameters. #python3.8
### Walrush operator
data = ["some", "dummy", "values", "in", "this", "list"]
# Show the length of data if data has more than 5 values
if (data_length:=len(data)) > 5:
print(data_length)
# 6
### Positional only parameters
@arsho
arsho / merge_two_lists.py
Created May 19, 2019 07:18
Shanto mapping debug
def merge_two_lists(a, b):
data = {}
for pair in a+b:
key, value = pair
data[key] = data.get(key, 0) + value
sorted_data = sorted([[key, value] for key, value in data.items()])
return sorted_data
if __name__ == '__main__':
a = [['hello', 5], ['test', 6], ['egg', 2]]