Skip to content

Instantly share code, notes, and snippets.

View JsAndDotNet's full-sized avatar

Justin JsAndDotNet

View GitHub Profile
@JsAndDotNet
JsAndDotNet / Print Javascript Array Of Properties As Angular Scope Assignment and Bindings
Last active August 29, 2015 14:12
Create AngularJs assigments from an array of different javascript properties (can convert from json first)
var printJavascriptArrayOfPropsAsAngularScopeAssignment = function (longArrayOfProperties, useOneTimeBindingSyntax) {
/// <summary>Takes a long list of properties, strips the names,
/// creates angular.js assignments/ bindings and outputs to console for copy+paste
///
/// - If you have an array of Json data, use angular.fromJson(jsonString) or JSON.parse(jsonString) first to get it in the right format
/// View the output in your javascript console (e.g. in Chrome)
/// Example Input -> var myProps = { myProperty1: 3, MyProperty2: 'Dave' };
/// Example Output
/// $scope.myProperty = inputData.myProperty;
/// $scope.myProperty2 = inputData.MyProperty2;
@JsAndDotNet
JsAndDotNet / AngularJS Replace String Filter
Created January 7, 2015 16:21
Using AngularJS, this method takes a string bound in the UI and replaces it as required
// Usage
// {{myIntValue | number:0 | replacestringfilter:',':'.'}}
// {{myStringValue | replacestringfilter:'ABC':'DEF'}}
myApp.filter('replacestringfilter', function () {
return function (item, oldstring, newstring) {
if (!item)
return item;
var sItem = item.toString();
var find = oldstring;
var re = new RegExp(find, 'g');
@JsAndDotNet
JsAndDotNet / An Over-Engineered Console to Perform a Function every x milliseconds
Created February 5, 2015 20:59
An Over-Engineered Console to Perform a Function Every x Seconds / Milliseconds
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestConsole
{
public interface IProcessor
{
@JsAndDotNet
JsAndDotNet / gist:dbc24179da9e0015ce10
Last active August 29, 2015 14:25
Android SDK: Converting SeekBar to Value (and back) when the seekers start value is greater than zero
/**
* The seekbars min value cannot be changed in the sdk. It has to be zero
* Total = 240seconds represented
* Start Value = 30 seconds
* Each interval of the seekbar = 5 seconds.
* <SeekBar
android:id="@+id/settings_seekbar_time_interval"
android:layout_span="2"
android:minWidth="200dp"
android:max="42"
@JsAndDotNet
JsAndDotNet / sort.js
Created January 8, 2016 12:04
OrderBy on Array based on Properties, taken from Javscript: The Good Parts, by Douglas Crockford
// This might need tweaking for uppercase/lowercase comparisons
// Source - Javscript: The Good Parts, by Douglas Crockford
var by = function (name, minor) {
// Array sorting
// myArray.sort(by('FirstName', by('LastName')));
return function (o, p) {
var a, b;
if (typeof o === 'object' && typeof p === 'object' && o && p) {
a = o[name];
@JsAndDotNet
JsAndDotNet / ip.html
Last active April 30, 2024 16:15
Get client ip address from html page without going to an external website.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>IP Address</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
<link rel="stylesheet" href="css/styles.css?v=1.0">
<script>
@JsAndDotNet
JsAndDotNet / calendar.html
Created February 10, 2017 09:52
Very basic starting point for iPhone style calendar using Html/JQuery
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
<link rel="stylesheet" href=""/>
<!-- http://qnimate.com/javascript-scroll-by-dragging/ -->
@JsAndDotNet
JsAndDotNet / Main.cs
Created March 24, 2017 16:36
Web API with body content and C# / Html Calls
// Calling client
class Program
{
static void Main(string[] args)
{
string answer = "";
//string baseUrl = "http://localhost:56539/";
string baseUrl = "http://169.254.80.80/winauth/";
@JsAndDotNet
JsAndDotNet / incrementversionnumber.ps1
Created September 1, 2017 10:31
Powershell Check Out / In Document from VSTS (TFS)
Add-PSSnapin Microsoft.TeamFoundation.PowerShell
# This file requires the TFS Power Tools (2015+). When installing, you must select Custom Installation and select PowerShell Cmdlets
# *VSTS Login*
# YOU MUST go to 'Options' and turn on 'Allow scripts to access OAuth token' for the buld
$url = "$($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)$env:SYSTEM_TEAMPROJECTID/_apis/build/definitions/$($env:SYSTEM_DEFINITIONID)?api-version=2.0"
Write-Host "URL: $url"
$definition = Invoke-RestMethod -Uri $url -Headers @{
Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
}
@JsAndDotNet
JsAndDotNet / start-a-build-with-name-x-and-wait.ps1
Created September 8, 2017 15:32
Start a TFS/ VSTS Build And Wait For Completion
Add-PSSnapin Microsoft.TeamFoundation.PowerShell
#Add-Type -Path "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.Client.dll"
# *VSTS Load Above* Load the TFS powershell
# NOTE: Must allow build to access tokens in the options
Clear-Host
$buildToStart = "My-Build-Name e.g. Test - CLI"
$newLine = [System.Environment]::NewLine