Skip to content

Instantly share code, notes, and snippets.

View jmg's full-sized avatar

Juan Manuel Garcia jmg

View GitHub Profile
#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
#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
@jmg
jmg / complex_square_roots.cpp
Last active April 13, 2016 04:41
Quadratic Formula with complex numbers solutions
#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);
@jmg
jmg / slice.py
Created April 29, 2015 15:42
slice objects in sublists sharing a common propery
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]
import sys
sys.path.append('../api2/include')
from helpers.database import DataBase
from config import config
class WarehousesFinder(object):
def __init__(self):
@jmg
jmg / manage_example.py
Created May 16, 2014 20:49
Configuration for multiple environments in manage.py
import os
# By default assume it's local environment
env = os.environ.get("ENV", "LOCAL")
# PROD/DEV/LOCAL are values the environment variable ENV can have.
# Example for production server: ~$ export ENV=PROD
settings_files = {
"PROD": "production_settings",
"DEV": "development_settings",
@jmg
jmg / fabric-django.py
Created January 30, 2014 01:40
django deploy fabric
from fabric.api import run, env
def staging():
env.hosts = ['root@crawley-cloud.com']
def prod():
env.hosts = ['root@crawley-cloud.com']
@jmg
jmg / django-shopify-virtualenv-setup.sh
Created January 6, 2014 17:41
Creates a new django-shopify app using virtualenv
virtualenv env
source env/bin/activate
pip install django==1.4.10 #Replace this for the django version you want
pip install django-shopify
start_shopify_app testing
@jmg
jmg / gist:4271779
Created December 12, 2012 21:26
Django class based view
from django.views.generic import TemplateView
class MyView(TemplateView):
url = "myurl/view1"
template_name = "index/template.html"
def get(self, *args, **kwargs):
context = {}
@jmg
jmg / ProxyDispatcher.php
Created January 12, 2012 03:06
Proxy Dispatcher using php call_user_func_array
<?php
/**
* Proxy Dispatcher using php call_user_func_array (http://us2.php.net/manual/en/function.call-user-func-array.php)
* */
class Foo {
function bar1($arg, $arg2, $arg3, $arg4) {
return "arg: $arg, arg2: $arg2, arg3: $arg3, arg4: $arg4\n";