This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python3 | |
| import socket | |
| import argparse | |
| import requests | |
| from random import sample | |
| from time import sleep, time | |
| from termcolor import colored | |
| from datetime import datetime | |
| from urllib.parse import urlparse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(function(){ | |
| $('.likeButton').click(function(){ | |
| let pk = this.id; | |
| $.ajax({ | |
| url: '/post/like/', | |
| type: 'POST', | |
| data: { | |
| pk: pk, | |
| }, | |
| success: function(data) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from post.models import Post | |
| from django.http import JsonResponse | |
| from django.views.generic import View | |
| from django.contrib.auth.mixins import LoginRequiredMixin | |
| class PostLikeView(LoginRequiredMixin, View): | |
| @staticmethod | |
| def get(request): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def expanded_form(num): | |
| number = list(str(num)) | |
| zeroes = len(number) - 1 | |
| last = number[-1] | |
| ans = [] | |
| for index, num in enumerate(number): | |
| if num == '0': | |
| zeroes -= 1 | |
| continue | |
| temp = "{} + ".format(int(num) * (10 ** zeroes)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <fstream> | |
| #include <iostream> | |
| #include <string.h> | |
| #include <sstream> | |
| #include <stdlib.h> | |
| #include <string> | |
| #include <unordered_map> | |
| using namespace std; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import OrderedDict | |
| def sort_model_fields(fields): | |
| print("BEFORE\n") | |
| print(fields) | |
| # creating a dictionary with key as length of string and value as the string itself | |
| dict_fields = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # inspiration - https://stackoverflow.com/a/2587513/7086106 | |
| # original - https://gist.github.com/mentix02/f1d545243b7eb37f7d033fc0735ec868#gistcomment-2754082 | |
| fields = """title = models.CharField(max_length=50) | |
| content = models.TextField() | |
| description = models.TextField(blank=True, null=True) | |
| thumbnail = models.ImageField(upload_to='post_thumbnails') | |
| draft = models.BooleanField(default=False) | |
| slug = models.SlugField(blank=True) | |
| author = models.CharField(max_length=30, default='mentix02', blank=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from random import shuffle | |
| data = list(range(1, 100)) | |
| shuffle(data) | |
| count = 0 | |
| while count != len(data): | |
| data[count] = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python3 | |
| from time import time | |
| from argparse import ArgumentParser | |
| __version__ = '1.0.0' | |
| parser = ArgumentParser(description='a simple collatz sequence solver') | |
| parser.add_argument('n', help='number', action='store', type=int) | |
| parser.add_argument('-t', '--time', help='show time taken', action='store_true') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def count(limit=350): | |
| file = open('words.py', 'r+') | |
| words = file.read().split() | |
| length = len(words) | |
| if length > limit: | |
| print("word count over word limit") | |
| print(f"words to cut down {length - limit}") | |
| elif length <= limit: | |
| print("word count adheres to word limit") |