Skip to content

Instantly share code, notes, and snippets.

View stuartelimu's full-sized avatar
🎯
Focusing

Stuart Elimu stuartelimu

🎯
Focusing
View GitHub Profile
@stuartelimu
stuartelimu / db.md
Last active October 3, 2019 12:42
PHP MySQL Revision

connect to the database, CRUD

$con = mysql_connect("localhost","root","");

// select database 
mysql_select_db("database-name");

// perform query 
// insert query
"$matchOne": func(template, context map[string]interface{}) (interface{}, error) {
if err := restrictProperties(template, "$matchOne"); err != nil {
return nil, err
}
match, ok := template["$matchOne"].(map[string]interface{})
if !ok {
return nil, TemplateError{
Message: "$matchOne can evaluate objects only",
Template: template,
@stuartelimu
stuartelimu / base.html
Last active March 28, 2020 19:10
Readit Blog
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Readit - Free Bootstrap 4 Template by Colorlib</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700,800,900" rel="stylesheet">
ab

Hello, world!

@stuartelimu
stuartelimu / createsuperuser.md
Last active July 5, 2020 06:09
Easily create a superuser for your django project

Easily create a superuser for your django project using this simple line.

I found this trick on the Quickstart guide from the django-rest-framework docs

$ python manage.py createsuperuser --username admin --email admin@example.com
Password: **********
Password (again): **********
Superuser created successfully.

Hello, world! carbon

@stuartelimu
stuartelimu / Change article Django site admin.png
Last active July 5, 2020 20:54
Using get_absolute_url() model instance method in Django
Change article Django site admin.png
@stuartelimu
stuartelimu / git-cheatsheet.md
Last active February 11, 2021 05:17
Git Cheatsheet

Undo git add

You can undo git add before commit with

git reset <file>

You can use

git reset

without any file name to unstage all due changes. This can come in handy when there are too many files to be listed one by one in a reasonable amount of time.