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: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
@leocosta
leocosta / gist:5383365
Created April 14, 2013 16:46
configuring webapp on heroku
#install heroku toolbelt
$ wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
#login
$ heroku login
#upload your public key to heroku
$ ssh-keygen -t rsa -C "your_email@youremail.com"
$ heroku keys:add ~/.ssh/id_rsa.pub
@leocosta
leocosta / gist:8270609
Created January 5, 2014 16:51
Re-associate vagrant with vm
Had the same issue and found a workaround. This is how it occurred:
Had two VMs running, went home for the day
Windows updated and restarted during the night
Came to work, fired up cygwin and ran vagrant up dev. Saw that vagrant began creating a new box and cancelled.
Opened Virtualbox and saw that no VMs where listed. Found the path to "Default Machine Folder", opened it in Windows and saw that my previous VMs still existed on disk
Deleted the thrid VM on disk that was accidentally created with "vagrant up"
Readded the old VMs to Virtualbox by going to "Machine -> Add..." and adding the VMs from disk manually
Ran vagrant status
At this point the VMs where still listed as "(not created)".