Skip to content

Instantly share code, notes, and snippets.

View victoraguilarc's full-sized avatar
🧭
Working

Victor Aguilar C. victoraguilarc

🧭
Working
View GitHub Profile
@victoraguilarc
victoraguilarc / monthly_payments.py
Created May 19, 2021 06:27
Calculate Total and IVA
from decimal import Decimal
from pprint import pprint
def cast_int(amount: Decimal) -> int:
return int(amount * 100)
def cast_decimal(amount: int) -> Decimal:
return Decimal(amount / 100).quantize(Decimal('1.00'))
class Product(models.Model):
# other fields
image = models.FileField(storage = MogileFSStorage(), upload_to = 'product_images')
from django.core.files import File
from django.core.files.temp import NamedTemporaryFile
product = Product()
# set all your variables here
product.save()
import Crypto.Cipher.AES
import Crypto.Random
import base64
import binascii
class Cipher_AES:
pad_default = lambda x, y: x + (y - len(x) % y) * " ".encode("utf-8")
unpad_default = lambda x: x.rstrip()
pad_user_defined = lambda x, y, z: x + (y - len(x) % y) * z.encode("utf-8")

Cheat Sheets are greate but they are not a substitute for learning the framework and reading the documentation as we most certainly have not covered every potential example here. Please refer to the Rails Command Line Docs for more information.

Command Line Generator Info

Reference

You can get all of this information on the command line.

rails generate with no generator name will output a list of all available generators and some information about global options. rails generate GENERATOR --help will list the options that can be passed to the specified generator.

@victoraguilarc
victoraguilarc / rails-4-djangonauts.md
Last active May 22, 2019 19:21
cheatsheets for django developers that for any reason uses rails

COMMAND LINE GENERATOR

CREATE A RESOURCE

rails generate scaffold Post name:string title:string content:text

GENERATE MODELS

rails generate model Post title:string body:text published:boolean
def clean_inactive_devices(f):
"""
This turns as inactive to the unused devices
"""
@wraps(f)
def decorated(*args, **kwargs):
# process anythin BEFORE
results, device_tokens = f(*args, **kwargs)
# process anythin AFTER
@victoraguilarc
victoraguilarc / GitHub-Forking.md
Created January 15, 2019 06:32 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@victoraguilarc
victoraguilarc / README.md
Created October 12, 2018 22:42 — forked from superseb/README.md
Deploy kubernetes-dashboard on Rancher 2.0 cluster exposed using NodePort

Deploy kubernetes-dashboard on Rancher 2.0 cluster exposed using NodePort

Requirements

Step 1: Generate kubeconfig from the UI

Generate the kubeconfig file for your cluster using the Kubeconfig File button in the Cluster view of your cluster. Save the generated file as $HOME/.kube/config and run kubectl get nodes to verify it works.

@victoraguilarc
victoraguilarc / wordpress-apache.conf
Created July 6, 2018 17:58
Apache wordpress config
<VirtualHost *:80>
ServerName DOMAIN
ServerAdmin [email protected]
DocumentRoot /var/www/PROJECT_FOLDER
ServerAlias www.DOMAIN
<Directory /var/www/PROJECT_FOLDER/>
Options +FollowSymlinks
AllowOverride All
Require all granted
@victoraguilarc
victoraguilarc / angular-nginx.conf
Last active July 6, 2018 21:27
Static Site nginx config
server {
listen 80;
root /var/www/angular.xiberty.com/dist;
index index.php index.html index.htm;
server_name angular.xiberty.com;
access_log /var/www/angular.xiberty.com/nginx-access.log;
error_log /var/www/angular.xiberty.com/nginx-error.log;