RSSAmplifier

Blog

Programmer blog

My thoughts/recipes on Django, Python, JS and other things I try...

garmoncheg.blogspot.comRSS feed ↗25 posts

Latest posts

AI Agents in Visual Studio Code

Getting Started with AI Agents in Visual Studio Code AI agents are becoming a powerful part of modern development. If you're using Visual Studio Code, you can integrate tools like Codex directly into your workflow and significantly speed up coding, debugging, and refactoring. 1. Install the AI Extension Open VS Code and go to the Extensions panel ( Ctrl+Shift+X ). Search for an AI extension such…

Making a TODO app with React

Once in a time a decent dev must renew his knowledge of tech. So I decided to recollect react by creating a basic TODO app with it. To start it one need to install react project. I prefer `pnpm` and `nvm` for managing packages and node versions respectively. Here are my steps to install React: Step 1: Install pnpm If you don’t already have pnpm installed, install it globally via npm or corepack :…

Install bcrypt on Mac OSX

Basically One can do it wih homebrew. About the App App name : bcrypt App description : Cross platform file encryption utility using blowfish App website : http://bcrypt.sourceforge.net Install the homebrew package manager Open Terminal and press enter/return key. Copy and paste the following command in Terminal app: /bin/bash -c "$(curl -fsSL…

Writing nice prompts for stable diffusion and like neural networks

Request: new york city, synthwave, cinematic, dramatic, composition, sunny sky, brutalist, hyper realistic, epic scale, sense of awe, hypermaximalist, insane level of details, artstation HQ Playing with neural models is really fun. Let's try to make our best at writing good requests. That's the key! So thst's how: Diffusion prompts are statements or questions that are designed to help individuals…

Running tasks with Celery on Heroku guide

An example project and a basic guide showing how to run Django/Celery on Heroku. Basic requirements First of all, let's actually set up a typical Django project for this. We would need virtualenvwrapper for that. One could use any other particular method. I prefer this one. $ cd dev $ mkvirtualenv dch ( dch ) $ pip install django ( dch ) $ django-admin startproject djheroku ( dch ) $ cd djheroku #…

SQLAlchemy (Flask) count model instances by unique values

One comes to a task that has to do with counting items in a database. We will describe the right approach here. Despite being so obvious I did not find much of the docs for junior developers to watch and learn. Here is a sample task and solution: Let's assume we have a model like so: class Cycle (db.Model): id = db.Column(db.Integer, primary_key= True ) object_id = db.Column(db.String, nullable=…

PostgreSQL DB with pgAdmin4 access through SSH tunnel

Despite using console most of the time I have a preference to edit PostgreSQL databases through UI. Especially when it comes to remote side. Usually one can access this through $ psql command. However this tends to writing raw SQL queries and a lot of typing in overall. Here is a way to do it with UI. First one needs to make a tunnel.Command is fairly simple: ssh - fNg - L 5555 : localhost : 5432…

Run Flask with Debug in PyCharm

I have gotten to setting UP a Flask environment for a project recently. Was completely puzzled by how to run this. I have used to running Django project with python manage.py script. This means pointing out a PyCharm interpreter into a certain point of entry, that is also a .py file also. In flask way of starting things there is another approach however. Here it is in Flask Docs. It states to set…

Promise -fication of JS calls.

Found a new pattern to use recently that is called Promise. I really like the way ES6/7 brings new thinking patterns into life nowdays. Here is Promise used instead of old pattern. It was to give JS method a callback function. This splitting code and making a lot of possibilities for error to come out in this place. One would write old times according to MDN : function greeting ( name ) { alert (…

Vagrant error: * Unknown configuration section 'hostmanager'.

Sometimes you get a vagrant environment or boilerplate with a Vagrantfile config in there and do a vagrant up command. And see some errors. like this: There are errors in the configuration of this machine . Please fix the following errors and try again : Vagrant: * Unknown configuration section 'hostmanager'. To fix this one needs: $ vagrant plugin install vagrant - hostmanager Installing the '…

POP3 Mock (Fake) server using python script

Having a need in POP3 server for my debugging purposes I have used this script. Letting it to be here in case of anyone would need to do something similar. Usage is: $ python pypopper.py 110 email_file.eml " " " pypopper: a file-based pop3 serve r Useage : python pypopper.py <port> <path_to_message_file > " " " import logging import os import socket import sys import traceback logging .…

Install Docker under Ubuntu 14.04 (Trusty)

Docker supports Ubuntu versions: Ubuntu Vivid 15.04 (64-bit) Ubuntu Trusty 14.04 (LTS) (64-bit) Ubuntu Precise 12.04 (LTS) (64-bit) Ubuntu Raring 13.04 and Saucy 13.10 (64 bit) For both Vivid and Trusty you need nothing. It will work out of the box. Others will require some modifications. (Updating of some things, like kernel or installing with wget on 13.04) 1. To install docker from a repository…

Remi and EPEL repositories in CentOS

There are 2 common repositories that come nowdays for centos. They contain tasty things, while they are absent in official repositories. CentOS 5: wget http : //dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm wget http : //rpms.famillecollet.com/enterprise/remi-release-5.rpm sudo rpm - Uvh remi - release - 5 * . rpm epel - release - 5 * . rpm CentOS 6: wget http :…

Tmux quick start guide

Tmux is a handy terminal manager that allows you to switch between terminal sessions easily. Without losing history or windows upon ssh disconnects or similar. It is like screen , just better. (First of all because of using client-server based technology... ) Here is my minimal keyboard shortcuts guide that allows you to start using Tmux in a blink of an eye. Endless advanced commands and hotkey…

Installing MySQL and phpMyAdmin for web development on a Mac OS X 10.9, 10.8, 10.7, 10.6

This is a simple guide on installing a must have SQL database engine for web development. It is often used at the beginning of the journey and I did not find a good guide for it. That made me make myself one and share with others. Hope somebody would benefit from it. First we need to setup the MySQL community edition (latest or not depending on your requirements). It's possible to download it…

[Django CMS] Adding plugins inside plugins programatically

I have a task to migrate a website. Old one is plain HTML and new one is Django CMS. I have a script that parses an HTML page from old website in to CMS page and places it into proper place. Task is to migrate all the page content (that is a CMS TextPlugin) into an interlinked pages setup. Like we have text <p>blah blah </p><a href="/page/url">Text</a><p> some other text</p> And I need to change…

Don&#39;t put html, head and body tags automatically into beautifulsoup content

Was making a parser recently with BeautifulSoup. Came to the final with rendering contents of the edited text. Like so: text = "<h1>Test text tag</h1>" soup = BeautifulSoup(text, "html5" ) text = soup . renderContents() print text It renders those contents with a result wrapped into the <html>, <head> and <body> tags. So print output looks like so: '<html><head></head><body><h1>Test text…

Error copying files in Finder of OS X

Problem: I have an SD flash card (8 GB Kingston) and a MacBook Pro 13" (Late 2011 model). I also use external card reader time to time. This problem persisted on all the conditions. The error message was stating: The Finder can’t complete the operation because some data in “” can’t be read or written. (Error code -36) This was happening while copying Photos from my camera (cr2 files). It worked,…

5 most common Rsync command usage examples

rsync is a command for remote sync. It is used to synchronise one location to another in a simple way. Location is meant to be local directory, server or remote web server or whatever accessible by ssh. Advantages of using rsync over other tools is speed and bandwidth requirements. First time rsync copies entire contents of the directory provided and increments changes over next sync times.…

Django adding custom widget to Django Admin

Sometimes you need to get out of standard behaviour of your Django admin. It means expanding its functionality with custom things. In our case we have a model that we want to add a custom html element. Button that must load something via AJAX from another place to be exact. We have a typical Django polls application for simplicity. Here is its structure: First of all we need to create a structure.…

Virtualenv for Django

One of main features and troubles for Django projects is the Django version you are using. Example for this would be the occasion of starting project for Django 1.4.x version. Trying to run it under Django 1.7.x would lead to various troubles, counting template changes, misconfiguration errors and so on. Solution is to use virtual environment. The tool for this is called Virtualenv . It is a…

Django CMS custom Plugin ManyToMany fields problems.

Developing a website for Django CMS I have done a plugin. This plugin however have had a problem. It had an m2m field. While selecting images there (It was a gallery plugin). It was not saving it to production. This way main problem with this field was that plugin have displayed m2m choices on a draft page and while storing it to live it fails. Django CMS Pages is built like so it has multiple…

Implementing a Multiple (Radio) Select + “Other” widget in Django

I have had a task to implement Radio Select field with "Other" choice field in a Django Model Form. Here is my implementation in case someone would benefit from it. The idea is to have it all stored to Django's CharField type of data and have a preselected set of fields. We have a model: # models.py class Entry (models.Model): SET_OF_CHOICES = ( ( 'choice1' , 'choice1' ), ( 'choice2' , 'choice2'…

How to delete a remote git tag

I'm always forgetting this. So decided to put it here for someone's benefit. I have the git tag added by command: git tag -a 1.2 . 0 -m "1.2.0" this means my tags tree will be updated with the tag 1.2.0 and message 1.2.0 Usually it marks the version of the build/release. I now push a tag to origin by command: git push origin --tags It is possible to see it at my repository github tagged. Time now…

Pillow compile error clang: -Wno-error=unused-command-line-argument-hard-error-in-future fix

I have had a problem with compiling Pillow recently. the error was with Pillow/Pil compilation. pillow install error clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error- in -future] Apple updated command line tools. So the cc command was updated too. $ gcc --version Configured with : --prefix= /Applications/Xcode.app/Contents/Developer/usr…