Skip to content

Instantly share code, notes, and snippets.

View kmels's full-sized avatar

Carlos López kmels

  • Guatemala, Guatemala
View GitHub Profile
#Punto fijo, que avisa si la sucesion de numeros dada la ecuacion de recurrencia G(x) no es una contraccion, i.e. si | G'(x) | >= 1. Hay que mandarle la derivada de G(x), i.e. G_ en el parametro
def PuntoFijoAPruebaDeMuladas(G,G_,x0,e):
if abs(G_(x0)) >= 1:
print "Esta funcion G(x) esta tricky, la derivada evaluada en x=",x, " es mayor que 1, por lo que se podria salir de la recta f(x)=x y no converger"
else:
print "x_i: " , x0, " G(x_i): ", G(x0)
x0 = G(x0)
return x
@kmels
kmels / xmonad.hs
Created June 6, 2012 14:52
xmonad.hs to use with launcher
import XMonad
import Data.Monoid
import System.Exit
import XMonad.Config.Gnome
import XMonad.Util.Replace
import XMonad.Actions.Search
import qualified XMonad.Actions.Submap as SM
import qualified XMonad.StackSet as W
-- tests if an image is valid and, if it is, returns the resolution of the picture as a pair of the x-resolution and the y-resolution. An image is valid if all its pixels are valid and if all the rows have equally many columns.
ANTES
-----------------------------
validImage rows@(firstRow:nextRow:rrs) =
if (isValidRow firstRow && length firstRow == length nextRow && (isJust $ validImage (nextRow:rrs))) then
Just (length firstRow, length rows)
else
Nothing
validImage rows@(r:rs) = if isValidRow r && (isJust $ validImage rs) then Just (length r, length rows) else Nothing
-- tests if an image is valid and, if it is, returns the resolution of the picture as a pair of the x-resolution and the y-resolution. An image is valid if all its pixels are valid and if all the rows have equally many columns.
ANTES
-----------------------------
validImage rows@(firstRow:nextRow:rrs) =
if (isValidRow firstRow && length firstRow == length nextRow && (isJust $ validImage (nextRow:rrs))) then
Just (length firstRow, length rows)
else
Nothing
validImage rows@(r:rs) = if isValidRow r && (isJust $ validImage rs) then Just (length r, length rows) else Nothing
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
data Expr :: * -> * where
Int :: Int -> Expr Int
Bool :: Bool -> Expr Bool
IsZero :: Expr Int -> Expr Bool
-- Plus :: (* -> *) -> (* -> *) -> (* ->
If :: Expr Bool -> Expr a -> Expr a -> Expr a
@kmels
kmels / ghc.data
Created August 30, 2012 09:53
trac-stats output
kmels@kmels-portable-stelle:~/code/trac-timeline-stats$ runhaskell Main.lhs "http://hackage.haskell.org/trac/ghc/timeline?changeset=on&ticket=on&milestone=on&wiki=on&blog=on&max=500&author=&daysback=120&format=rss"
## Debug output ##
# Fetching feed..
# Fetched feed..
# Parsing..
# Calculating..
#########################
# REPORT
# (to plot with gnuplot)
# Number of Tickets fetched: 182
kmels@kmels-stelle:~/code/trac-stats$ git config --list
user.name=Carlos López-Camey
user.email=c.lopez@kmels.net
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=https://github.com/kmels/trac-stats
branch.master.remote=origin
@kmels
kmels / gist:3908520
Created October 17, 2012 21:53
yesod
maybeGetBy :: forall (m :: * -> *) val. (PersistEntity val,
PersistUnique
(PersistEntityBackend val) m) =>
Unique val (PersistEntityBackend val)
-> MaybeT
(PersistEntityBackend val m) (Database.Persist.Store.Entity val)
maybeGetBy criterion = MaybeT $ getBy criterion
canvas = document.getElementById("canvas");
field = document.getElementById("field");
robot = document.getElementById("robot");
goal = document.getElementById("goal");
ctx = canvas.getContext("2d");
mkImagePattern = (img) -> ctx.createPattern(img, 'repeat');
# fills canvas with a field pattern
### Keybase proof
I hereby claim:
* I am kmels on github.
* I am kmels (https://keybase.io/kmels) on keybase.
* I have a public key whose fingerprint is 290C EB97 2C38 9CCE 8352 A8B4 3A69 87CF 41D7 3145
To claim this, I am signing this object: