Skip to content

Instantly share code, notes, and snippets.

View cristianounix's full-sized avatar
👨‍🚀
Focusing

Cristiano Oliveira cristianounix

👨‍🚀
Focusing
View GitHub Profile
@cristianounix
cristianounix / NeuralNetwork.py
Created February 17, 2020 01:14
NeuralNetwork implement
class NeuralNetwork:
def __init__(self, x, y):
self.input = x
self.weights1 = np.random.rand(self.input.shape[1],4)
self.weights2 = np.random.rand(4,1)
self.y = y
self.output = np.zeros(self.y.shape)
def feedforward(self):
self.layer1 = sigmoid(np.dot(self.input, self.weights1))
@cristianounix
cristianounix / mongo-restore.sh
Created June 4, 2018 17:57
Restore mongo database in your container (named mongo)
#!/bin/bash
if [ -s "$1" ]
then
MONGO_STATUS=$(docker inspect -f {{.State.Running}} mongo)
if [ "$MONGO_STATUS" != "true" ]
then
echo "Mongo is not running"
exit 1
fi
@cristianounix
cristianounix / mysql-restore.sh
Created June 4, 2018 17:55
Restore database in your container (named database)
#!/bin/bash
if [ -s "$1" ]
then
if [ "$(docker inspect -f {{.State.Running}} database)" != "true" ]
then
echo "Container MySql is not running"
exit 1
fi
else
echo "Syntax: $0 <filename>"
@cristianounix
cristianounix / git-change-email-end-author.sh
Last active May 25, 2018 17:01
Fix email and author git
git filter-branch --env-filter '
WRONG_EMAIL="cristiano.oliveira@venturus.org.br"
NEW_NAME="Cristiano S. Oliveira"
NEW_EMAIL="cristianounix@gmail.com"
if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
@cristianounix
cristianounix / make_data_correlation.R
Created April 5, 2018 17:41
Generate data correlation
make_data_corr = function(corr, n){
x = rnorm(n,0,1)
y = rnorm(n,0,1)
a = corr/(1-corr^2)^0.5
z=a*x+y
the_data = data.frame(x,z)
return(the_data)
}
data=make_data_corr(0.99,50)
╔══════╦═════════════╗
║ Dias ║ Altura (cm) ║
╠══════╬═════════════╣
║ 10 ║ 5 ║
║ 12 ║ 6 ║
║ 13 ║ 7 ║
║ 15 ║ 8 ║
║ 19 ║ 13 ║
║ 25 ║ 16 ║
╚══════╩═════════════╝
@cristianounix
cristianounix / R
Created March 4, 2018 21:32
Function that generate a dataset with a given correlation
# tks jerimi ann walker
make_data_correlated = function(corr, n){
x = rnorm(n,0,1)
y = rnorm(n,0,1)
a = corr/(1-corr^2)^0.5
z=a*x+y
the_data = data.frame(x,z)
return(the_data)
}
# -*- coding:utf-8 -*-
import scrapy
from scrapy.exceptions import CloseSpider
class LoginSpider(scrapy.Spider):
name = 'login-spider'
start_urls = ['http://quotes.toscrape.com/login']
def parse(self, response):
// Requires: http://cloud.github.com/downloads/harthur/brain/brain-0.6.0.js
// Contrived example using string "0" as output.
var net = new brain.NeuralNetwork();
net.train([{input: [0, 0], output: {"F":1}},
{input: [0, 1], output: {"1":1}},
{input: [1, 0], output: {"1":1}},
{input: [1, 1], output: {"0":1}}]);
/*
DESCRIPTION
-----------
Use NodeJS to read RFID ids through the USB serial stream. Code derived from this forum:
http://groups.google.com/group/nodejs/browse_thread/thread/e2b071b6a70a6eb1/086ec7fcb5036699
CODE REPOSITORY
---------------
https://gist.github.com/806605