Skip to content

Instantly share code, notes, and snippets.

View ritchieng's full-sized avatar
🤓

Ritchie Ng ritchieng

🤓
View GitHub Profile
# One day returns calculation through differencing by 1
differencing_factor = 1
df_daily_returns = (df_raw - df_raw.shift(differencing_factor)) / df_raw.shift(differencing_factor) * 100
df_daily_returns.plot(figsize=figsize)
plt.title(f'{asset_name} Daily Returns via Differencing 1 Day');
# Critical imports for GPU cuDF
import nvstrings, nvcategory, cudf
# Other imports
import numpy as np
import pandas as pd
import time
import pandas_datareader.data as web
from datetime import datetime
from matplotlib import pyplot as plt
int raiseToPower(int base, int exponent) {
int result = 1;
for (int i = 0; i < exponent; i = i + 1) {
result = result * base;
}
return result;
}
#include <iostream>
using namespace std;
int main() {
int x = 0;
for (; x <= 10;) {
x = x + 1;
cout << "x is " << x << "\n";
}
return 0;
#include <iostream>
using namespace std;
int main() {
int x = 0;
int y = 2;
while (x < 10) {
x = x + 1;
cout << "x is " << x << "\n";
}
@ritchieng
ritchieng / if_conditional.cpp
Created November 21, 2016 05:49
If conditional for C++
#include <iostream>
using namespace std;
int main() {
int x = 6;
int y = 2;
if(x > y)
cout << "x is greater than y\n";
else if(y > x)
cout << "y is greater than x\n";
#include <iostream>
using namespace std;
int main() {
int x;
cin >> x;
cout << x / 3 << ' ' << x * 2;
return 0;
}
// Just a simple program
#include <iostream>
int main() {
std::cout << "Hello, world!\n";
return 0;
}
// Tell the preprocessor to dump the contents into iostream that defines our io
#include <iostream>
// This tells the compiler that it should look in the std namespace for any identifiers we haven't defined
using namespace std;
// Initiate
int main() {
// We declare the variable with int x then initialize x by specifying a value
int x = 4 + 2;
@ritchieng
ritchieng / keras_wide_resnet_native.py
Created October 28, 2016 21:21
Keras Implementation of Wide ResNet with TensorFlow Sessions
import tensorflow as tf
from keras import backend as K
from keras.layers import Dense
from keras.objectives import categorical_crossentropy
from keras.metrics import categorical_accuracy as accuracy
from keras.datasets import cifar10
from keras.utils import np_utils
from keras.layers import Dense, Activation, Flatten, Lambda, Convolution2D, Convolution1D, AveragePooling2D, BatchNormalization, Dropout, Reshape
from keras.engine import merge, Input, Model
from keras.engine.training import collect_trainable_weights