This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sign(num) { | |
// IE does not support method sign here | |
if (typeof Math.sign === 'undefined') { | |
if (num > 0) { | |
return 1; | |
} | |
if (num < 0) { | |
return -1; | |
} | |
return 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tastypie import http | |
from tastypie.exceptions import ImmediateHttpResponse | |
from tastypie.resources import ModelResource | |
class CustomModelResource(ModelResource): | |
def deserialize(self, request, data, format='application/json'): | |
try: | |
return super(CustomModelResource, self).deserialize(request, data, format=format) | |
except Exception as e: | |
# if an exception occurred here it must be due to deserialization |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# particion que hace ordenamiento usando el pivote | |
#low es el indice mas bajo | |
#high es el indice mas algo | |
def particion(arr, low, high): | |
i = (low-1) | |
# pivot es el valor medio que necesitamos | |
pivot = arr[high] | |
for j in range(low, high): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let res = [] | |
function greedyChange(coinSet, n, amount) { | |
if (n < 0) { | |
console.log( | |
'Lo sentimos no contamos con efectivo suficiente para darte el monto que necesitas' | |
) | |
return | |
} | |
if (amount === 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
listen [::]:80; | |
root /var/www/example.com/site; | |
index index.html index.htm index.nginx-debian.html; | |
server_name example.com www.example.com; | |
location / { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Instalador de brew | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" | |
brew update | |
brew install nginx | |
# Comando para iniciar el server | |
launchctl load /usr/local/cellar/nginx/1.19.2/homebrew.mxcl.nginx.plist | |
# Comando para detener servicio+ | |
launchctl unload /usr/local/cellar/nginx/1.19.2/homebrew.mxcl.nginx.plist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. create a folder called Backups | |
mkdir Backups | |
2. Login as postgres user through console | |
sudo -su postgres | |
3. execute the following comand | |
./backup_script.sh | |
(REPLACE DB_NAME with the database that you want to extract data) | |
NOTE: the content of backup_script is: | |
#!/bin/bash |