Skip to content

Instantly share code, notes, and snippets.

João Paulo dos Santos Portela joaoportela

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am joaoportela on github.
  • I am joaoportela (https://keybase.io/joaoportela) on keybase.
  • I have a public key whose fingerprint is 7A9F 9FC1 5CED 8F5D 119C 9366 FBB7 35B9 CB30 9D36

To claim this, I am signing this object:

View tls1_process_heartbeat-after_heartbleed_patch.c
int
tls1_process_heartbeat(SSL *s)
{
unsigned char *p = &s->s3->rrec.data[0], *pl;
unsigned short hbtype;
unsigned int payload;
unsigned int padding = 16; /* Use minimum padding */
if (s->msg_callback)
s->msg_callback(0, s->version, TLS1_RT_HEARTBEAT,
View KeepOneItemSelectedBehavior.cs
/// <summary>
/// Behaviour that keeps at least one item in the listbox selected by blocking it's
/// deselection (SelectionChanged event).
///
/// Will not allow for deselection by the user or programatically.
/// Will allow for deselection if the selected item is being removed from the list.
/// When the list is empty no item is selected.
///
/// Only tested with SingleSelection list boxes, should work with others.
/// </summary>
@joaoportela
joaoportela / MainWindow.xaml.cs
Created Jul 22, 2013
Very simple experiment with C# Tasks and async + await. Do not take any of this code as correct or even as best practice. I'm just trying to understand how this all works. 1st obvious shortcomming: The server only accepts one client connection at a time.
View MainWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
@joaoportela
joaoportela / message box.txt
Created Jul 2, 2013
Logs of nunit (gui) failing to open MySolution.sln as a project (with fusion enabled).
View message box.txt
---------------------------
NUnit
---------------------------
Test load failed!
System.IO.FileNotFoundException : Could not load file or assembly 'MyNamespace.Administration, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
@joaoportela
joaoportela / fusionlog_nunit-agent-x86_MyNamespace.Administration.exe
Created Jul 1, 2013
Fusion log when trying to load a project using nunit.
View fusionlog_nunit-agent-x86_MyNamespace.Administration.exe
*** Assembly Binder Log Entry (01-07-2013 @ 17:20:43) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Program Files (x86)\NUnit 2.6.2\bin\nunit-agent-x86.exe
--- A detailed error log follows.
=== Pre-bind state information ===
@joaoportela
joaoportela / nunit-exception.txt
Created Jul 1, 2013
Nunit exception when loading MySolution.sln into nunit gui.
View nunit-exception.txt
System.IO.FileNotFoundException...
Server stack trace:
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark&
@joaoportela
joaoportela / NotifyCollectionChangedAction-Move.cs
Created Jan 24, 2013
Snippet related to NotifyCollectionChangedAction.Move taken from the code that is used to keep two collections in sync.
View NotifyCollectionChangedAction-Move.cs
case NotifyCollectionChangedAction.Move:
{
// Loosely based on http://stackoverflow.com/a/450250/86845
int newIndex = e.NewStartingIndex;
int oldIndex = e.OldStartingIndex;
int itemsCount = e.OldItems.Count;
// get a copy of the items that are to be moved
List<T> items = otherList.Skip(oldIndex).Take(itemsCount).ToList();
View a_ original version.cpp
// -- original version --
for (u = b.size(), v = b.back(); u--; v = p[v])
b[u] = v;
// "unrolled" original version
// init
u = b.size(), v=b.back();
// condition
u--;
// code
@joaoportela
joaoportela / gist:1854249
Created Feb 17, 2012
layoutsubviews behaviour test (only most relevant part of the code)
View gist:1854249
// --------------- //
// VIEW CONTROLLER //
- (void)viewDidLoad
{
[super viewDidLoad];
JPMyView* view1 = [JPMyView viewWithName:@"view1"];
view1.backgroundColor = [UIColor greenColor];
view1.frame = CGRectMake(0.0f, 0.0f, 200.0f, 200.0f);
You can’t perform that action at this time.