Skip to content

Instantly share code, notes, and snippets.

View hello-alf's full-sized avatar
🏠
Working from home

Luis Alfredo Quispe Villca hello-alf

🏠
Working from home
  • La Paz, Bolivia
  • 08:25 (UTC -04:00)
View GitHub Profile
@hello-alf
hello-alf / precise_round.js
Created October 1, 2015 16:33 — forked from a-r-m-i-n/precise_round.js
How to round correctly in JavaScript
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;
@hello-alf
hello-alf / api.py
Created June 26, 2016 02:30 — forked from SeanHayes/api.py
TastyPie: Return 400 Bad Request when deserialization fails
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
# 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):
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) {
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 / {
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
# 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