Skip to content

Instantly share code, notes, and snippets.

View petrosDemetrakopoulos's full-sized avatar

Petros Demetrakopoulos petrosDemetrakopoulos

View GitHub Profile
@petrosDemetrakopoulos
petrosDemetrakopoulos / pandas_categorical_2.py
Created September 17, 2022 23:36
Pandas categorical column as category
df['color'] = df['color'].astype('category')
print(df.info(memory_usage="deep"))
@petrosDemetrakopoulos
petrosDemetrakopoulos / pandas_categorical_1.py
Created September 17, 2022 23:31
Pandas categorical column as object
import pandas as pd
import random
colors = ['WHITE', 'BLACK','RED','YELLOW','BLUE','GREEN']
colors_column = [random.choice(colors) for x in range(1000)]
df = pd.DataFrame({'color':colors_column})
print(df.info(memory_usage="deep"))
from ethairballoons.ethairballoons import ethairBalloons
prov = ethairBalloons('127.0.0.1', '..')
carSchema = prov.createSchema(modelDefinition={
'name': "Car",
'contractName': "carsContract",
'properties': [{
'name': "model",
'type': "bytes32",
@petrosDemetrakopoulos
petrosDemetrakopoulos / interfaceExample.tsx
Created June 30, 2022 15:35
Example of custom TS interface
interface Options {
color: string;
volume: number;
}
@petrosDemetrakopoulos
petrosDemetrakopoulos / webpack.config.js
Last active June 30, 2022 15:21
Webpack config example
const path = require('path');
module.exports = {
entry: './src/index.ts',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
@petrosDemetrakopoulos
petrosDemetrakopoulos / tsconfig.json
Last active June 30, 2022 15:22
Example tsconfig.json file
{
"compilerOptions": {
"outDir": "./dist/",
"noImplicitAny": true,
"sourceMap": true,
"module": "es6",
"target": "es5",
"jsx": "react",
"allowJs": true,
"moduleResolution": "node"
import React from 'react'
import './App.css'
import { ToastContainer, toast } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
function App() {
const notifyDefault = () => toast("A toast alert!");
const notifyTimeout = () => toast("Dismiss after 8 secs", {autoClose: 8000});
const notifyTopLeft = () => toast("This appears on top left corner", {position: 'top-left'});
const notifyNotBar = () => toast("This does not have the bar", {hideProgressBar: true});
@petrosDemetrakopoulos
petrosDemetrakopoulos / react-toasts-app.tsx
Last active May 14, 2022 17:02
React toasts App.tsx
import React from 'react'
import './App.css'
import { ToastContainer, toast } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
function App() {
const notifyDefault = () => toast("A toast alert!");
return (
<div className="App">
<div style={{ marginTop: '2em' }}>
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "jest",
"eject": "react-scripts eject"
}
module.exports = {
presets: [
['@babel/preset-env', {targets: {node: 'current'}}],
'@babel/preset-typescript',
],
};