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 / 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: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 / 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: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 / .bashrc
Created January 30, 2012 16:36
Load RVM shell configuration
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
@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]