Skip to content

Instantly share code, notes, and snippets.

@lot224
lot224 / bookmarklet.js
Created January 18, 2019 18:37
Inject ng app into running website via bookmarklet. (If security allows for it.)
/**
* Bookmarklet code, this will inject a script into what ever page your currently visiting when you click this favorite/bookmark link.
* To install, just create a favorite/bookmark, then view the properties of is and change the name to something familiar.
* Update the url to the next line, also you will need to modify the src attribute so that it points to the payload script you want to inject.
*/
javascript: (function () { var d = document; var h = d.getElementsByTagName('head')[0]; var s = d.createElement("script"); s.setAttribute("type", "text/javascript"); s.setAttribute("src", "http://www.somedomain.com/somescript.js"); h.appendChild(s); })();
@lot224
lot224 / ipsum.cs
Created June 8, 2016 19:12
C# Ipsum Class for generating random data
public static class Ipsum {
private static Random random;
public static Random Random {
get {
if (random == null) random = new Random();
return random;
}
}
@lot224
lot224 / example.js
Created May 16, 2016 17:34
Angular, reuse a $q promise if not resolved.
var factoryItem = ["$q", function ($q) {
var factory = {};
var pendingPromises = {};
factory.test = function (identifier) {
// Assigns d to the variable that will contain the promise if pending.
var d = pendingPromises[identifier];
@lot224
lot224 / query.cs
Created April 18, 2016 18:45
Run string linq query
StringBuilder queryString = new StringBuilder("SELECT [System.Id]" +
" FROM WorkItemLinks " +
" WHERE [Source].[System.WorkItemType] = '" + TFS_TIMESHEET_WORK_ITEM_TYPE + "'" +
" AND [Source].[System.TeamProject] = '" + TFS_TIMESHEET_PROJECT_KEY + "'" +
" AND [Source].[System.Id] = " + id
);
Query wiQuery = new Query(GetWorkItemStore, queryString.ToString());
WorkItemLinkInfo[] wiTrees = wiQuery.RunLinkQuery();
@lot224
lot224 / prototype.js
Created April 15, 2016 15:29
javascript string.format like c# (ish)
if (!String.prototype.format) {
String.prototype.format = function () {
var n = this;
for (var i = 0; i < arguments.length; i++) {
var e = new RegExp('\\{' + (i) + '\\}', 'gm');
n = n.replace(e, arguments[i]);
}
return n;
}
}
@lot224
lot224 / formControlDropDown.html
Created January 15, 2016 10:05
Bootstrap Form Control Dropdown Example
<div class="input-group">
<span class="input-group-addon">Label Name</span>
<div class="dropdown input-group" id="DropDownId">
<ul class="dropdown-menu" style="width:100%">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
{"feed":{"author":{"name":{"label":"iTunes Store"}, "uri":{"label":"http://www.apple.com/itunes/"}}, "entry":[
{"im:name":{"label":"Inside Out (2015)"}, "im:image":[
{"label":"http://is4.mzstatic.com/image/thumb/Video69/v4/f8/f4/16/f8f41613-6e2f-6ea3-2125-8eb02d5c029a/pr_source.lsr/60x60bb-85.jpg", "attributes":{"height":"60"}},
{"label":"http://is4.mzstatic.com/image/thumb/Video69/v4/f8/f4/16/f8f41613-6e2f-6ea3-2125-8eb02d5c029a/pr_source.lsr/60x60bb-85.jpg", "attributes":{"height":"60"}},
{"label":"http://is5.mzstatic.com/image/thumb/Video69/v4/f8/f4/16/f8f41613-6e2f-6ea3-2125-8eb02d5c029a/pr_source.lsr/170x170bb-85.jpg", "attributes":{"height":"170"}}], "summary":{"label":"Growing up can be a bumpy road, and it's no exception for Riley, who is uprooted from her Midwest life when her father starts a new job in San Francisco. Like all of us, Riley is guided by her emotions – Joy (Amy Poehler), Fear (Bill Hader), Anger (Lewis Black), Disgust (Mindy Kaling) and Sadness (Phyllis Smith). The emotions live in H
@lot224
lot224 / Horizontal.js
Last active September 9, 2015 03:04
Generate Hexagon Points
var horizontalHexagonPoints = function (canvas, radius) {
var size = {
width: radius * 2,
height: (radius / 2 * Math.sqrt(3)) * 2
};
var rows = Math.ceil(canvas.height / size.height) + 1;
var columns = Math.ceil(canvas.width / (radius / 2 * 3)) + 1;
@lot224
lot224 / extend.js
Created December 19, 2014 20:13
simple javascript extend function
var extend = function () {
if (arguments.length == 0)
return {};
if (arguments.length == 1)
return arguments[0];
var nResult = {};
for (var i = 0; i < arguments.length; i++) {
@lot224
lot224 / concatenate.cs
Last active August 29, 2015 14:11
MS Build Tasks, concatenate, templates
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace eo {
public class Concatenate : Task {