source_repo string | license string | text string | word count int64 | letter count int64 | author_username null | id string |
|---|---|---|---|---|---|---|
0neKill/chat_react_with_mongoDB | no_license | import React from "react";
import PropsTypes from 'prop-types';
import './Avatar.scss';
import {generateAvatarFromHash} from '../../utils/helpers'
const Avatar = ({user}) => {
if (user.avatar) {
return <img className='avatar' src={user.avatar} alt={`${user.fullname} avatar`}/>;
} else {
cons... | 64 | 442 | null | 6464474118270601 |
0neKill/chat_react_with_mongoDB | no_license | const initialState = {
data: null,
isAuth: !!localStorage.getItem('token'),
token: localStorage.getItem('token') || null,
}
export default (state = initialState, action) => {
switch (action.type) {
case 'USER:SET_DATA': {
return {
...state,
data: acti... | 51 | 277 | null | 6503326098182072 |
0neKill/chat_react_with_mongoDB | no_license | import express from 'express';
import {verifyJWToken} from "../utils";
import {IUser} from '../models/User';
export default (req: any, res: any, next: any) => {
const token = req.get('token');
if (!token) return res.status(401).json({error: 'Token not provided!'});
verifyJWToken(token)
.then((user:... | 48 | 259 | null | 5664648519389674 |
0neKill/chat_react_with_mongoDB | no_license | import {withFormik} from 'formik';
import {connect} from 'react-redux';
import RegisterForm from '../components/RegisterForm';
import validate from '../../../utils/validations';
import {userActions} from "../../../redux/actions";
const MyEnhancedForm = withFormik({
mapPropsToValues: () => ({email: '', fullName: '... | 88 | 594 | null | 8226704343882225 |
0neKill/chat_react_with_mongoDB | no_license | import React from "react";
import classNames from 'classnames';
import PropsTypes from 'prop-types';
import format from 'date-fns/format';
import isToday from 'date-fns/isToday';
import {IconReaded, Avatar} from '../';
import {Link} from "react-router-dom";
const messageTime = created_at => {
return isToday(new D... | 152 | 1,041 | null | 0691439685663996 |
0neKill/chat_react_with_mongoDB | no_license | import {Schema, model, Document} from 'mongoose';
import isEmail from 'validator';
import differenceInMinutes from 'date-fns/differenceInMinutes';
import {generatePasswordHash} from '../utils';
export interface IUser extends Document {
email?: string;
fullname?: string;
password?: string;
avatar?: str... | 164 | 1,010 | null | 0164901599719148 |
0neKill/chat_react_with_mongoDB | no_license | import express from "express";
import {validationResult} from 'express-validator';
import socket from 'socket.io';
import bcrypt from 'bcrypt';
import createJWToken from "../utils/createJWToken";
import {UserSchema} from '../models';
import has = Reflect.has;
export default class UserController {
io: socket.Serv... | 385 | 2,078 | null | 1768209297658473 |
0neKill/chat_react_with_mongoDB | no_license | import React, {useEffect, useState} from 'react';
import {useSelector} from "react-redux";
import {Status as BaseStatus} from '../components';
const Status = () => {
const {dialogs: {currentDialog, item}, user: {data}} = useSelector(state => state);
const [user, setUser] = useState();
console.log(data)
... | 97 | 516 | null | 6068499007475202 |
0neKill/chat_react_with_mongoDB | no_license | import React, {useEffect, useRef, useState} from "react";
import {useDispatch, useSelector} from 'react-redux';
import socket from '../core/socket';
import {messagesActions} from '../redux/actions';
import {Messages as BaseMessages} from '../components';
const Messages = () => {
const {dialogs: {currentDialog}, m... | 176 | 1,434 | null | 7619638250017013 |
0neKill/chat_react_with_mongoDB | no_license | import React from 'react';
import {Input, Button} from "antd";
import {UploadField} from '@navjobs/upload';
import {Picker} from 'emoji-mart'
import {SmileOutlined, CameraOutlined, AudioOutlined, SendOutlined, AudioMutedOutlined} from '@ant-design/icons';
import {UploadFile} from '../';
import './ChatInput.scss';
con... | 169 | 1,494 | null | 7898579195960866 |
0neKill/chat_react_with_mongoDB | no_license | .messages{
height: 100%;
padding: 20px 20px 0 20px;
overflow: auto;
&--loading{
display: flex;
align-items: center;
justify-content: center;
}
}
.block {
padding: 45px;
background: #FFFFFF;
box-shadow: 0px 0px 25px rgba(0, 0, 0, 0.04204);
border-radius: 3px;
} | 36 | 156 | null | 6587767163802177 |
0neKill/chat_react_with_mongoDB | no_license | import {axios} from "../../core";
export default {
getAll: () => axios.get('/dialogs'),
createDialog: (data) => axios.post('/dialogs/create', data),
}; | 17 | 95 | null | 1431926995423931 |
0neKill/chat_react_with_mongoDB | no_license | import {Schema, model, Document} from 'mongoose';
interface IDialog extends Document {
author?: { type: Schema.Types.ObjectId, ref: string, },
partner?: { type: Schema.Types.ObjectId, ref: string, },
lastMessage?: { type: Schema.Types.ObjectId, ref: string, },
}
export default model<IDialog>('Dialog', new... | 66 | 390 | null | 5086265891692886 |
0neKill/chat_react_with_mongoDB | no_license | .status {
display: inline-block;
color: #dfdfdf;
position: relative;
&::before {
top: 6px;
left: -11px;
display: block;
position: absolute;
content: '';
width: 6px;
height: 6px;
border-radius: 30px;
background-color: #d3d3d3;
}
&--online {
&::before {
backgrou... | 39 | 187 | null | 6680012810455948 |
0neKill/chat_react_with_mongoDB | no_license | .avatar {
border-radius: 50%;
height: 100%;
width: 100%;
&--symbol {
color: #FFFFFF;
font-weight: 600;
font-size: 18px;
text-align: center;
line-height: 38px;
}
} | 22 | 93 | null | 9479740116102215 |
0neKill/chat_react_with_mongoDB | no_license | import express from 'express';
import dotenv from 'dotenv';
import {createServer} from 'http';
import DataBase from './core/db';
import createRoutes from "./core/routes";
import createSocket from './core/socket';
const app = express();
const http = createServer(app);
const io = createSocket(http);
createRoutes(app,... | 56 | 355 | null | 7547848269388827 |
0neKill/chat_react_with_mongoDB | no_license | .auth {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
&__success-block {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
text-align: center;
height: 400px;
h2 {
margin-top: 10px;
font-size: 22px;
... | 108 | 527 | null | 5950834521327696 |
0neKill/chat_react_with_mongoDB | no_license | import express from 'express';
import socket from "socket.io";
import {DialogSchema, MessageSchema} from '../models';
export default class DialogController {
io: socket.Server;
constructor(io: socket.Server) {
this.io = io
}
index = (req: any, res: express.Response): void => {
const... | 186 | 1,052 | null | 7357095172342152 |
0neKill/chat_react_with_mongoDB | no_license | @import "../../styles/variables";
.dialogs {
&-search {
padding: 2px 20px 20px 20px;
.ant-input-search {
height: 38px;
padding: 4px 11px 6px;
}
span, input {
background-color: #f7f8f9;
border: 0;
&::before {
border-left: 0;
}
}
}
&__item {
$... | 213 | 887 | null | 5314463076317363 |
0neKill/chat_react_with_mongoDB | no_license | .button {
height: 56px !important;
&--large {
}
} | 9 | 28 | null | 5321134929821904 |
0neKill/chat_react_with_mongoDB | no_license | import bcrypt from 'bcrypt';
export default (password: string = '') => {
return new Promise((resolve, reject) => {
bcrypt.hash(password, 10)
.then((hash) => resolve(hash))
.catch((err) => reject(err))
})
} | 28 | 132 | null | 4666111037496349 |
0neKill/chat_react_with_mongoDB | no_license | import jwt from 'jsonwebtoken';
import {IUser} from '../models/User'
export default (token: string) => {
return new Promise((resolve, reject) => {
jwt.verify(token, process.env.JWT_SECRET || "", (err, date) => {
if (err || !date) return reject(err);
return resolve(date);
})
... | 39 | 184 | null | 3092470196737351 |
0neKill/chat_react_with_mongoDB | no_license | import React, {useEffect, useState} from "react";
import {connect} from 'react-redux';
import {Empty} from 'antd';
import socket from "../core/socket";
import {Dialogs as BaseDialogs} from '../components';
import {dialogsActions} from '../redux/actions';
import {useLocation} from "react-router-dom";
const Dialogs = (... | 135 | 1,155 | null | 7767314423739971 |
0neKill/chat_react_with_mongoDB | no_license | import React, {useEffect} from "react";
import {Upload, Modal} from 'antd';
function getBase64(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = error => rejec... | 150 | 963 | null | 3284037334802836 |
0neKill/chat_react_with_mongoDB | no_license | import bodyParser from "body-parser";
import express from 'express';
import path from 'path';
import {UserController, UploadController, DialogController, MessageController} from "../controllers";
import {checkAuth, updateLastSeen} from '../middlewares';
import {loginValidation, registerValidation} from '../utils/valid... | 124 | 1,433 | null | 1411868923220690 |
0neKill/chat_react_with_mongoDB | no_license | import React from 'react';
import {Form, Input} from "antd";
import {validateField} from "../../utils/helpers";
const FromField = ({touched, errors, handleChange, handleBlur, prefix, placeholder, id,type}) => {
return (
<Form.Item
validateStatus={validateField(id, touched, errors)}
... | 51 | 364 | null | 6331272987811455 |
0neKill/chat_react_with_mongoDB | no_license | .add-dialog-form {
.ant-form-item {
margin-bottom: 5px;
&-label {
line-height: inherit !important;
}
}
} | 14 | 69 | null | 4763349576853466 |
0neKill/chat_react_with_mongoDB | no_license | import mongoose from "mongoose";
export default mongoose.connect(
"mongodb://localhost:27017/chat",
{
useUnifiedTopology: true,
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
},
(err: any) => {
if (err) {
throw Error(err);
... | 30 | 178 | null | 7917746002796780 |
0neKill/chat_react_with_mongoDB | no_license | import multer, {diskStorage} from 'multer';
const storage = diskStorage({
destination: (req: any, file: any, callback: any) => {
callback(null, 'temp/upload')
},
filename: (req: any, file: any, callback: any) => {
callback(null, new Date().toISOString().replace(/:/g, '-') + '-' + file.ori... | 74 | 396 | null | 9696149267558014 |
0neKill/chat_react_with_mongoDB | no_license | import React from "react";
import readeSvg from "../../assets/img/readed.svg";
import noReade from "../../assets/img/noreaded.svg";
const IconReaded = ({isMe = false, isReaded}) => {
return (
(isMe && isReaded) ?
(<img className='message__icon-reade' src={readeSvg} alt="reader Icon"/>) :
... | 49 | 299 | null | 4525706863416104 |
0neKill/chat_react_with_mongoDB | no_license | NODE_ENV=development
PORT=3003
JWT_SECRET=HelloWorld
JWT_MAX_AGE="1 days" | 5 | 54 | null | 9211190962597406 |
0neKill/chat_react_with_mongoDB | no_license | import {Schema, model, Document} from 'mongoose';
interface IMessage extends Document {
dialog?: { type: Schema.Types.ObjectId, ref: string, };
text?: { type: string };
isRead?: boolean;
attachments?: [{ type: Schema.Types.ObjectId, ref: string }]
}
export default model<IMessage>('Message', new Sche... | 81 | 441 | null | 6409207733813352 |
0neKill/chat_react_with_mongoDB | no_license | import React from 'react';
import {FormOutlined, TeamOutlined} from "@ant-design/icons";
import {Button, Modal, Form, Select,} from "antd";
import TextArea from "antd/es/input/TextArea";
import './SideBar.scss';
import {Dialogs} from "../../containers";
const Sidebar = ({
userData,
... | 156 | 1,263 | null | 7825764122828912 |
0neKill/chat_react_with_mongoDB | no_license | export {default as UserSchema} from './User';
export {default as MessageSchema} from './Message';
export {default as DialogSchema} from './Dialog';
export {default as UploadedFileSchema} from './UploadedFile'; | 24 | 158 | null | 2675367710320838 |
0neKill/chat_react_with_mongoDB | no_license | import express from 'express';
import {UserSchema} from '../models'
export default async (req: any, res: express.Response, next: express.NextFunction) => {
if (req.user) {
await UserSchema.findOneAndUpdate({_id: req.user._id}, {last_seen: new Date()});
}
next();
} | 31 | 185 | null | 0371772341212305 |
0neKill/chat_react_with_mongoDB | no_license | {
"name": "chat-backend",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "ts-node src/index.ts",
"nodemon": "nodemon --exec ts-node src/index.ts"
},
"author": "",
"license": "ISC",
"dependencies": {
"@types/multer": "^1.4.4",
"@types/passport": "^1.0.4... | 85 | 409 | null | 5557940609613188 |
0neKill/chat_react_with_mongoDB | no_license | import React from "react";
import {Form} from "antd";
import {Link} from "react-router-dom";
import {UserOutlined, LockOutlined, MailOutlined, InfoCircleOutlined} from '@ant-design/icons';
import {Block, Button} from "../../../components";
import {FromField} from "../../../components";
const RegisterForm = (props) =... | 167 | 1,473 | null | 2497925738198035 |
0ss/MakelifeEasier | no_license | # @author = Salah
# My Fancy project
#
# your repo name
REPO = MakelifeEasier
# your account or org name
ACCOUNT = 0ss
#
# git commands
#
pull:
git pull https://github.com/${ACCOUNT}/${REPO}
push:
git push
i:
git init
c: # short cut for commit. make c="first commit"
git add .
git commit -m "$n"
branch: #... | 115 | 448 | null | 0048062810696872 |
0ss/MakelifeEasier | no_license | Right now I just added some basic silly commands 😎
I'm planning an'shalah to add more commands and document them.
How to use those commands ?
*you need to install `make` command in your machine*
- Windows
`choco install make`
- Ubunto
`sudo apt-get -y install make`
Then, add the Makefile file in your project roo... | 60 | 254 | null | 3726585015296560 |
0umot/ALFAALTYAPI | no_license | const Discord = require("discord.js");
const db = require('quick.db');
const ayarlar = require('../ayarlar.json')
module.exports.run = async (client, message, args) => {
if (!message.guild) {
return }
let kullanıcı = await db.fetch(`gold_${message.author.id}`);
if( kullanıcı == undefined){
message.channel.send... | 119 | 812 | null | 2765194164828341 |
0umot/ALFAALTYAPI | no_license | const Discord = require('discord.js');
exports.run = async (client, message, args) => {
message.channel.send(new Discord.MessageEmbed()
.setThumbnail(message.author.avatarURL() ? message.author.avatarURL({dynamic: true}) : 'https://cdn.glitch.com/8e70d198-9ddc-40aa-b0c6-ccb4573f14a4%2F6499d2f1c46b106eed1e25892568aa55... | 64 | 601 | null | 4418502164172153 |
0umot/ALFAALTYAPI | no_license | const Discord = require('discord.js');
const data = require('quick.db');
exports.run = async (client, message, args) => {
Array.prototype.random = function() {
return this[Math.floor(Math.random() * this.length)];
}
let images = ['https://topg.org/image/461120/412323.gif', 'https://topg.org/image/461120/41232... | 155 | 954 | null | 9893449872470865 |
0umot/ALFAALTYAPI | no_license | const reqEvent = (event) => require(`../events/${event}`);
module.exports = client => {
client.on('arroiz', () => reqEvent('arroiz')(client));
client.on('message', reqEvent('message'));
}; | 18 | 119 | null | 5711767216193533 |
0umot/ALFAALTYAPI | no_license | # Environment Config
# store your secrets and config variables in here
# only invited collaborators will be able to see your .env values
# Note: comments will be visible to remixes so don't put secrets in comments!
# reference these in your code with process.env.SECRET
# note: .env is a shell file so there can't be... | 85 | 342 | null | 3043258035307662 |
0w0www/CodeDeployGitHubDem | no_license | {"nbformat": 4, "nbformat_minor": 0, "metadata": {"colab": {"provenance": [], "authorship_tag": "ABX9TyMR4Ubn12ONWGUTU8j7kX6q", "include_colab_link": true}, "kernelspec": {"name": "python3", "display_name": "Python 3"}, "language_info": {"name": "python"}}, "cells": [{"cell_type": "markdown", "metadata": {"id": "view-i... | 48 | 449 | null | 1148249634299884 |
0x3af72/random-dot-stereogram | no_license | #include <iostream>
#include <vector>
#include <random>
#include <SDL2/include/SDL2/SDL.h>
#define DOT_SIZE 4
#define SCREEN_WIDTH (DOT_SIZE * 120) // each frame is 120 pixels wide
#define SCREEN_HEIGHT (DOT_SIZE * 200) // each frame is 200 pixels tall
// random boolean generator for generating dots
std::... | 437 | 1,786 | null | 1780505986169797 |
0xAF/bg-repeaters-worker | no_license | #!/usr/bin/perl
use JSON;
use DDP;
use DBIx::Simple;
binmode(STDOUT, ":encoding(UTF-8)");
binmode(STDERR, ":encoding(UTF-8)");
my $json;
open(my $fh, '<', "reps.json") or die "cannot open file reps.json";
{ local $/; $json = <$fh>; }
close($fh);
my $db = DBIx::Simple->connect('dbi:SQLite:dbname=reps.db', { RaiseErro... | 337 | 1,017 | null | 4967897026332289 |
0xAF/bg-repeaters-worker | no_license | {
"name": "repeaters-varna-radio",
"scripts": {
"dev": "wrangler dev",
"deploy": "wrangler deploy --minify",
"cf-typegen": "wrangler types --env-interface CloudflareBindings",
"pages-dev": "run-p pages-dev:*",
"pages-dev:wrangler": "wrangler pages dev dist --live-reload",
"pages-dev:esbuild": "esbuild --b... | 68 | 474 | null | 6098370723767840 |
0xAF/bg-repeaters-worker | no_license | import { Hono } from 'hono'
import { basicAuth } from 'hono/basic-auth'
import { etag } from 'hono/etag'
import { poweredBy } from 'hono/powered-by'
import { logger } from 'hono/logger'
import { prettyJSON } from 'hono/pretty-json'
import { HTTPException } from "hono/http-exception"
import { swaggerUI } from '@hono/swa... | 508 | 2,225 | null | 5654649210803695 |
0xAF/bg-repeaters-worker | no_license | #!/bin/bash
rm -f reps.json
wget https://varna.radio/reps.json
sqlite3 reps.db < schema.sql
./convert_reps_json.pl
sqlite3 reps.db .schema > tmpschema.sql
sqlite3 reps.db .dump > tmpdump.sql
grep -vx -f tmpschema.sql tmpdump.sql > dump1.sql
grep -vP "^(PRAGMA|COMMIT|BEGIN)" dump1.sql > dump.sql
npx wrangler d1 execu... | 57 | 342 | null | 6857665498464466 |
0xAF/bg-repeaters-worker | no_license | /**
* For more details on how to configure Wrangler, refer to:
* https://developers.cloudflare.com/workers/wrangler/configuration/
*/
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "repeaters-varna-radio",
"main": "src/index.ts",
"compatibility_date": "2025-03-13",
"observability": {
"enable... | 159 | 1,164 | null | 8068024244124787 |
0xAF/bg-repeaters-worker | no_license | DROP TABLE IF EXISTS repeaters;
DROP TABLE IF EXISTS requests;
DROP TABLE IF EXISTS changelog;
CREATE TABLE
IF NOT EXISTS repeaters (
callsign TEXT NOT NULL PRIMARY KEY,
disabled INTEGER NOT NULL ON CONFLICT REPLACE DEFAULT 0,
keeper TEXT NOT NULL,
latitude NUMERIC(3, 8) NOT NULL,... | 276 | 1,417 | null | 4710456561119133 |
0xAF/bg-repeaters-worker | no_license | import { z } from '@hono/zod-openapi'
const ErrorSchema = z.object({
failure: z
.boolean()
.openapi({
description: "Indicates Operation Failure",
example: true,
}),
errors: z
.object({})
.openapi({
description: "The errors",
example: { "SQL": "Error in SQL" }
}),
... | 52 | 258 | null | 1166612242538003 |
0xCaFeBEef/PassingEventsToDescendantPagesReact | no_license | # PassingEventsToDescendantPagesReact
Created with CodeSandbox
| 5 | 57 | null | 3203940755537079 |
0xCaFeBEef/PassingEventsToDescendantPagesReact | no_license | import "./styles.css";
import NumberList from "./NumberList";
export default function App() {
return (
<div className="App">
<NumberList />
</div>
);
}
| 20 | 103 | null | 6888531588468404 |
0xCaFeBEef/PassingEventsToDescendantPagesReact | no_license | import React, { Component } from "react";
class ButtonList extends Component {
static defaultProps = {
colors: ["red", "blue", "yellow", "purple"]
};
constructor(props) {
super(props);
this.state = {
color: "green"
};
}
changeColor(newColor, e) {
console.log(`newColor... | 85 | 435 | null | 0938974568996506 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
import exceptions.*;
import price.*;
/**
* Represents the top price and volume for one side of a market.
* @author <NAME>
* @see CurrentMarketObserver
* @see CurrentMarketTracker
* @see CurrentMarketPublisher
* @see Price
* @see PriceFactory
*/
public class CurrentMarketSide {
/**
... | 163 | 759 | null | 9899842188702753 |
0xD3caf/SE450_object-oriented_programming | no_license | //<NAME>
// CSEC 450
package price;
import homework2.InvalidPriceException;
import java.util.HashMap;
public abstract class PriceFactory {
private static final HashMap<Integer, Price> priceHistory = new HashMap<Integer, Price>();
public static Price makePrice (int i) {
// Flyweight pattern to conser... | 314 | 1,783 | null | 2676507709290217 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
import exceptions.DataValidationException;
import exceptions.InvalidUserException;
import java.util.TreeMap;
/**
* Facade class for User. Handles the creation and management of User objects.
* @author <NAME>
* @see User
*/
public class UserManager {
/**
* private instance of class fo... | 532 | 2,581 | null | 2070041727443984 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
import price.Price;
public record TradableDTO(String user, String product, Price price, int originalVolume, int remainingVolume, int cancelledVolume, int filledVolume, BookSide side,String tradableId, String representation) {
public TradableDTO (Tradable trade) {
this(trade.getUser(),
... | 51 | 448 | null | 7098544979561562 |
0xD3caf/SE450_object-oriented_programming | no_license | package exceptions;
public class InvalidVolumeException extends Exception {
public InvalidVolumeException(String s) {
}
}
| 14 | 101 | null | 1946675859156684 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
import price.Price;
public class Order implements Tradable {
// User - 3 letter code, no space, no num, no special
final String user;
// 1-5 chars, alphaNum, may contain period -- No space, no special
private final String product, id;
private final Price price;
private fina... | 292 | 1,925 | null | 8671992871671603 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
public enum BookSide {
BUY,
SELL;
}
| 9 | 40 | null | 9475964641102306 |
0xD3caf/SE450_object-oriented_programming | no_license | //<NAME>
// CSEC 450
package trading;
public abstract class PriceFactory {
public static Price makePrice (int i) {
return new Price(i);
}
public static Price makePrice (String stringValueIn) throws InvalidPriceException {
// Check for empty and null inputs
if (stringValueIn.is... | 272 | 1,476 | null | 1526031913714775 |
0xD3caf/SE450_object-oriented_programming | no_license | //<NAME>
// CSEC 450
package price;
import homework2.InvalidPriceException;
import java.util.Comparator;
import java.util.Objects;
public class Price implements Comparable<Price>, Comparator<Price> {
private final int value;
Price (int input) {
value = input;
}
public boolean isNegative ()... | 249 | 1,413 | null | 7972040609460443 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
import price.*;
/**
* Singleton class that takes updates from product books and forwards info to market publisher.
* @author <NAME>
* @see CurrentMarketPublisher
* @see CurrentMarketSide
* @see Price
* @see ProductBook
*/
public class CurrentMarketTracker {
private static CurrentMarketTr... | 289 | 1,587 | null | 9203069623539110 |
0xD3caf/SE450_object-oriented_programming | no_license | //<NAME>
// CSEC 450
package homework2;
public class InvalidPriceException extends Exception{
public InvalidPriceException() {
}
public InvalidPriceException (String msg) {
super(msg);
}
}
| 23 | 142 | null | 6191598017549252 |
0xD3caf/SE450_object-oriented_programming | no_license | //<NAME>
// CSEC 450
package price;
import exceptions.DataValidationException;
import java.util.Comparator;
import java.util.Objects;
/**
* Price class representing a single cost value. Price is stored in cents and converted back when needed.
* @author <NAME>
* @see PriceFactory
*/
public class Price implements ... | 730 | 3,468 | null | 7148782111967151 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
import price.Price;
public interface Tradable {
String getId ();
int getRemainingVolume ();
void setRemainingVolume (int newVol);
int getCancelledVolume ();
void setCancelledVolume (int newVol);
int getFilledVolume ();
void setFilledVolume (int newVol);
TradableDTO ... | 53 | 332 | null | 4072965235688582 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
import price.Price;
public record TradableDTO(String user, String product, Price price, int originalVolume, int remainingVolume, int cancelledVolume, int filledVolume, BookSide side,String tradableId, String representation) {
public TradableDTO (Tradable trade) {
this(trade.getUser(),
... | 131 | 910 | null | 0887220247490731 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
/**
* Interface for market observers
* @author <NAME>
* @see User
* @see CurrentMarketSide
* @see CurrentMarketTracker
* @see CurrentMarketPublisher
*/
public interface CurrentMarketObserver {
public void updateCurrentMarket(String symbol, CurrentMarketSide buySide, CurrentMarketSide sel... | 37 | 253 | null | 6759984683322623 |
0xD3caf/SE450_object-oriented_programming | no_license | //<NAME>
// CSEC 450
package trading;
public class InvalidPriceException extends Exception{
public InvalidPriceException() {
}
public InvalidPriceException (String msg) {
super(msg);
}
}
| 23 | 141 | null | 1801672590174910 |
0xD3caf/SE450_object-oriented_programming | no_license | package exceptions;
public class DataValidationException extends Exception {
public DataValidationException(String e) {
}
}
| 14 | 103 | null | 0434530820666356 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
import exceptions.InvalidUserException;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Represents a single user who may buy or sell tradables. Each user is represented by a 3 letter code and maintains a list of all trades it has taken part in.
* @author <NAME>
* @see UserManager
*/... | 412 | 2,192 | null | 0874873130500196 |
0xD3caf/SE450_object-oriented_programming | no_license | //<NAME>
// CSEC 450
package trading;
import java.util.Objects;
public class Price {
private final int value;
public Price (int input) {
value = input;
}
public boolean isNegative () {
return (value < 0);
}
public Price add (Price p) throws InvalidPriceException {
v... | 227 | 1,191 | null | 4593903553441777 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
import exceptions.*;
import price.Price;
/**
* Special helped class to handle validating inputs that update orders. This applies to many classes and will test Symbols, users, volumes, prices, and book sides.
* Each throws a different error with specific message text to allow more detailed error l... | 403 | 2,363 | null | 8215619963933991 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
import exceptions.DataValidationException;
import exceptions.InvalidVolumeException;
import price.Price;
/**
* Represents a single buy or sell order.
* @author <NAME>
* @see Price
* @see Tradable
*/
public class Order implements Tradable {
// User - 3-letter code, no space, no num, no spe... | 478 | 3,020 | null | 1925491012248425 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
import price.Price;
public class QuoteSide implements Tradable{
private final String user, product;
private final Price price;
private final int originalVolume;
private final String id;
private final BookSide side;
public int remainingVolume, filledVolume, cancelledVolume;
... | 260 | 1,778 | null | 1828349829525737 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
import exceptions.InvalidUserException;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Represents a single user who may buy or sell tradables. Each user is represented by a 3 letter code and maintains a list of all trades it has taken part in.
* @author <NAME>
* @see UserManager
* ... | 562 | 3,135 | null | 7775006078469106 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
import price.Price;
public class Validators {
public static void validateUserName(String userName) {
if (!userName.matches("[a-zA-Z]{3}")) {
throw new IllegalArgumentException("invalid user name");
}
}
public static void validateSymbol(String symbol) {
... | 161 | 1,060 | null | 7862965973106116 |
0xD3caf/SE450_object-oriented_programming | no_license | //<NAME>
// CSEC 450
package exceptions;
public class InvalidPriceException extends Exception{
public InvalidPriceException() {
}
public InvalidPriceException (String msg) {
super(msg);
}
}
| 23 | 144 | null | 9214074203186560 |
0xD3caf/SE450_object-oriented_programming | no_license | package price;
import exceptions.InvalidPriceException;
import java.util.HashMap;
/**
* Generates price objects on demand. Utilizes a flyweight pattern to reuse price objects.
* @author <NAME>
* @see Price
*/
public abstract class PriceFactory {
/**
* Stores all previously created price objects to faci... | 578 | 2,972 | null | 3658806653516890 |
0xD3caf/SE450_object-oriented_programming | no_license | package exceptions;
public class InvalidBookSideException extends Exception {
public InvalidBookSideException(String sideCannotBeNull) {
}
}
| 14 | 120 | null | 5582286713646537 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
import exceptions.DataValidationException;
import price.Price;
/**
* Represents a customer order that contains both buy and sell requests.
* @author <NAME>
* @see QuoteSide
* @see Price
* @see Tradable
*/
public class Quote {
/**
* 3 Character String used to identify customer. Must ... | 370 | 1,806 | null | 6654031876749982 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
import exceptions.DataValidationException;
import price.Price;
public interface Tradable {
String getId ();
int getRemainingVolume ();
void setRemainingVolume (int newVol) throws DataValidationException;
int getCancelledVolume ();
void setCancelledVolume (int newVol) throws Data... | 74 | 542 | null | 3239210811523642 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
import price.Price;
import price.PriceFactory;
public class ProductBook {
final String product;
final ProductBookSide buySide, sellSide;
ProductBook(String symbol) {
// Check if symbol is valid
Validators.validateSymbol(symbol);
product = symbol;
buySide... | 378 | 2,512 | null | 1657966474995459 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Maintains a list of observers and publishes market updates based on observer interest. Singleton using the observer pattern.
* @author <NAME>
* @see CurrentMarketObserver
* @see CurrentMarketTracker
* @see CurrentMarketPublisher
*/
p... | 252 | 1,545 | null | 9439529125319403 |
0xD3caf/SE450_object-oriented_programming | no_license | package homework2;
import price.Price;
public class Quote {
private final String user, product;
private final QuoteSide buySide,sellSide;
public Quote (String symbol, Price buyPrice, int buyVolume, Price sellPrice, int sellVolume, String userName) {
//Constructor
Validators.validateQuoteIn... | 96 | 600 | null | 3957929622092988 |
0xKaiFu/Config-System | no_license | #pragma once
template <typename T>
class MutexLock {
private:
bool* isLockedPtr;
public:
T* data;
MutexLock(bool* lockPtr, T* _data) {
isLockedPtr = lockPtr;
data = _data;
}
~MutexLock() {
*isLockedPtr = false;
}
};
class Mutex {
private:
bool isLocked = false;
public:
MutexLock<void> lock()
{
while ... | 96 | 487 | null | 5539644699442550 |
0xKaiFu/Config-System | no_license | # Config System
A simple C++ config system using JSON (nlohmann)
| 11 | 49 | null | 7390470800794762 |
0xKaiFu/Config-System | no_license | #include <iostream>
#include "Configsystem.h"
int main()
{
cfg::setSavePath("./", "test.json");
cfg::load();
auto context = cfg::getContext("testContext");
std::cout << "testValue: " << context->getValue<bool>("testValue", false) << std::endl;;
context->set<bool>("testValue", true);
std::c... | 41 | 256 | null | 1375558668815634 |
0xKaiFu/Config-System | no_license | #include "ConfigSystem.h"
#include <string>
std::string CFG::savePath = {};
std::string CFG::saveFileName = {};
ConfigContext CFG::mainContext = ConfigContext(true,"main");
std::unordered_map<std::string, ConfigContext*> CFG::configContexts = {}; | 21 | 179 | null | 9766315223471199 |
0xMichaelRan/sgGroceryCrawler | no_license | .bg {
background: url('/static/images/junbotron_bg.jpg')
repeat center center;
background-size: 100% auto;
position: fixed;
width: 100%;
height: 100%;
/*same height as jumbotron */
top: 0;
left: 0;
z-index: -1;
}
.jumbotron {
margin-bottom: 0px;
height: 350p... | 44 | 218 | null | 3605563686286398 |
0xMichaelRan/sgGroceryCrawler | no_license | from local import *
import json
from tornado import ioloop,web
import pymongo
from bson import json_util
from bson.objectid import ObjectId
# Mongo setting
connection = pymongo.MongoClient(MONGODB_SERVER, MONGODB_PORT)
db = connection.sg_grocery
items = db.table
class ItemHandler(web.RequestHandler):
def get(... | 185 | 924 | null | 1617057750551416 |
0xMichaelRan/sgGroceryCrawler | no_license | import scrapy
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import CrawlSpider, Rule
from sgGroceryCrawler.items import SggrocerycrawlerItem
class GiantSpider(CrawlSpider):
name = "giant_spider"
allowed_domains = ["giantonline.com.sg"]
start_urls = ['https://giantonline.com.sg/... | 106 | 981 | null | 3581360495037229 |
0xMichaelRan/sgGroceryCrawler | no_license | import scrapy
import json
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import CrawlSpider, Rule
from scrapy.http import FormRequest
from sgGroceryCrawler.items import SggrocerycrawlerItem
class ColdSpider(CrawlSpider):
name = "cold_spider"
allowed_domains = ["www.coldstorage.com.sg"]
... | 227 | 1,665 | null | 0626398754727716 |
0xMichaelRan/sgGroceryCrawler | no_license | # -*- coding: utf-8 -*-
# Define here the models for your scraped items
#
# See documentation in:
# http://doc.scrapy.org/en/latest/topics/items.html
import scrapy
class SggrocerycrawlerItem(scrapy.Item):
title = scrapy.Field()
brand = scrapy.Field()
quantity = scrapy.Field()
unit = scrapy.Fiel... | 138 | 673 | null | 3912722086825764 |
0xMichaelRan/sgGroceryCrawler | no_license | import scrapy
from sgGroceryCrawler.items import SggrocerycrawlerItem
class FairSpider(scrapy.Spider):
name = "fair_spider"
allowed_domains = ["www.fairprice.com.sg"]
start_urls = [
"http://www.fairprice.com.sg/webapp/wcs/stores/servlet/CategoryDisplay?storeId=10001&urlRequestType=Base&pageVi... | 296 | 1,978 | null | 4774957520909021 |
0xMichaelRan/sgGroceryCrawler | no_license | {% extends "base.html" %}
{% block title %} {{page_title}} {% end %}
{% block body %}
<div class="container">
<div class="row">
<div id="selector" class="btn-group btn-group-lg pull-right" role="group" aria-label="Large button group">
<button id="sortNameButton" type="button" class="btn btn-default" onclick="loca... | 171 | 1,209 | null | 9035198752102810 |
0xMichaelRan/sgGroceryCrawler | no_license | import os
from tornado import ioloop,web
from pymongo import MongoClient
import json
from search import SearchHandler
from search import ItemHandler
class IndexHandler(web.RequestHandler):
def get(self):
self.render("index.html", title="My title")
settings = {
"template_path": os.path.join(os.path.d... | 64 | 487 | null | 4374631061772381 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.