Skip to content

Instantly share code, notes, and snippets.

View SalahAdDin's full-sized avatar
🎯
Focusing

José Luis SalahAdDin

🎯
Focusing
View GitHub Profile
@SalahAdDin
SalahAdDin / solution.js
Created May 13, 2022 20:16
Code Challenge Solution
const getNonConstructibleChange = (input) => {
const coins = input.sort((a, b) => a - b);
let currentChange = 0;
coins.forEach((coint) => {
const aimedChange = currentChange + 1;
if (coint > aimedChange) return aimedChange;
@SalahAdDin
SalahAdDin / instructions.md
Last active July 3, 2020 11:55
Loading SVGR as URL react

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 August 9, 2019 09:56
A try to create a default widget totally in c++.
// 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 14:32
Setup to Darknet and Deeplearning

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 January 21, 2019 14:48
Repairing Arch/Manjaro Grub

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
@SalahAdDin
SalahAdDin / commands.md
Last active November 1, 2018 13:15
Odoo tricks

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 12:46
PostgresSQL commands

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 March 10, 2018 18:16
Recipe views
# 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 February 8, 2018 15:34
Useful commands

Crontab

export EDITOR=nano
crontab -e
crontab -l

Docker

  • docker-compose up
  • docker-compose down
@SalahAdDin
SalahAdDin / formsets.py
Created October 8, 2017 13:23
Multiple formularios en vista
# 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):