Skip to content

Instantly share code, notes, and snippets.

View ajinzrathod's full-sized avatar
🏠
Working from home

Ajinkya Rathod ajinzrathod

🏠
Working from home
View GitHub Profile
@ajinzrathod
ajinzrathod / admin.py
Created November 13, 2024 05:40
This code snippet demonstrates how to create custom actions in Django Admin to perform bulk updates on selected records. Specifically, it includes actions to mark users as active or inactive by updating the is_active field. These actions are integrated into the admin dropdown menu, allowing for efficient management of multiple records at once.
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from .models import Account
from django.utils.translation import ngettext
from django.contrib import messages
class UserAdmin(admin.ModelAdmin):
actions = ('mark_as_active', 'mark_as_inactive') # Add your actions here
list_display = (
@ajinzrathod
ajinzrathod / sealed_class.dart
Last active October 19, 2024 16:22
sealed class without exhaustively matched
sealed class LoginState {}
class LoginLoadingState extends LoginState{}
class LoginSuccessState extends LoginState{}
class LoginFailureState extends LoginState{}
class LoginRedirectState extends LoginState{}
void handleLoginState(LoginState state) {
switch(state) {
case LoginLoadingState():
@ajinzrathod
ajinzrathod / login_state_2.dart
Last active October 19, 2024 16:23
Abstract Class example
abstract class LoginState {}
class LoginLoadingState extends LoginState{}
class LoginSuccessState extends LoginState{}
class LoginFailureState extends LoginState{}
class LoginRedirectState extends LoginState{} // added now
void handleLoginState(LoginState state) {
switch(state) {
case LoginLoadingState():
@ajinzrathod
ajinzrathod / login_state.dart
Created October 19, 2024 15:46
Abstract Class example
abstract class LoginState {}
class LoginLoadingState extends LoginState{}
class LoginSuccessState extends LoginState{}
class LoginFailureState extends LoginState{}
void handleLoginState(LoginState state) {
switch(state) {
case LoginLoadingState():
print('Logging in...'); // Handle loading state
@ajinzrathod
ajinzrathod / Website.dart
Created September 12, 2024 05:33
Comparing Objects in Dart
class Website {
  const Website(this.url);
final String url;
}
void main() {
  final Website website = Website("Stackoverflow");
  print(website == Website("Stackoverflow")); // Prints false
}
@ajinzrathod
ajinzrathod / pandas_postgres.py
Created September 8, 2021 15:27 — forked from kunanit/pandas_postgres.py
Read postgres database table into pandas dataframe
import pandas as pd
from sqlalchemy import create_engine
# follows django database settings format, replace with your own settings
DATABASES = {
'production':{
'NAME': 'dbname',
'USER': 'user',
'PASSWORD': 'pass',
'HOST': 'rdsname.clqksfdibzsj.us-east-1.rds.amazonaws.com',
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Inherited
@interface Deletable {
}
@Deletable
class Entity {
@ajinzrathod
ajinzrathod / UsingMarkerInterface.java
Last active July 28, 2021 06:42
Sharing Annotation Example
interface Deletable {
}
class Entity implements Deletable {
// implementation details
}
class ShapeDao extends Entity {
// other dao methods
public boolean delete(Object object) {
# Search "Startup Applications" in App launcher
# Under name: Auto Screenshot Taker
# Under Command: /usr/bin/python3 /home/ajinkya/Documents/Ajinkya/Freelancing/screenshots.py
# Under Comment: Auto Screenshot Taker
# Now the script
# import py auto gui
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
.inp-field {