Skip to content

Instantly share code, notes, and snippets.

@mbeltagy
mbeltagy / pascal.jl
Created Nov 9, 2019
Pascal Triangle calculation
View pascal.jl
"Pascal triangle"
function pascal(n)
(n<=0) && error("Pascal trinalge can not have zero or negative rows")
r=Vector{Int}(undef,n)
pr=Vector{Int}(undef,n)
pr[1]=r[1]=1
println(@view pr[1])
for i=2:n
r[1]=r[i]=1
for j=2:i-1
@mbeltagy
mbeltagy / roundupdown.jl
Created Jun 1, 2019
Julia rounding up or down to the nearest integer mulitple
View roundupdown.jl
round_up(x,m::Integer)=ceil(Int,x/m).*m
round_down(x,m::Integer)=floor(Int,x/m).*m
@mbeltagy
mbeltagy / Interpolation_example.jl
Last active Feb 14, 2019
Interpolations Example
View Interpolation_example.jl
using Interpolations, Plots
# Demonstrating interpolations
x=0:0.5:2π
y=sin.(x);
itp=LinearInterpolation(x,y);
y2=[itp(x) for x in 0:0.1:2];
x2=0:0.1:6;
y2=[itp(x) for x in x2];
itpC=CubicSplineInterpolation(x,y);
@mbeltagy
mbeltagy / Buildingread.jl
Created Feb 10, 2019
Building Expenses Filtration
View Buildingread.jl
using CSV
data=CSV.read("Jan19.csv")
# The occursin is used to get the line where the transfer happened...hence summing all transfers
audi_ind=findall(x->ismissing(x) ? false : occursin(r"audi"i,x), data[:,1])
data[audi_ind,1:3][:Cash] |> x-> prod.(split.(x,',')) |> x-> Meta.parse.(x) |> sum
@mbeltagy
mbeltagy / extractcerts.jl
Last active Nov 26, 2017
Getting TensorFlow.jl to build properly
View extractcerts.jl
#=
I was getting the following errors when running
Pkg.update("TensorFlow")
On my ubunutu 14.04
INFO: Building TensorFlow.jl for CPU use only. To enable the GPU, set the TF_USE_GPU environment variable to 1 and rebuild TensorFlow.jl
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (60) server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
@mbeltagy
mbeltagy / readFusionTable.jl
Created Jul 15, 2017
Opening up fusion table from Julia
View readFusionTable.jl
# Reading a fusion table from Julia
using Requests, DataFrames
request_url = "https://www.googleapis.com/fusiontables/v2/query"
query = "SELECT * FROM 1KlX4PFF81wlx_TJ4zGudN_NoV_gq_GwrxuVau_M"
resp=get(request_url,query=Dict("sql"=>query, "key"=>"somekey","alt"=>"csv"))
myTable=readtable(IOBuffer(resp.data));
@mbeltagy
mbeltagy / PoolJumpCalc.ipynb
Last active Jun 23, 2017
Jumping from second floor to pool
View PoolJumpCalc.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mbeltagy
mbeltagy / TupperFormula.ipynb
Created Jun 7, 2017
Tupper's_self-referential_formula in Julia
View TupperFormula.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mbeltagy
mbeltagy / MohRafeaIntroToJuila.ipynb
Created Apr 25, 2017
First intro to Mohammed Rafea to Julia for NN
View MohRafeaIntroToJuila.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mbeltagy
mbeltagy / Makefile
Created Apr 4, 2017
For the Julia calling C minimal example
View Makefile
CC=gcc
CFLAGS=-c -Wall -fPIC
SOURCES=calc_mean.c
OBJECTS=$(SOURCES:.c=.o)
.c.o:
$(CC) $(CFLAGS) $< -o $@
You can’t perform that action at this time.