Skip to content

Instantly share code, notes, and snippets.

🎯
go module

Yan Feng frankie-yanfeng

🎯
go module
Block or report user

Report or block frankie-yanfeng

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@frankie-yanfeng
frankie-yanfeng / gcp_bucket_creation.py
Created Apr 17, 2019
create the env variables to call gsutil command
View gcp_bucket_creation.py
# change these to try this notebook out
BUCKET = 'cloud-training-demos-ml'
PROJECT = 'cloud-training-demos'
REGION = 'us-central1'
import os
os.environ['BUCKET'] = BUCKET
os.environ['PROJECT'] = PROJECT
os.environ['REGION'] = REGION
View sql_query.py
# Create function that finds the number of records and the average weight for each value of the chosen column
def get_distinct_values(column_name):
sql = """
SELECT
{0},
COUNT(1) AS num_babies,
AVG(weight_pounds) AS avg_wt
FROM
publicdata.samples.natality
WHERE
@frankie-yanfeng
frankie-yanfeng / operatorOverridingMemberFunction.cpp
Created Mar 3, 2019
C++ operator overriding member function
View operatorOverridingMemberFunction.cpp
#include <iostream>
using namespace std;
class Complex {
public:
Complex( double r= 0.0, double m = 0.0 ):real(r), imaginary(m) { } // constructor
Complex operator+ ( const Complex & ); // addition
Complex operator- ( const Complex & ); // subtraction
void getValue(){ cout << "real:" << this->real << " imaginary:" << this->imaginary << endl;}
@frankie-yanfeng
frankie-yanfeng / operatorOverriding.cpp
Created Mar 3, 2019
C++ operator Overriding (operator function)
View operatorOverriding.cpp
#include <iostream>
using namespace std;
class Complex {
public:
Complex( double r = 0.0, double i= 0.0 ){
real = r;
imaginary = i;
}
View enclosing.cpp
class CTyre { //轮胎类
private:
int radius; //半径
int width; //宽度
public:
CTyre(int r, int w):radius(r), width(w) { }
};
class CEngine { //引擎类
};
View typeChangeConstructor.cpp
#include <iostream>
using namespace std;
class Complex {
public:
double real, imag;
Complex( int i ) { //类型转换构造函数
cout << "IntConstructor called" << endl;
real = i; imag = 0;
View constructorArray.cpp
#include <iostream>
using namespace std;
class CSample {
int x;
public:
CSample() {
cout << "Constructor 1 Called" << endl;
}
View privateConstructor.cpp
class WonderfulClass
{
public:
static WonderfulClass* makeAnObject()
{
// 创建一个WonderfulClass对象并返回其指针
return (new WonderfulClass);
}
private:
WonderfulClass() { }
@frankie-yanfeng
frankie-yanfeng / comma_sep.cpp
Created Mar 3, 2019
how to parser comma separated string in c++
View comma_sep.cpp
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <sstream>
using namespace std;
int main() {
char Name[30];
You can’t perform that action at this time.