Skip to content

Instantly share code, notes, and snippets.

import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
public long FibonacciNumber(long n)
{
if (n > 92)
throw new ArgumentOutOfRangeException("n", "Fib(>92) will cause a 64-bit integer overflow.");
if (n < -92)
throw new ArgumentOutOfRangeException("n", "Fib(<-92) will cause a 64-bit integer overflow.");
var sqrt5 = Math.Sqrt(5);
var bigPhi = (sqrt5 + 1) / 2;
using Xamarin.Forms;
namespace DraggableView
{
public class App
{
public static Page GetMainPage()
{
return new ContentPage
{
public class CustomAndroidEntryRenderer : EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (e.OldElement == null) {
// Get the 'native' control
var nativeTextField = (EditText)Control;
@tombowers
tombowers / alt-data-structure.js
Last active August 29, 2015 14:08
How to search for an object in a Javascript array, and fast!
var food = {
fruit: [
{ name: 'banana', value: 'joke fruit', type: 'fruit' },
{ name: 'apple', value: 'newtonian legend', type: 'fruit' }
],
vegetables: [
{ name: 'cabbage', value: 'filth', type: 'vegetable' },
{ name: 'broccoli', value: 'green evil', type: 'vegetable' }
]
};
@tombowers
tombowers / get-script.js
Last active August 29, 2015 14:08
Load Cross-Domain Javascript Synchronously Using jQuery
$.getScript('http://example.com/script1.js', function () {
alert('Script Loaded');
});
@tombowers
tombowers / delete-with-select.cs
Last active March 8, 2023 04:32
Entity Framework - Update without Select
var id = 1;
using (var db = new entityContext())
{
// Select entity
var entity = db.dbset.FirstOrDefault(e => e.ID == id);
if (entity != null)
{
// Remove Entity
db.dbset.Remove(entity);
db.SaveChanges();
@tombowers
tombowers / basic-context-translation.js
Created October 27, 2014 15:28
HTML5 Canvas – Crisp lines every time
context.translate(0.5, 0.5);
var secondsSinceReferenceDate = 386463600; // 2013-4-1
var referenceDate = new DateTime(2001, 1, 1);
var databaseUtcTime = refdate.AddSeconds(secondsSinceReferenceDate);
TimeZoneInfo timeZone;
try {
timeZone = TimeZoneInfo.FindSystemTimeZoneById("Europe/Dublin");
}
catch (Exception)
@tombowers
tombowers / adding-to-cache.cs
Created October 27, 2014 14:59
Xamarin Android – Image Caching
if (_memoryCache.Get(key) == null)
_memoryCache.Put(key, bitmap);