Skip to content

Instantly share code, notes, and snippets.

@ozzieperez
ozzieperez / Flip Card with graceful degradation
Last active December 14, 2015 06:29
Flip Card With Graceful Degradation. Dependencies jQuery and Modernizr (can be optional). The only thing used from Modernizr is it looks for the "csstransforms3d" class to handle degradation.
<html class="csstransforms3d">
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<style>
/* CARDS
*****************************************************/
.card {
/* styling */
width: 200px;
height: 200px;
@ozzieperez
ozzieperez / Masonry with Flip cards and graceful degradation
Last active December 14, 2015 06:29
Masonry with gracefully degrading CSS transform flip cards. Dependencies are jQuery, Masonry, and Modernizr (only for csstransforms detection).
<html class="csstransforms3d1">
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/masonry/2.1.07/jquery.masonry.min.js"></script>
<style>
/* CARDS
*****************************************************/
.card {
/* styling */
@ozzieperez
ozzieperez / Test page for DOM Mutation Events
Created February 27, 2013 16:31
Test page to show support of DOM Mutation events
<html>
<!--
POC that detects DOM mutations on FF13+ and Chrome.
Uses MutationObserver, or DOM events as a fallback.
###################################################
For IE compatibility, replace:
myElement.addEventListener ('eventNameHere', callBackNameOrFunctionHere, false);
@ozzieperez
ozzieperez / ReflectionExamples.cs
Last active May 20, 2022 08:19
Reflection Examples in C#
/*
This example shows how to dynamically load assembly, how to create object instance, how to invoke method or how to get and set property value.
Create instance from assembly that is in your project References
*/
//The following examples create instances of DateTime class from the System assembly.
// create instance of class DateTime
DateTime dateTime = (DateTime)Activator.CreateInstance(typeof(DateTime));
@ozzieperez
ozzieperez / IOHelper.cs
Last active March 3, 2019 19:23
Xamarin.iOS - Get Special Folder Directory
public class IOHelper
{
public enum IosSpecialFolder
{
Documents,
Library,
Cache,
Preferences,
Tmp
}
@ozzieperez
ozzieperez / ISQLite.cs
Created February 14, 2015 14:38
SQLite for Xamarin.Forms Example
//db interface in shared pcl
using System;
using SQLite.Net;
namespace SampleApp
{
public interface ISQLite
{
SQLiteConnection GetConnection();
@ozzieperez
ozzieperez / NumericValidationTrigger.cs
Last active February 3, 2017 14:35
Xamarin.Forms Trigger Example
// Visual elements can react to events or property changes.
// Triggers can be thought of for "conditional styles".
// Types: Trigger, EventTrigger, DataTrigger, MultiTrigger
//EXAMPLE: hooking trigger to a property
//You have a trigger that fires when a property changes
//create the trigger
var trigger = new Trigger(typeof(Entry));
trigger.Property = Entry.IsFocusedProperty; // hooked to the "IsFocused" property!
@ozzieperez
ozzieperez / NumericValidationBehavior.cs
Created February 14, 2015 15:16
Xamarin.Forms Behavior Example
//Add functionality to visual elements without subclassing.
//Xamarin.Form controls can have a list of Behaviors.
public class NumericValidationBehavior : Behavior<Entry>
{
protected override void OnAttachedTo(Entry entry)
{
entry.TextChanged += OnEntryTextChanged;
base.OnAttachedTo(entry);
}
@ozzieperez
ozzieperez / Xamarin.Forms Accessibility-ChangeFocusedElement.cs
Last active August 29, 2015 14:15
Xamarin.Forms Accessibility - Change the default element selected when screen changes.
// Change default element selected when the screen changes.
// In the view controller...
public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear (animated);
//pass in the object to get focus
UIAccessibility.PostNotification(UIAccessibilityPostNotification.ScreenChanged, myObject);
}
@ozzieperez
ozzieperez / ListShuffle.cs
Created February 26, 2015 09:42
Randomly shuffles items in a list
public static class ListShuffle
{
public static void Shuffle<T>(this IList<T> list)
{
Random rng = new Random();
int n = list.Count;
while (n > 1)
{
n--;
int k = rng.Next(n + 1);