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
def slice(objects, prop): | |
""" | |
slice objects in sublists sharing a common propery | |
""" | |
if not objects: | |
return [] | |
def get_prop(obj, prop): | |
if not isinstance(objects[0], dict): | |
return obj.__dict__[prop] |
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
#include <stdio.h> | |
#include <complex> | |
#include <iostream> | |
int main() | |
{ | |
double a1,b1,c1; | |
printf("ingrese valor de a,b,c\n"); | |
scanf("%lf" "%lf" "%lf", &a1, &b1, &c1); |
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
#aca van los coeficientes de la cuadratica | |
a = 1 | |
b = 0 | |
c = -1 | |
#aca van las cotas del intervalo | |
ax = -3 | |
bx = 3 | |
#estes es el error de la raiz en el cual cortar |
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
#aca van los coeficientes de la cuadratica | |
a = 2 | |
b = 0 | |
c = -3 | |
#aca van las cotas del intervalo | |
ax = -3 | |
bx = 3 | |
delta = 1 |
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 django.db import connection | |
from functools import wraps | |
def check_db_connection(f): | |
@wraps(f) | |
def inner(*args, **kargs): | |
try: | |
connection.connection.ping() | |
except: | |
connection.close() | |
return f(*args, **kargs) |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Carrusel Ejemplo</title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<!-- Archivos de bootstrap --> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> |
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
import itertools | |
def get_all_sum_combinations(elements): | |
""" | |
Gets all the combinations of the sum of a list of elements. | |
""" | |
combinations = [] | |
for i in range(1, len(elements) + 1): | |
for subset in itertools.combinations(elements, r=i): | |
result = sum(subset) |
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
library(quantreg) | |
airq <- airquality | |
#fit the quantile regression with Ozone formula | |
fit <- rq(Ozone ~ ., data=airquality) | |
#create a new dataframe with the values to forecast the Ozone | |
newdata <- data.frame(Solar.R=201:203, Wind=8:10, Temp=82:84, Month=9, Day=20:22) | |
#newdata is the parameter to tell the predict function to use the values for making the forecast | |
fore <- predict(fit, newdata=newdata) |
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
import random | |
import time | |
class Card(object): | |
def __init__(self, number, kind): | |
self.number = number | |
self.kind = kind |
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
buildFormula <- function(dataset, terms_array) { | |
for (i in 1:length(terms_array)) | |
assign(paste("fact", i, sep=""), L(dataset, terms_array[i])) | |
factors = array() | |
for (i in 1:length(terms_array)) | |
factors[i] <- paste("fact", i, sep="") | |
form = as.formula(paste("dataset~", paste(factors, collapse="+"))) | |
return(form) |