Skip to content

Instantly share code, notes, and snippets.

View AD0791's full-sized avatar
🎯
Focusing

Alexandro Disla AD0791

🎯
Focusing
View GitHub Profile
@AD0791
AD0791 / write_your_first_app.dart
Created March 31, 2024 06:02 — forked from Andrious/write_your_first_app.dart
Write Your First App example using both the Marterial design or the Cupertino design.
import 'dart:io' show Platform;
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:english_words/english_words.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
@AD0791
AD0791 / c_sharp_for_python.md
Created January 13, 2023 15:53 — forked from mrkline/c_sharp_for_python.md
An intro to C# for a Python developer. Made for one of my coworkers.

C# For Python Programmers

Syntax and core concepts

Basic Syntax

  • Single-line comments are started with //. Multi-line comments are started with /* and ended with */.

  • C# uses braces ({ and }) instead of indentation to organize code into blocks. If a block is a single line, the braces can be omitted. For example,

@AD0791
AD0791 / c_sharp_for_python.md
Created January 13, 2023 15:53 — forked from mrkline/c_sharp_for_python.md
An intro to C# for a Python developer. Made for one of my coworkers.

C# For Python Programmers

Syntax and core concepts

Basic Syntax

  • Single-line comments are started with //. Multi-line comments are started with /* and ended with */.

  • C# uses braces ({ and }) instead of indentation to organize code into blocks. If a block is a single line, the braces can be omitted. For example,

@AD0791
AD0791 / api_version.py
Created March 18, 2022 15:36
advanced_fastapi
from fastapi import FastAPI
apiv1 = FastAPI()
@apiv1.get('/returnName')
def index():
return {"Name": "Kaustubh demo"}
#################
@AD0791
AD0791 / Bad.py
Last active February 21, 2022 16:21
RabbitMQ service. The publisher doesn't need to declare exchange, queue and do the binding
from models.item import Item
from json import dumps
from pika import (
BlockingConnection,
ConnectionParameters,
BasicProperties
)
async def register_item_service(item:dict)->Item:
from typing import Optional
import base64
from passlib.context import CryptContext
from datetime import datetime, timedelta
import jwt
from jwt import PyJWTError
from pydantic import BaseModel
@AD0791
AD0791 / fish.md
Created October 20, 2021 05:16
Fish setup

Installation

Install via homebrew and set fish as default shell.

brew install fish
echo /usr/local/bin/fish | sudo tee -a /etc/shells
chsh -s (which fish)

To go back to zsh: do chsh -s (which zsh).

@AD0791
AD0791 / main.py
Created October 12, 2021 18:49
function composition
import functools
def compose(*functions):
return functools.reduce(lambda f, g: lambda x: f(g(x)), functions)
# dec double inc are given function
>>> inc_double_and_dec = compose(dec, double, inc)
@AD0791
AD0791 / Middleware.js
Created September 25, 2021 22:09
Redux simplification
/*
Middlewares provide us with the ability to intercept actions and do something we want to before that action reaches the reducers. We can log actions, log store state, log crash reports, etc.
Let's create a middleware for logging actions when they get dispatched.
*/
const logger = (store) => (next) => (action) => {
console.log("DISPATCHED ACTION: ", action);
next(action);
}
@AD0791
AD0791 / redux.js
Last active September 20, 2021 02:19
redux
const INCREMENT = "INCREMENT"; // define a constant for increment action types
const DECREMENT = "DECREMENT"; // define a constant for decrement action types
// define the counter reducer which will increment or decrement the state based on the action it receives
const counterReducer = (state = 0, action) => {
switch (action.type) {
case INCREMENT:
return state + 1;
case DECREMENT: