Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Ismael Venegas Castelló SalchiPapa

🎯
Focusing
Block or report user

Report or block SalchiPapa

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@SalchiPapa
SalchiPapa / julia_meta.jl
Last active Aug 26, 2015
Julia Metaprogramming
View julia_meta.jl
julia> for sym in (:foo, :baz, :bar)
#=
$ is used to interpolate expressions (`Expr`) and symbols into other expressions
it is also used to interpolate values in strings and commands (`Cmd`)
=#
@eval $(sym)() = println($"$sym was called")
end
julia> syms = [symbol(string(:test, i)) for i in 1:5] # generate symbols
5-element Array{Symbol,1}:
@SalchiPapa
SalchiPapa / openshift-slides.jl
Last active Aug 28, 2015
Julia OpenShift Cartridge Slides - Ivan David Barron Baez
View openshift-slides.jl
using Markdown
presentable(x) = Escher.fontsize(1.5em, lineheight(2em, x))
indent(x) = Escher.pad([left], 5em, x) |> lineheight(1.5em)
function content_slide(slide_title, content)
vbox(
title(3, slide_title),
vskip(2em),
@SalchiPapa
SalchiPapa / str_cat.jl
Created Feb 3, 2014
String concatenation demo in Julia with the *= operator.
View str_cat.jl
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
ismaelvc@toybox ~> julia
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "help()" to list help topics
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.3.0-prerelease+1316 (2014-01-30 05:22 UTC)
View constante_e.py
ismaelvc@toybox ~> python2
Python 2.7.6 (default, Feb 15 2014, 23:01:55)
[GCC 4.8.2 20140206 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> math.e
2.718281828459045
ismaelvc@toybox ~> python
Python 3.3.4 (default, Feb 11 2014, 16:14:21)
[GCC 4.8.2 20140206 (prerelease)] on linux
View ejemplo_if.c
#include <stdio.h>
#define MAX 5
int main(void)
{
int arreglo[] = {1, 2, 3, 4, 5};
int i;
for(i=0; i < MAX; i++) {
int numero = arreglo[i];
@SalchiPapa
SalchiPapa / guess_number.jl
Last active Aug 29, 2015
Example of 1 vs 0 based indexing.
View guess_number.jl
#!/usr/bin/env julia
range = 1:100
big = range[end]
small = range[1]
function guess()
(small + big) >> 1
end
@SalchiPapa
SalchiPapa / valid_base_3.py
Last active Aug 29, 2015
Checks wheter a string is a valid base 3 number representation.
View valid_base_3.py
In [1]: valid_base_3_digits = ['0', '1', '2']
In [2]: for digit in '012':
...: if digit not in valid_base_3_digits:
...: print("That won't work!")
...: else:
...: print("Seems right!")
...:
Seems right!
Seems right!
@SalchiPapa
SalchiPapa / caras_cubo.jl
Last active Aug 29, 2015
caras de un cubo?
View caras_cubo.jl
ismaelvc@toybox ~> julia
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "help()" to list help topics
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.3.0-prerelease+1672 (2014-02-22 04:00 UTC)
_/ |\__'_|_|_|\__'_| | Commit b2fea25* (0 days old master)
|__/ | i686-pc-linux-gnu
@SalchiPapa
SalchiPapa / sum_even_factorials.py
Last active Aug 29, 2015
Sum even factorials.
View sum_even_factorials.py
#!/usr/bin/env python3
def factorial(n):
"""
>>> factorial(20)
2432902008176640000
"""
if n < 2:
return 1
View caras_rubik.py
[[[ 1, 2, 3],
[ 4, 5, 6],
[ 7, 8, 9]],
[[10, 11, 12],
[13, 14, 15],
[16, 17, 18]],
[[19, 20, 21],
[22, 23, 24],
You can’t perform that action at this time.