Skip to content

Instantly share code, notes, and snippets.

/*
ways to calculate the number of blocks of used to build a pyramid
*/
var numberOfBlocksInPyramid = function(edgeLength,intialCount) {
if (edgeLength==0) return intialCount;
var atLevel=edgeLength*edgeLength;
console.log(edgeLength + " " + atLevel + " " + intialCount);
intialCount=atLevel+intialCount;
return numberOfBlocksInPyramid(--edgeLength, intialCount);
}
@cullen-tsering
cullen-tsering / gist:19c78587a14d65a67efb
Last active August 29, 2015 14:23
Xamarin Widget Helper
public static class WidgetHelper
{
// sets text and move caret to the end of the line
public static void SetText (this EditText edt, string textToSet){
edt.Text = textToSet;
edt.Append("");
}
}
@cullen-tsering
cullen-tsering / XamarinApp
Created October 31, 2014 21:40
Xamarin App
using System;
using Android.App;
using Android.Runtime;
using Android.Util;
namespace VelocityTab
{
[Application]
public class App : Application
{
@cullen-tsering
cullen-tsering / SpitOutAndroidAppDir
Last active May 6, 2016 14:47
Spit Out Android Directories
foreach (Environment.SpecialFolder s in (Environment.SpecialFolder[])Enum.GetValues(typeof(System.Environment.SpecialFolder)))
{
Android.Util.Log.Info("App", string.Format("Environment.SpecialFolder.{0}::{1}",Enum.GetName(typeof(Environment.SpecialFolder),s),Environment.GetFolderPath(s)));
}
/* output starts */
/*
Environment.SpecialFolder.Desktop::/data/data/{package name}/files/Desktop
Environment.SpecialFolder.Programs::
@cullen-tsering
cullen-tsering / IsNumeric
Created August 6, 2014 19:47
string extension IsNumeric in c#
public static class StringExtension
{
public static bool IsNumeric(this string str)
{
double n;
return Double.TryParse(str, out n);
}
}
@cullen-tsering
cullen-tsering / ConstantsToKVPair
Last active August 29, 2015 14:04
Get Constant value and names in a dictionary
public class DoingConstants
{
public const string Flying = "F";
public const string Walking = "W";
public const string Crawling = "C";
public const string Scooting = "R";
static Dictionary<string,string> _asDictionary;
public static Dictionary<string, string> AsDictionary
{
@cullen-tsering
cullen-tsering / ConstUsingAngularService
Last active August 29, 2015 14:03
Using Angular Service to return constants
// @dankapusta on twitter sent me a link to
// http://stackoverflow.com/questions/13015523/angular-js-is-value-the-proper-way-to-set-app-wide-constant-and-how-to-retri
// so changing service to const to
//code omitted
.constant('Consts',
{
const1: {
yes: 1,
no: 2,
@cullen-tsering
cullen-tsering / Custom schedule sorter
Created May 4, 2014 22:43
An architectural decision and simple custom sorting
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
// Read in every line in the file.
var list = new List<JobSchedule>{
@cullen-tsering
cullen-tsering / TitleCaseToDelimited
Created April 19, 2014 13:16
Formatting / Splitting string from Title Case to Delimited Words
namespace tests
{
[TestClass]
public class string_extension_tests
{
[TestMethod]
public void when_formatting_title_case_to_delimited_but_the_delimiter_is_not_specified()
{
var s = "ThisIsTheDayThatTheLordHasMade";
var formated = s.TitleCaseToDelimited();