Skip to content

Instantly share code, notes, and snippets.

View prestigegodson's full-sized avatar
💭
I may be slow to respond.

Godson Ositadinma prestigegodson

💭
I may be slow to respond.
View GitHub Profile
private Page<GroupedCustomerTransaction> groupCustomerTransactionRecordByMonthOfYear(Page<CustomerTransactionDTO> customerTransactionPage) {
List<CustomerTransactionDTO> customerTransactions = customerTransactionPage.getContent();
Map<String, List<CustomerTransactionDTO>> store = new HashMap<>();
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MMMM-yyyy");
customerTransactions.stream().forEach(customerTransaction -> {
String createdYearMonth = dateTimeFormatter.format(customerTransaction.getCreatedDate());
if(store.containsKey(createdYearMonth)){
store.get(createdYearMonth).add(customerTransaction);
}else{
import {Component, OnInit, ViewChild} from '@angular/core';
import {SharedService} from '../../../services/shared-service/shared.service';
import {Constants} from '../../../util/Constants';
import {AnonymousService} from '../../../services/anonymous-service';
import {AuthService} from '../../../services/auth-service/auth-service.service';
import {MdSnackBar, MdSnackBarConfig} from '@angular/material';
import {FormBuilder, FormGroup, FormGroupDirective, Validators} from '@angular/forms';
import {ErrorService} from '../../../util/error_service/error.service';
import {ToastService} from '../../../util/toast-service/toast.service';
import {MobileNetworks} from '../../../util/mobile-networks';
@prestigegodson
prestigegodson / length_of_longest_substring.py
Created April 2, 2021 14:59
Length of longest substring python
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
cursor = 0
start = 0
end = len(s)
longest = 0
subStringMap = {}
while start < end:
function first_repeating_character(characters) {
if (characters == undefined || characters.length == 0) {
return undefined;
}
let dict = {};
for (i = 0; i < characters.length; i++) {
if (dict[characters.charAt(i)] == undefined) {
dict[characters.charAt(i)] = true;
def first_repeating_character(characters):
if not characters:
return None
characterSet = set()
for c in characters:
if c in characterSet:
return c
else:
characterSet.add(c)
@prestigegodson
prestigegodson / postgres_manager.py
Created December 9, 2020 11:14 — forked from valferon/postgres_manager.py
Python script to take care of postgres backup and restore of data
#!/usr/bin/python3
import argparse
import logging
import subprocess
import os
import tempfile
from tempfile import mkstemp
import configparser
import gzip
{
"countries": [
{
"country": "Afghanistan",
"states": ["Badakhshan", "Badghis", "Baghlan", "Balkh", "Bamian", "Daykondi", "Farah", "Faryab", "Ghazni", "Ghowr", "Helmand", "Herat", "Jowzjan", "Kabul", "Kandahar", "Kapisa", "Khost", "Konar", "Kondoz", "Laghman", "Lowgar", "Nangarhar", "Nimruz", "Nurestan", "Oruzgan", "Paktia", "Paktika", "Panjshir", "Parvan", "Samangan", "Sar-e Pol", "Takhar", "Vardak", "Zabol"]
},
{
"country": "Albania",
"states": ["Berat", "Dibres", "Durres", "Elbasan", "Fier", "Gjirokastre", "Korce", "Kukes", "Lezhe", "Shkoder", "Tirane", "Vlore"]
},
<!doctype html>
<html lang="en">
<!-- Copyright 2017 Nishant Srivastava
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>,
next: HttpHandler): Observable<HttpEvent<any>> {
const idToken = localStorage.getItem("id_token");
if (idToken) {
const cloned = req.clone({
select au.first_name, au.last_name, au.email, p.user_id as "User Id", p.id as "Pledge Id", p.amount as "Pledged Amount",
(select coalesce(sum(pr.amount), 0) from pledge_redemption pr where p.id = pr.pledge_id) as "Paid Amount"
from pledge p
join auth_user au on au.id = p.user_id
where p.amount > (select coalesce(sum(pr.amount), 0) from pledge_redemption pr where p.id = pr.pledge_id);