Skip to content

Instantly share code, notes, and snippets.

View nonsocchi's full-sized avatar
😄
Coding for dear life.

nonsocchi nonsocchi

😄
Coding for dear life.
  • RikaiData Ltd
  • Nigeria
View GitHub Profile
@nonsocchi
nonsocchi / statistical-analysis.csv
Last active November 3, 2023 17:37
Statistical analysis of offset data
stat value
P10 0.86
P50 1.00
Average (mean) 1.02
P90 1.24
Sample Size 9.00
Standard Deviation 0.20
@nonsocchi
nonsocchi / offset-data.csv
Last active November 3, 2023 15:35
Table of historical guesses/estimates.
Guess Actual Actual-Guess-Ratio
9.8 10 1.0
9.2 11 1.2
11.5 10.4 0.9
12.2 11 0.9
8 11 1.4
12 11.6 0.9
10 10 1
9 10 1.1
13 9 0.7
@nonsocchi
nonsocchi / Loss Forecasting with ARIMA.py
Last active October 14, 2023 13:18
Notebook file for Loss forecasting with ARIMA model.
# %%
import pandas as pd
import matplotlib.pyplot as plt
from statsmodels.tsa.arima.model import ARIMA
# %%
# Load data into a pandas df
company_data = pd.DataFrame({
'Month' : ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug'],
'Loss_YTD' : [53.9, 41.5, 34.3, 31.5, 28.3, 26.8, 30.4, 28.4]
@nonsocchi
nonsocchi / app.dart
Last active May 17, 2023 19:59
riverpod_app_theme: switching theme with provider
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return Consumer(
builder: (_, ref, __) => MaterialApp(
debugShowCheckedModeBanner: false,
// Define a light and dark color theme. Then, read the user's
@nonsocchi
nonsocchi / main.dart
Created May 17, 2023 19:49
riverpod_theme_app: Setting up local storage access.
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Create the shared_preferences instance.
final sharedPreferences = await SharedPreferences.getInstance();
runApp(
ProviderScope(
// override the prefsProvider with this value.
overrides: [
@nonsocchi
nonsocchi / theming_service_2.dart
Last active May 14, 2023 21:04
riverpod_theme_app: service layer providers.
// Creates a themingServiceProvider used by the ThemingController.
@riverpod
ThemingService themingService(ThemingServiceRef ref) {
final prefs = ref.read(prefsProvider);
return ThemingService(prefs);
}
// Override in `Provider Container` when app starts.
@riverpod
SharedPreferences prefs(PrefsRef ref) => throw UnimplementedError();
@nonsocchi
nonsocchi / theming_service_1.dart
Last active May 14, 2023 21:01
riverpod_theme_app: Service class for reading and writing theme settings from local storage.
class ThemingService {
final SharedPreferences _prefs;
ThemingService(this._prefs);
static const _themeKey = 'theme';
/// Loads the preferred theme from local storage with shared_preferences.
/// Returns system theme initially if no theme is saved.
ThemeMode themeMode() {
final themeValue = _prefs.getInt(_themeKey);
@nonsocchi
nonsocchi / theming_view_1.dart
Last active May 17, 2023 19:05
riverpod_theme_app: creating widgets in the presentation layer.
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'theming_controller.dart';
class ThemingView extends StatelessWidget {
const ThemingView({super.key});
static const String themingRoute = '/theming';
@override
@nonsocchi
nonsocchi / pubspec.yaml
Last active May 14, 2023 18:46
create new flutter app using skeleton template
environment:
sdk: '>=3.0.0 <4.0.0'
dependencies:
flutter_riverpod: ^2.3.6
riverpod_annotation: ^2.1.1
shared_preferences: ^2.1.1
# other dependencies ...
dev_dependencies:
function doGet() {
// return displayEmails();
// return displayParsedData();
return processTxnEmails();
}