Skip to content

Instantly share code, notes, and snippets.

View joaoportela's full-sized avatar

João Paulo dos Santos Portela joaoportela

View GitHub Profile

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:

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,
/// <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 July 22, 2013 18:19
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.
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 July 2, 2013 19:16
Logs of nunit (gui) failing to open MySolution.sln as a project (with fusion enabled).
---------------------------
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 July 1, 2013 16:32
Fusion log when trying to load a project using nunit.
*** 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 July 1, 2013 15:47
Nunit exception when loading MySolution.sln into nunit gui.
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 January 24, 2013 17:27
Snippet related to NotifyCollectionChangedAction.Move taken from the code that is used to keep two collections in sync.
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();
// -- 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 February 17, 2012 16:31
layoutsubviews behaviour test (only most relevant part of the code)
// --------------- //
// 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);