Skip to content

Instantly share code, notes, and snippets.

@taiar
taiar / plot.rb
Created March 24, 2014 03:03
plot histogram fom csv
require 'csv'
data = CSV.read('train.csv')
# puts 'Cabeçalho: ' + data[0].inspect
sobrev = []
data.each do |r|
if r[1] == '1'
@taiar
taiar / Upload.cs
Created June 18, 2014 15:02
Amazon S3 Upload
public string InserirArquivoCliente(Usuario usr, string arq)
{
string folderStr = ("{0}{1}").Concatenar("~/", usr.UsuarioPerfil.Empresa.IDEmpresa);
try
{
using (IAmazonS3 client = AWSClientFactory.CreateAmazonS3Client("XXXXX", "XXXXXX", RegionEndpoint.SAEast1))
{
S3DirectoryInfo info = new S3DirectoryInfo(client, "XXXXXX");
Stream a = new FileStream(arq, FileMode.Open, FileAccess.Read);
// Modeline settings {{{
// vim: foldmarker={{{,}}} foldlevel=0 foldmethod=marker
// }}}
<O arquivo em questão é um mini tutorial sobre como engendrar uma Autoridade Certificadora (AC), bem como gerar certicados e chaves via OpenSSL. Os exemplos são para serem executados em linha de comando UNIX/POSIX sua apresentação de forma de procedimentos é meramente para ilustrar a passagem de parâmetros.>
/*========================================================================*/
<<< MINI-TUTORIAL>>>
<<< premissas> >>
@taiar
taiar / dirw.php
Last active August 29, 2015 14:07
Dir watcher prototype
<?php
class dir_watcher {
private $dir;
private $files;
public function __construct($dir = '.') {
$this->dir = realpath($dir) . DIRECTORY_SEPARATOR;
$this->get_file_timestamps();
@taiar
taiar / fv.cs
Created December 9, 2014 14:05
FV.cs
using System;
using System.Collections.Generic;
using System.Collections;
using System.Web;
using System.Reflection;
namespace VetNuvem.Web.App_Code
{
public class FormValidation
{
@taiar
taiar / Instructions.md
Last active August 29, 2015 14:11
Vagrant n00b

Vagrant

Windows 8

  1. Ceritifique-se de que o seu usuário do windows não tenha acentos no nome do diretório de usuário. Se tiver, retire assim: http://superuser.com/questions/495290/how-to-rename-user-folder-in-windows-8
  2. Tenha o virtualbox instalado
  3. Ter certeza de que o virtualbox consegue inicializar máquinas de 64bits (pode ter que alterar configurações de virtualização do windows - usei isso https://www.youtube.com/watch?v=rtF8nooLruY e isso https://www.youtube.com/watch?v=Y56boAsdptw)
  4. Abre o Power Shell ou o Cmder
  5. vagrant.exe box add --name rails http://files.hellobits.com/vagrant/hellobits-trusty64-virtualbox.box (using an already setted up box)
  6. vagrant plugin install vagrant-vbguest
@taiar
taiar / gist:fa88849078d098b38661
Created December 29, 2014 15:12
Fork SSH in Exec
<?
exec("ssh -n -f us@hos \"sh -c 'nohup ./some_script_or_command > /dev/null 2>&1 &'\" &");
@taiar
taiar / authorized_keys
Last active August 29, 2015 14:19
Own Multi-User Private Git Server
command="/usr/bin/gitserve richard rw",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAA...zzz me@example.com
@taiar
taiar / snippet.js
Created April 23, 2015 12:26
addCPFChromeButton
javascript:function getCPF(){var n1 = Math.round(Math.random()*9);var n2 = Math.round(Math.random()*9);var n3 = Math.round(Math.random()*9);var n4 = Math.round(Math.random()*9);var n5 = Math.round(Math.random()*9);var n6 = Math.round(Math.random()*9);var n7 = Math.round(Math.random()*9);var n8 = Math.round(Math.random()*9);var n9 = Math.round(Math.random()*9);var aux = n1 * 10 + n2 * 9 + n3 * 8 + n4 * 7 + n5 * 6 + n6 * 5 + n7 * 4 + n8 * 3 + n9 * 2;aux = mod(aux, 11);var nv1 = aux < 2 ? 0 : 11 - aux;aux = n1 * 11 + n2 * 10 + n3 * 9 + n4 * 8 + n5 * 7 + n6 * 6 + n7 * 5 + n8 * 4 + n9 * 3 + nv1 * 2; aux = mod(aux, 11);var nv2 = aux < 2 ? 0 : 11 - aux;return ""+n1+n2+n3+"."+n4+n5+n6+"."+n7+n8+n9+"-"+nv1+nv2;}function mod(a,b){return Math.round(a-(Math.floor(a/b)*b));}javascript:$('#campoCpf').val(getCPF());$('#btnCriarUsuario').focus();
@taiar
taiar / waitFor.js
Created May 13, 2015 19:23
waitFor.js
/**
* Espera até que algo ocorra para executar um callback
*
* @param t referência para função que testa a condição de continuidade
* @param v valor que a função de teste deve alcançar para que dê continuidade
* @param d intervalo de espera entre testes (milissegundos)
* @param c callback executado após condição alcançada
*/
function waitFor(t, v, d, c) {
while (t() !== v) { setTimeout(function() { waitFor(t, v, d, c); }, d); return; }