Skip to content

Instantly share code, notes, and snippets.

View luiseduardohd's full-sized avatar
🎯
Focusing

Luis Hernandez luiseduardohd

🎯
Focusing
View GitHub Profile
@brandontreb
brandontreb / Vector2D.lua
Created June 3, 2011 14:26
A simple Vector2D class used in Corona SDK games.
Vector2D = {}
function Vector2D:new(x, y)
local object = { x = x, y = y }
setmetatable(object, { __index = Vector2D })
return object
end
function Vector2D:copy()
return Vector2D:new(self.x, self.y)
@conceptdev
conceptdev / AppDelegate.cs
Created March 30, 2012 23:57
CoreImage quick'n'dirty sample: Contrast/Saturation/Brightness editing (screenshot http://twitpic.com/93gfty)
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace ColorControl {
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to
@lessthanyouthink
lessthanyouthink / CJProperRotationNavigationController.h
Created October 5, 2012 20:27
A simple UINavigationController subclass to handle iOS 6's orientation changes better.
//
// CJProperRotationNavigationController.h
//
// Created by Charles Joseph on 2012-10-01.
//
#import <UIKit/UIKit.h>
@interface CJProperRotationNavigationController : UINavigationController
//does the actual coloring
void DrawPoints (CGContext dctx)
{
dctx.BeginPath ();
dctx.MoveTo (Points.First().X, Points.First().Y);
dctx.SetLineWidth(swatchSlider.Value);
dctx.SetBlendMode (CGBlendMode.Normal);
foreach (var crayon in Crayons) {
public class HashEncryption
{
/// <summary>
/// Encrypts a string using the MD5 hash encryption algorithm.
/// Message Digest is 128-bit and is commonly used to verify data, by checking
/// the 'MD5 checksum' of the data. Information on MD5 can be found at:
///
/// http://www.faqs.org/rfcs/rfc1321.html
/// </summary>
/// <param name="Data">A string containing the data to encrypt.</param>
anonymous
anonymous / HTTPRequest.cs
Created March 18, 2013 18:34
Flash-Like Unity HTTP Request
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
public delegate void SuccessHandler(HTTPRequest request);
public delegate void ErrorHandler(HTTPRequest request);
public class HTTPRequest
@jlewin
jlewin / ListDuplicateFiles.cs
Created June 27, 2013 18:23
List duplicate files in a directory
/// <summary>
/// Processes a given directory, grouping and listing files with duplicate content
/// </summary>
/// <param name="directory">The path to process</param>
private void ListDuplicateFiles(string directory)
{
// Calculate and store the hash and path for each file in the directory
var files = Directory.GetFiles(directory).Select(f => new { Path = f, Hash = FileHash.CalculateFromFile(f) });
// Group and iterate when duplicates exist
@praeclarum
praeclarum / EasyLayout.cs
Last active April 21, 2023 10:28
**OUT OF DATE** Please use the NuGet package https://www.nuget.org/packages/EasyLayout or the code on GitHub https://github.com/praeclarum/EasyLayout. (EasyLayout makes writing auto layout code in Xamarin.iOS easier. See [the example](https://gist.github.com/praeclarum/8185036) for hints on how to use this library.)
//
// Copyright (c) 2013-2015 Frank A. Krueger
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
@praeclarum
praeclarum / EasyLayoutExample.cs
Last active June 16, 2018 12:26
Here is an example of using my [EasyLayout](https://gist.github.com/praeclarum/6225853) library. Note the use of <= and >=, these are very difficult to write in old fashioned (frame-based) layout code. Also note the extension method GetMidY() that emulates Center.Y. You can also use GetBaseline() that works for baseline-aware views.
ContentView.ConstrainLayout (() =>
border.Frame.Top == ContentView.Frame.Top &&
border.Frame.Height == 0.5f &&
border.Frame.Left == ContentView.Frame.Left &&
border.Frame.Right == ContentView.Frame.Right &&
nameLabel.Frame.Left == ContentView.Frame.Left + hpad &&
nameLabel.Frame.Right == ContentView.Frame.GetMidX () - 5.5f &&
nameLabel.Frame.Top >= ContentView.Frame.Top + vpad &&
@luiseduardohd
luiseduardohd / MessageBox iOs
Created February 12, 2014 16:53
simple MessageBox para Xamarin ios
public static class MessageBox
{
public static void Show(string title, string message, MessageBoxButton buttons, Action positiveCallback, Action negativeCallback)
{
UIAlertView alert = BuildAlert(title, message, buttons);
alert.Clicked += (sender, buttonArgs) =>
{
if (buttonArgs.ButtonIndex == 0)
{