This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import pymysql | |
import requests | |
from flask import Flask, request | |
from flask_restful import Api, Resource | |
host = 'your_mysql_ip' | |
user = 'your_username' | |
password = 'your_password' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import pymysql | |
from flask import Flask, request | |
from flask_restful import Api, Resource | |
host = 'your_mysql_ip' | |
user = 'your_username' | |
password = 'your_password' | |
database = 'rest' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import pymysql | |
from flask import Flask, request | |
from flask_restful import Api, Resource | |
host = 'your_mysql_ip' | |
user = 'your_username' | |
password = 'your_password' | |
database = 'rest' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Worked on MySQL 5.7 | |
CREATE DATABASE IF NOT EXISTS rest; | |
CREATE TABLE IF NOT EXISTS rest.Users( | |
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, | |
username VARCHAR(128) NOT NULL, | |
email VARCHAR(128) NOT NULL, | |
joined_datetime DATETIME DEFAULT NOW() | |
); | |
CREATE TABLE IF NOT EXISTS rest.Makers( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Other request methods to use in the Resource object: | |
- request.get_json() | |
- request.path | |
- request.base_url | |
- request.get_data() | |
- request.query_string | |
- request.args -> Kind of dict | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def partition(list, l, r): | |
pivot = list[r] | |
i=l | |
j=r-1 | |
while True: | |
while i<r and list[i]<=pivot: | |
i+=1 | |
while j>l and list[j]>pivot: | |
j-=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def parent_index(i): | |
return (i-1)//2 | |
def lchild_index(i): | |
return i*2+1 | |
def rchild_index(i): | |
return i*2+2 | |
# max_min==1 means a max-heap. -1 means a min-heap. | |
# right means the rightmost index (not the length) | |
def recursive_heapify(list, i, right, max_min=1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class iPhone: | |
iphone_list = ["3g", "3gs", "4", "4S", "5", "5s"] | |
def __init__(self, model): | |
self.model = model | |
@classmethod | |
def from_year(cls, year): | |
return cls(iPhone.iphone_list[int(year) - 2008]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(){ | |
volatile int impenetrable_variable=10; | |
for(int i=1; i<=3; i++){ | |
// Every time the value is changed, it really changes the value in the main memory. | |
impenetrable_variable += i; | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Parent{ | |
public: | |
virtual void print(){ | |
cout<<"PARENT PRINT"<<endl; | |
} | |
void display(){ | |
cout<<"PARENT DISPLAY"<<endl; |
NewerOlder