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):
var http = require("http");
var fs = require("fs");
var index = fs.readFileSync("index.html");
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var db = mongoose.connection;
@cristianounix
cristianounix / QSQlite3
Last active August 29, 2015 14:23 — forked from daltheman/QSQlite3
//
// QSQLite3.swift
// SQLiteWrapper
//
// Created by Danilo Altheman on 24/06/15.
// Copyright © 2015 Quaddro - Danilo Altheman. All rights reserved.
/* Usage:
// Open or create a Database
let database = QSQLite3(path: NSHomeDirectory() + "/Documents/database.sqlite")