Skip to content

Instantly share code, notes, and snippets.

View leocosta's full-sized avatar
:electron:
Focusing

Leonardo Costa leocosta

:electron:
Focusing
View GitHub Profile
@leocosta
leocosta / gist:11299920
Last active August 29, 2015 14:00
VirtualBox + Vagrant
Instale o Oracle VirtualBox
http://www.virtualbox.org/wiki/Downloads
Instale o Ruby + RubyGems
(recomendo usar o RVM https://rvm.io/)
Abra o terminal e execute os seguintes comandos:
(instalação do Vagrant - http://vagrantup.com/)
$ gem install vagrant
@leocosta
leocosta / gist:11301664
Created April 25, 2014 20:11
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
@leocosta
leocosta / gist:1556080
Created January 3, 2012 17:54
Find in NFe XML file by order number
private static bool FindInFile(string filename, string content)
{
using (var reader = XmlReader.Create(filename))
{
var root = XDocument.Load(reader);
var nsmgr = new XmlNamespaceManager(reader.NameTable);
nsmgr.AddNamespace("ns", "http://www.portalfiscal.inf.br/nfe");
return root.XPathSelectElement("//ns:infCpl", nsmgr).Value
.Split(new[] { "Ped_Num:" }, StringSplitOptions.None)[1]
@leocosta
leocosta / .bashrc
Created January 30, 2012 16:36
Load RVM shell configuration
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
@leocosta
leocosta / gist:3155415
Created July 21, 2012 10:48
Return data from web services in ruby
require 'uri'
require 'net/http'
source_url = "http://www.tripsay.com/api/json/tips/Paris,Ile-de-France,France?api_key=TEST&maxResults=5 "
url = URI.parse(source_url)
path=url.path
path=url.path+"?"+url.query
post = Net::HTTP::Get.new(path)
@leocosta
leocosta / gist:3261306
Created August 5, 2012 03:06
Fibonacci Solution
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Fibonacci
{
[TestClass]
public class FibonacciTests
{
[TestMethod]
public void TestReturn()
{
@leocosta
leocosta / gist:3805595
Created September 30, 2012 01:34
HttpRequest Helper
namespace ConsoleApplication1
{
using UrlExtensions;
class Program
{
static void Main(string[] args)
{
var html = "http://www.google.com".Request(RequestOptions.KeepTrying);
Console.WriteLine(html);
@leocosta
leocosta / ProcessLog.rb
Created October 28, 2012 20:42
ProcessLog
#!/usr/bin/env ruby
$LOAD_PATH << '.'
require 'rest_client'
require 'hpricot'
require 'config'
module ProcessLog
@leocosta
leocosta / gist:5218376
Last active December 15, 2015 06:39
Installing Google V8 Javascript Engine on Linux
sudo apt-get install g++
sudo svn checkout http://v8.googlecode.com/svn/trunk/ /usr/local/v8
cd /usr/local/v8
make dependencies
make [arch] snapshot=on gdbjit=on liveobjectlist=on debuggersupport=on
sudo scons
@leocosta
leocosta / gist:5229549
Last active December 15, 2015 08:19
Configuring yeoman + angular generator + karma generator + phantomJS
#configuring phantomJS
$ cd /usr/local
$ sudo git clone git://github.com/ariya/phantomjs.git && cd phantomjs
$ sudo ./build.sh
sudo ln -s /usr/local/phantomjs/bin/phantomjs /usr/local/bin/phantomjs
export PHANTOMJS_BIN=/usr/local/bin/phantomjs