Skip to content

Instantly share code, notes, and snippets.

View jrgcubano's full-sized avatar

Jorge Rodríguez Galán jrgcubano

View GitHub Profile
@jrgcubano
jrgcubano / PicturesCarousel.cs
Created August 29, 2016 13:51 — forked from davidtavarez/PicturesCarousel.cs
Picture carousel for Android, iOS, WP using Xamarin.Forms. https://cdn.pbrd.co/images/2otpyQam.png
using System;
using Xamarin.Forms;
using System.Collections.ObjectModel;
namespace NAMESPACE.Controls
{
public class PicturesCarousel : ScrollView
{
AbsoluteLayout _ElementsStack = new AbsoluteLayout ();
private static Bitmap getCropBitmap (Bitmap origialBitmap,int left, int top, int right, int bottom){
int targetWidth = right-left;
int targetHeight = bottom-top;
Bitmap cutBitmap = Bitmap.createBitmap(targetWidth,targetHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(cutBitmap);
Rect desRect = new Rect(0, 0, targetWidth, targetHeight);
Rect srcRect = new Rect(left, top, right, bottom);
canvas.drawBitmap(origialBitmap, srcRect, desRect, null);
return cutBitmap;
}
@jrgcubano
jrgcubano / gist:d61244a29b0d1271e49c05826ea65cdf
Created September 5, 2016 16:12 — forked from jorgebastida/gist:1886036
Get credit card type by number
import re
def credit_card_type(number):
"""
Return a string that represents the type of the credit card number.
Criteria:
AMEX: Starts with 34 or 37 and the length 15.
MASTERCARD: Starts with 51-55 and the length is 16.
@jrgcubano
jrgcubano / Mod10Algorithm.cs
Created September 5, 2016 16:13 — forked from playerx/Mod10Algorithm.cs
Mod10 algorithm function on c#
private int Mod10Check(string creditCardNumber)
{
//// 1. Starting with the check digit double the value of every other digit
//// 2. If doubling of a number results in a two digits number, add up
/// the digits to get a single digit number. This will results in eight single digit numbers
//// 3. Get the sum of the digits
int sumOfDigits = creditCardNumber.Where((e) => e >= '0' && e <= '9')
.Reverse()
.Select((e, i) => ((int)e - 48) * (i % 2 == 0 ? 1 : 2))
.Sum((e) => e / 10 + e % 10);
@jrgcubano
jrgcubano / gist:b371e0ac74f0794b2c45869486cdc561
Created September 28, 2016 09:00 — forked from jamessdixon/gist:f81b230d91c3f500ae14
Consume an Azure ML API (Request/Response) using F#
#r @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll"
#r @"..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll"
open System
open System.Net.Http
open System.Net.Http.Headers
open System.Net.Http.Formatting
open System.Collections.Generic
@jrgcubano
jrgcubano / HUDProviderDroid.cs
Created October 13, 2016 13:21 — forked from Vratislav/HUDProviderDroid.cs
HUD Bindings for Xamarin Forms projects
using System;
using Applifting;
using Android.Content;
using Xamarin.Forms.Labs.Services;
namespace Applifting.Droid
{
public interface IDroidContextProvider{
Context Context {get;}
}
@jrgcubano
jrgcubano / YearMonthPicker.cs
Created October 31, 2016 09:58 — forked from tvand7093/YearMonthPicker.cs
A year or month picker for Xamarin Forms
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace DatePickerFormat
{
@jrgcubano
jrgcubano / MLCoverflow.cs
Created November 3, 2016 21:05 — forked from melanke/MLCoverflow.cs
MLCoverflow Xamarin Implementation
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
SET NOCOUNT ON
-- Get size of SQL Server Page in bytes
DECLARE @pg_size INT, @Instancename varchar(50)
SELECT @pg_size = low from master..spt_values where number = 1 and type = 'E'
-- Extract perfmon counters to a temporary table
IF OBJECT_ID('tempdb..#perfmon_counters') is not null DROP TABLE #perfmon_counters
SELECT * INTO #perfmon_counters FROM sys.dm_os_performance_counters

FizzBuzzBang ('-' * 12) Solution to essential FizzBuzz problem, however I got bored and stylized it a little :)

A Pen by Ryan Trimble on CodePen.

License.