Skip to content

Instantly share code, notes, and snippets.

Avatar

José Luis SalahAdDin

View GitHub Profile
@SalahAdDin
SalahAdDin / instructions.md
Last active Jul 3, 2020
Loading SVGR as URL react
View instructions.md

First, install url-loader along side with svgr: yarn add -D url-loader.

Add the loader to svg test option:

{
  test: /\.svg$/,
  use: ["@svgr/webpack", "url-loader"],
},
@SalahAdDin
SalahAdDin / LectureWidget.cpp
Created Aug 9, 2019
A try to create a default widget totally in c++.
View LectureWidget.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "LectureWidget.h"
#include "Blueprint/WidgetTree.h"
#include "Components/Button.h"
#include "Components/Image.h"
#include "Components/CanvasPanel.h"
#include "Components/CanvasPanelSlot.h"
#include "Layout/Anchors.h"
@SalahAdDin
SalahAdDin / command.md
Last active May 16, 2019
Setup to Darknet and Deeplearning
View command.md

First, we need to install allr required libraries:
sudo pacman -S python-numpy vtk hdf5 openmp opencv cuda cudnn
It installs all requirements to work with the GPU and the OpenCv's support to Darknet and other libraries; hdf5 is required to work with opencv in python; vtk is required to compile Darknet.
By default Darknet handles libraries' references on Debians based linux systems, then, it requires opencv's as well as cuda references to work; in ArchLinux, opencv is in its 4.1.0 and it used opencv4 as environment variable, we need change the reference then:
sudo cp /usr/lib/pkgconfig/opencv4.pc /usr/lib/pkgconfig/opencv.pc.
While the cuda library is installed in a different folder than Debian's based systems, we need to created a symbolic link to solve this problem:
sudo ln -s /opt/cuda/ /usr/local/cuda.

@SalahAdDin
SalahAdDin / commands.md
Created Jan 21, 2019
Repairing Arch/Manjaro Grub
View commands.md

If we have access to the grub rescue, we can do the next steps:

grub rescue > ls
(hd0)... (hd0,gpt8)...
grub rescue > ls (hd2,gpt8) # try to recognize which partition is this
grub rescue > ls (hd2,gpt6) # let's assume this is the linux partition
grub rescue > set root=(hd2,gpt6)
grub rescue > set prefix=(hd2,gpt6)/boot/grub # or wherever grub is installed
grub rescue > insmod normal # if this produced an error, reset root and prefix to something else ..
grub rescue > normal
View commands.md

Installing extra addons:

In shell

  • copy the directory of the module in ./addons
  • give permissions chmod -R 755 addons/<module_directory>
  • restart the container

In Odoo:

  • Activate the developer mode
@SalahAdDin
SalahAdDin / Commands.md
Last active May 2, 2019
PostgresSQL commands
View Commands.md

Enter to superuser: sudo su
Enter to postgres user: sudo -iu postgres
Enter to user: sudo -iu $username$
Enter to console with authentication: psql -d $databasename$ -U $username$ -W
Enter to postgres console(default database): psql
Enter to postgres console(other database): psql -d $databasename$
Disconnect: \q

List all databases: \l
List all schemas: \dn

@SalahAdDin
SalahAdDin / views.py
Last active Mar 10, 2018
Recipe views
View views.py
# Golbal queries
class GlobalQueryMixin(object):
"""
Mixin for get a global template query
post: Most ranked recipe
tops: Five most ranked recipes
top fruits: Three most ranked fruit recipes
random: Four random recipes
fruits: Four fruit recipes
desserts: Four desserts recipes
@SalahAdDin
SalahAdDin / Commands.md
Last active Feb 8, 2018
Useful commands
View Commands.md

Crontab

export EDITOR=nano
crontab -e
crontab -l

Docker

  • docker-compose up
  • docker-compose down
@SalahAdDin
SalahAdDin / formsets.py
Created Oct 8, 2017
Multiple formularios en vista
View formsets.py
# PriorityFormSet = formset_factory(PriorityForm, extra=5, can_delete=True)
PriorityFormSet = modelformset_factory(Priority, form=PriorityForm, extra=3, can_delete=True)
# TicketStatusFormSet = formset_factory(TicketStatusForm, extra=3, can_delete=True)
TicketStatusFormSet = modelformset_factory(TicketStatus, form=TicketStatusForm, extra=3, can_delete=True)
# TicketTypeFormSet = formset_factory(TicketTypeForm, extra=3, can_delete=True)
TicketTypeFormSet = modelformset_factory(TicketType, form=TicketTypeForm, extra=3, can_delete=True)
class PriorityForm(forms.ModelForm):
@SalahAdDin
SalahAdDin / geo_tags.py
Created Apr 4, 2017
Trying to make a custom template tag.
View geo_tags.py
import logging
import re
import requests
from django.conf import settings
from django.template import Library
from django.template import Node
from django.template import TemplateSyntaxError
from django.utils.html import format_html_join
You can’t perform that action at this time.