Skip to content

Instantly share code, notes, and snippets.

View programmation's full-sized avatar

David Dancy programmation

View GitHub Profile
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@praeclarum
praeclarum / Dsp.cs
Created April 9, 2013 19:38
DSP functions for Xamarin.iOS bound to the Accelerate framework. See it in action by buying my Spectrogram app for iOS: https://itunes.apple.com/us/app/live-spectrogram/id630831185
using System;
using System.Runtime.InteropServices;
namespace Circuit
{
public static class Dsp
{
class FftSetupD : IDisposable
{
public IntPtr Handle;
@praeclarum
praeclarum / MarkovChain.fs
Last active August 29, 2015 14:13
Markov Chain that learns by observing data.
/// Markov chain that learns by observing data.
/// Let it observe a sequence of states.
/// Then you can ask it, given a state,
/// what are the probabilities of the next states occuring?
/// This chain can remember history to make better predictions.
type MarkovChain (numStates : int, memory : int) =
let numPrevious = 1 + memory
let matrixSize = int (System.Math.Pow (float numStates, float numPrevious))
@kristopherjohnson
kristopherjohnson / DispatchGroupDemo.swift
Last active May 28, 2021 14:40
Simple demo of dispatch_group_async/dispatch_group_notify/dispatch_group_wait in Swift
import Foundation
let notified = dispatch_semaphore_create(0)
let group = dispatch_group_create()
let queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
for n in 0..<20 {
dispatch_group_async(group, queue) {
let timeInterval = Double(arc4random_uniform(1000)) * 0.01
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using Xamarin.Forms;
namespace WrapPanelDemo.Controls
{
public class AwesomeWrappanel : Layout<View>
{
@ChaseFlorell
ChaseFlorell / GridView.cs
Last active August 6, 2017 23:53
Xamarin.Forms GridView
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using Xamarin.Forms;
namespace TimeTracker.Controls
{
public class GridView : Grid
@georgejecook
georgejecook / FastCell.cs
Created May 4, 2015 05:20
butter smooth performance in xamarin forms listview
using System;
using Xamarin.Forms;
namespace TwinEvents.Core.Media.View
{
public class FastCell : ViewCell
{
}
}
module.exports = function(grunt) {
grunt.initConfig({
adminPassword: '',
solution: '',
versionNumber: grunt.option('versionNumber'),
buildAgent: grunt.option('buildAgent'),
@vwart
vwart / Example.cs
Last active March 14, 2017 23:49
This can be used to re-layout a Grid with star (*) rows within a ScrollView. For Xamarin Forms
//usage:
// ContactGrid is the x:Name of the Grid within the ScrollView
protected override void OnAppearing()
{
base.OnAppearing();
ContactGrid.LayoutStars(((float)App.INSTANCE.Resources["PageHeight"]));
}
//In your MainActivity:
@praeclarum
praeclarum / ListDiff.cs
Created June 15, 2017 17:36
Implements generic list diffing
using System;
using System.Collections.Generic;
namespace Praeclarum
{
/// <summary>
/// The type of <see cref="ListDiffAction{S,D}"/>.
/// </summary>
public enum ListDiffActionType
{