Skip to content

Instantly share code, notes, and snippets.

View lfreneda's full-sized avatar
💙
Always deliver more than expected.

Luiz Freneda lfreneda

💙
Always deliver more than expected.
View GitHub Profile
@lfreneda
lfreneda / extract-emails.sh
Created January 27, 2016 18:31
extract-emails.sh
#!/usr/bin/env bash
if [ -f "$1" ]; then
strings "$1" | grep -o '[[:alnum:]+\.\_\-]*@[[:alnum:]+\.\_\-]*' | sort | uniq -i > emails_"$1"
else
echo "Expected a file at $1, but it doesn't exist." >&2
exit 1
fi
@lfreneda
lfreneda / gist:6212282
Created August 12, 2013 16:02
imdb info :p
using System;
using System.Globalization;
using System.Threading;
using SimpleBrowser;
namespace ConsoleApplication19
{
public static class StringExtensions
{
public static void Print(this string str, string prefix = null)
@lfreneda
lfreneda / gist:6062195
Created July 23, 2013 13:01
Frases :P
using System;
using System.Web;
using CsQuery;
namespace ConsoleApplication14
{
class Program
{
static void Main(string[] args)
{
@lfreneda
lfreneda / gist:5770666
Created June 13, 2013 01:47
R# sample
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace horrible.code.console {
public class SampleBaseClass {
@lfreneda
lfreneda / gist:5533177
Created May 7, 2013 14:49
bcp utility extract table to file sql server
bcp "SELECT Line from db_WF_Log.dbo.tbLogs where Type = 'anticheat_report' and Processed = 0" queryout 'C:\temp\queryout.txt' -c -t, -S 10.30.0.51,1220 -T
@lfreneda
lfreneda / gist:5356481
Last active December 16, 2015 01:39
all.js plugin widget jsonp
(function () {
var jQuery;
// If not present, load jquery
if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.4.2') {
createScriptReference("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", function () {
// Restore $ and window.jQuery to their previous values and store the
// new jQuery in our local jQuery variable
jQuery = window.jQuery.noConflict(true);
main();
});
@lfreneda
lfreneda / gist:5134190
Created March 11, 2013 13:25
FilterAttibutes nocache asp.net mvc
public class NoCacheAttribute : ActionFilterAttribute {
public override void OnResultExecuting(ResultExecutingContext filterContext) {
filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
filterContext.HttpContext.Response.Cache.SetValidUntilExpires(false);
filterContext.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
filterContext.HttpContext.Response.Cache.SetNoStore();
base.OnResultExecuting(filterContext);
}
}
@lfreneda
lfreneda / gist:4740186
Created February 8, 2013 16:37
getting branch name on post-receive :) git post receive hudson url branch name branch current
if ! [ -t 0 ]; then
read -a ref
fi
IFS='/' read -ra REF <<< "${ref[2]}"
branch="${REF[2]}"
if [ "lfreneda_novo_b2c" == "$branch" ]; then
URL='http://10.30.0.51:8081/job/dev.ecommerce.newb2c/build?delay=0sec'
wget.exe $URL
fi
[TestFixture]
public class EncryptingDecryptingTests {
static byte[] GetBytes(string str) {
byte[] bytes = new byte[str.Length * sizeof(char)];
System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
return bytes;
}
static string GetString(byte[] bytes) {
@lfreneda
lfreneda / Mock comparation using Moq and MagicMoq
Created December 18, 2012 18:39
comparation using MagicMoq ~
//using Moq as usual
[Test]
public void EditItem_Post_WhenModelIsValid_ShouldRedirectToIndex() {
//Arrange
var shoppingCartStub = new Mock<IShoppingCartService>();
shoppingCartStub.Setup(c => c.Change(It.IsAny<Guid>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<string>()));
var wcfServiceFactoryStub = new Mock<IWCFServiceFactory>();
var controller = new BasketController(shoppingCartStub.Object, wcfServiceFactoryStub.Object);