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
Image = imread('Cameraman256.bmp'); | |
Frequency = zeros(256); | |
Samples = 256 * 256; | |
for i = 1:256 | |
for j = 1:256 | |
% convert 0-255 to index-wise | |
IntensityIndex = Image(i,j) + 1; | |
Frequency(IntensityIndex) = Frequency(IntensityIndex) + 1; | |
end |
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
% it creates a simple gray image (4x4) | |
I = [255, 255, 30, 100 | |
255, 50, 90, 20 | |
70, 70, 20, 10 | |
100, 20, 10, 0]; | |
% it converts it to grayscale | |
I = mat2gray(I); | |
% shows it | |
imshow(I); |
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
// This post will briefly explain (omiting, skipping some parts) in code what is | |
// Functor, Pointed Functor, Monad and Applicative Functor. Maybe by reading the | |
// code you will easily grasp these functional concepts. | |
// if you only want to run this code go to: | |
// https://jsfiddle.net/leandromoreira/buq5mnyk/ | |
// or https://gist.github.com/leandromoreira/9504733c7f8c6361c46270ea953d8409 | |
// This code requires you to have require.js loaded (or you can load ramda instead :P) | |
requirejs.config({ |
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
var a = []; document.onkeyup=function(e){a+=[(e||self.event).keyCode-37] ; if (/113302022928/.test(a)) { alert('Konami Code'); a = ""}} |
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
# creating an amazon machine | |
docker-machine create --driver amazonec2 --amazonec2-access-key XXX --amazonec2-secret-key "xxxxx" --amazonec2-vpc-id vpc-xxx --amazonec2-zone Y amazon | |
# creating a digital ocean machine | |
docker-machine create --driver digitalocean --digitalocean-access-token=XXX do | |
# let's take note of our ip | |
docker-machine ip amazon | |
# let's deploy our application | |
docker-machine up |
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
# we'll create a "machine" called dev on virtualbox | |
docker-machine create --driver virtualbox dev | |
# let's use this machine | |
eval "$(docker-machine env dev)" | |
# let's take note of our docker-ip | |
docker-machine ip dev | |
# let's run this app | |
docker-compose up | |
# now go to your browser and type ip :) it should show something |
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
# we'll use 2 processors/core | |
worker_processes 2; | |
# we set a new limit for open files for our workers | |
worker_rlimit_nofile 100000; | |
# we define how we're going to work | |
events { | |
# for each worker we'll handle 4000 requests (enquee them) | |
worker_connections 4000; | |
# we'll accept multiple |
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
# we'll build our container from an existent image :) | |
FROM nginx | |
# for some reason we need to create this folder | |
RUN mkdir -p /var/lib/nginx/proxy | |
# copy our app config to nginx | |
COPY sites-enabled/myapp.conf /etc/nginx/nginx.conf |
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
# we'll call our web app of web | |
web: | |
# it'll build this container based the docker file ./Dockerfile | |
build: . | |
# it'll run this command to star the server | |
command: bash -c "rm -f tmp/pids/server.pid || true && bundle exec rails s -p 3000 -b '0.0.0.0'" | |
# it'll export the port 3000 | |
ports: | |
- "3000:3000" | |
# it links to db container (on mongoid.yaml at rail's config we say host: db:27017 it's linked) |
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
# we'll use an existent image which already have ruby installed | |
FROM ruby:2.3.0 | |
# creating our app folder | |
RUN mkdir /myapp | |
# move to this folder | |
WORKDIR /myapp | |
# move the Gemfile to our app's root folder | |
ADD Gemfile /myapp/Gemfile | |
# move the Gemfile.lock too | |
ADD Gemfile.lock /myapp/Gemfile.lock |