Skip to content

Instantly share code, notes, and snippets.

@srkirkland
srkirkland / georesults.json
Last active August 29, 2015 14:09
sample results
{
"version": 3,
"status": "ok",
"response": {
"data": [
{
"address": "1131 Folsom St",
"category_ids": [
358,
348,
using System;
using System.Collections.Generic;
using System.Linq;
using Foundation;
using UIKit;
namespace pagingnav
{
// The UIApplicationDelegate for the application. This class is responsible for launching the
@srkirkland
srkirkland / panmove.cs
Created February 5, 2015 06:41
finger tracking pan gesture recognizer.
//addtl info at https://github.com/johncadengo/JCWindowShade/blob/master/JCWindowShade/JCViewController.m#L137
var dragging = false;
contentView.AddGestureRecognizer (new UIPanGestureRecognizer ((pan) => {
if (dragging){
var origin = pan.LocationInView(View);
Console.WriteLine ("dragging at {0}", origin);
var translated = pan.TranslationInView(contentView);
var cf = contentView.Frame;
@srkirkland
srkirkland / xamarinslowcamera.cs
Created February 6, 2015 07:25
animate camera
var newPosition = newMarker.Spec.GeoPoint;
var camera = mapView.Camera;
mapView.CameraPositionIdle += MapAnimateForSwipeComplete;
CATransaction.Begin ();
CATransaction.AnimationDuration = 2.0;
mapView.Animate (CameraUpdate.SetTarget (newPosition.ToCLLocationCoordinate2D (), camera.Zoom - 1));
CATransaction.Commit ();
@srkirkland
srkirkland / overlay.cs
Created February 19, 2015 08:09
rotation overlay
var centerImg = new UIImageView (UIImage.FromBundle ("findme_fab"));
centerImg.Frame = new RectangleF (
centerX - (centerImg.Frame.Width / 2) ,
centerY - centerImg.Frame.Height - 20 ,
centerImg.Frame.Width ,
centerImg.Frame.Height);
var animation = CABasicAnimation.FromKeyPath("transform.rotation.z");
animation.From = NSNumber.FromFloat (0.0f);
animation.To = NSNumber.FromFloat (2f * (float)Math.PI);
animation.Duration = 1f;
@srkirkland
srkirkland / pulse.cs
Created February 24, 2015 08:45
upvote pulse animation
var pulseAnimation = CABasicAnimation.FromKeyPath ("transform.scale");
pulseAnimation.Duration = 0.15;
pulseAnimation.To = NSNumber.FromFloat(1.5f);
pulseAnimation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
pulseAnimation.AutoReverses = true;
pulseAnimation.RepeatCount = 2;
_upvoteView.Layer.AddAnimation (pulseAnimation, "scalepulse");
@srkirkland
srkirkland / camera.cs
Created May 6, 2015 02:09
request and check for camera access
var status = AVCaptureDevice.GetAuthorizationStatus (AVMediaType.Video);
if (status == AVAuthorizationStatus.Authorized) {
//yay
} else if (status == AVAuthorizationStatus.NotDetermined) {
AVCaptureDevice.RequestAccessForMediaType (AVMediaType.Video, (bool accessGranted) => {
if (accessGranted) {
//yay
} else {
//boo
@srkirkland
srkirkland / frag.sql
Created May 20, 2015 00:05
database fragmentation
SELECT name, avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats (
DB_ID(N'PrePurchasing')
, OBJECT_ID('PrePurchasing')
, NULL
, NULL
, NULL) AS a
JOIN sys.indexes AS b
ON a.object_id = b.object_id AND a.index_id = b.index_id;
@srkirkland
srkirkland / sqlstats.sql
Created May 20, 2015 22:01
overall sql stats for the last week
SELECT
avg(avg_cpu_percent) AS 'Average CPU Percentage Used',
max(avg_cpu_percent) AS 'Maximum CPU Percentage Used',
avg(avg_physical_data_read_percent) AS 'Average Physical IOPS Percentage',
max(avg_physical_data_read_percent) AS 'Maximum Physical IOPS Percentage',
avg(avg_log_write_percent) AS 'Average Log Write Percentage',
max(avg_log_write_percent) AS 'Maximum Log Write Percentage',
--avg(avg_memory_percent) AS 'Average Memory Used Percentage',
--max(avg_memory_percent) AS 'Maximum Memory Used Percentage',
avg(active_worker_count) AS 'Average # of Workers',
@srkirkland
srkirkland / rebuild.sql
Created May 20, 2015 22:02
helpful rebuild your indexes script
SELECT name, OBJECT_NAME(a.object_id), avg_fragmentation_in_percent,
'ALTER INDEX ' + b.name + ' ON ' + OBJECT_NAME(a.object_id) +' REBUILD WITH (STATISTICS_NORECOMPUTE = ON)' as command
FROM sys.dm_db_index_physical_stats (
DB_ID(N'PrePurchasing')
, OBJECT_ID('PrePurchasing')
, NULL
, NULL
, NULL) AS a
JOIN sys.indexes AS b
ON a.object_id = b.object_id AND a.index_id = b.index_id