Skip to content

Instantly share code, notes, and snippets.

View afrinjamanbd's full-sized avatar
🔆
Google Summer of Code Winner 2019

Afrin Jaman afrinjamanbd

🔆
Google Summer of Code Winner 2019
View GitHub Profile
@afrinjamanbd
afrinjamanbd / djangoadminmodel.py
Last active January 19, 2023 10:28
django admin model
from django.contrib.auth.models import User
from django.db import models
from django.utils import timezone
class Catagory(models.Model):
title = models.CharField(max_length=100)
def __str__(self):
return self.title
@afrinjamanbd
afrinjamanbd / Wrong_Method_Chain.py
Last active June 18, 2022 14:47
Wrong_Method_Chain.
class Calculator():
def __init__(self, variable):
self.variable = variable
def add(self, adition):
total = self.variable + adition
print(total)
print ("Calculator.add() function called")
return total
def gviz_json(desc, model_class, columns, orderby, dist, **filt):
ret = model_class.objects.all().values(*columns).filter(**filt).order_by(orderby)
return ret
@afrinjamanbd
afrinjamanbd / method_chaining_calc.py
Last active June 18, 2022 16:00
Calculator with Method chaining in Python
class Calculator():
def __init__(self, variable):
self.variable = variable
def add(self, adition):
self.variable = self.variable + adition
print(self.variable)
print ("Calculator.add() function called")
return self
@afrinjamanbd
afrinjamanbd / Method Chaining in python.py
Last active June 18, 2022 15:35
Method Chaining example in python
class Calculator():
def __init__(self, variable):
self.variable = variable
def add(self, adition):
total = self.variable + adition
print(total)
print ("Calculator.add() function called")
self.variable = total
@afrinjamanbd
afrinjamanbd / JSON value with single quote
Last active June 12, 2022 15:27
JSON value with single quote error fixed
var json = '{"1440167924916":{"id":1440167924916,"type":"text","content":"It\'s a test!"}}';
var parsed = JSON.parse(json);
@afrinjamanbd
afrinjamanbd / unexpected token ' in JSON at position
Created June 10, 2022 04:59
unexpected token ' in JSON at position while Json parsing
let a;
const x = `{
'quotes':
[
{
'id':1,
'quote':'Life isn’t about getting and having, it’s about giving and being.',
'author':'Kevin Kruse'
},
{
@afrinjamanbd
afrinjamanbd / Multiple Request Sender.py
Created June 5, 2022 07:16
Multiple Request Sender
# import requests module
import requests
# Making a get request
response = requests.get('https://medex.com.bd/search?search=Maxpro')
# print response
print(response)
# print json content
@afrinjamanbd
afrinjamanbd / gviz_api_django.py
Created December 2, 2021 15:11
Simple example to use gviz_api with Django Models
import gviz_api
description = {"name": ("string", "Name"),
"salary": ("number", "Salary"),
"full_time": ("boolean", "Full Time Employee")}
data = [{"name": "Mike", "salary": (10000, "$10,000"), "full_time": True},
{"name": "Jim", "salary": (800, "$800"), "full_time": False},
{"name": "Alice", "salary": (12500, "$12,500"), "full_time": True},
{"name": "Bob", "salary": (7000, "$7,000"), "full_time": True}]
@afrinjamanbd
afrinjamanbd / goCheatSheet.go
Last active February 6, 2021 10:17
go cheat sheet
package main
import (
"fmt"
"strconv"
"github.com/afrinjamanbd/firstapp/help"
)
var (