Skip to content

Instantly share code, notes, and snippets.

View m-root's full-sized avatar
💭
I may be slow to respond.

m-root

💭
I may be slow to respond.
View GitHub Profile
HTML Animations
@m-root
m-root / chartist-js.html
Created March 4, 2018 08:07
CHARTIST.JS Charts implementation in html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Chartist</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="https://rawgit.com/gionkunz/chartist-js/master/dist/chartist.min.css">
@m-root
m-root / wordpress_schema.py
Created March 10, 2018 09:54
Wordpess Schema in Django Models
from django.db import models
class WpCommentmeta(models.Model):
meta_id = models.BigAutoField(primary_key=True)
comment_id = models.BigIntegerField()
meta_key = models.CharField(max_length=255, blank=True, null=True)
meta_value = models.TextField(blank=True, null=True)
class Meta:
@m-root
m-root / access_from_web.md
Created March 18, 2018 09:03 — forked from jasperf/access_from_web.md
MySQL Commands to create users, database, password and grant necessary privileges from the command line
mysql> CREATE USER 'user_name'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON database_name.* TO 'user_name'@'localhost' WITH GRANT OPTION;
mysql> CREATE USER 'user_name'@'%' IDENTIFIED BY 'password';

mysql> GRANT ALL PRIVILEGES ON database_name.* TO 'user_name'@'%' WITH GRANT OPTION;

@m-root
m-root / time_date.py
Created March 18, 2018 16:10
Python Date and Time Example
import time
import datetime
print "Time in seconds since the epoch: %s" %time.time()
#Time in seconds since the epoch: 1349271346.46
print "Current date and time: " , datetime.datetime.now()
#Current date and time: 2012-10-03 15:35:46.461491
print "Or like this: " ,datetime.datetime.now().strftime("%y-%m-%d-%H-%M")
#Or like this: 12-10-03-15-35
@m-root
m-root / django_authentication_flows.py
Last active March 19, 2018 07:03
Django authentication template
# python manage.py startapp accounts
# cmkdir -p accounts/templates/accounts
# ccryptomanager.urls
# curl(r'^', include('accounts.urls')),
############ accounts/urls.py ############
@m-root
m-root / quick_tricks.md
Created March 19, 2018 07:06
Django Quick Start
@m-root
m-root / restricted.py
Created March 20, 2018 09:07
Django provides many ways of implementing this goal, I just used 3 unique and two derive from the basic ones.
from django.contrib.auth.decorators import login_required
from django.shortcuts import render, redirect
from django.views.generic import TemplateView
from django.utils.decorators import method_decorator
from django.conf import settings
from django.contrib.auth.mixins import LoginRequiredMixin
from django.shortcuts import reverse
def restricted_view_manual(request):
@m-root
m-root / DJANGO_CURD.py
Created March 20, 2018 09:13
Django class CURD
####################### MODELS ##########################
class ModelAuthor(models.Model):
username = models.CharField(max_length=150, null=False, blank=False)
def __str__(self):
return self.username # This gets called for example when you create an user input, the text shown is the returned string
class ModelPost(models.Model):
title = models.CharField(max_length=200)
@m-root
m-root / shell_colors
Created March 30, 2018 06:14
Shell colors
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# SETUP CONSTANTS
# Bunch-o-predefined colors. Makes reading code easier than escape sequences.
# I don't remember where I found this. o_O
# Reset
Color_Off="\[\033[0m\]" # Text Reset