Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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); })();
{[
"Acme Corp.",
"Aperture Science",
"Armacham",
"Bartok Science",
"Benthic Petroleum",
"Biffco Enterprises",
"Big Kahuna Burger",
"Black Mesa",
"Blue Sunv",
@lot224
lot224 / discordWebHook.cs
Created March 6, 2019 18:33
An very basic example of a Webhook in C# to Discord.
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
namespace discordWebHook
{
class Program
{
private static HttpClient client;
@lot224
lot224 / fileInput processing.html
Created July 29, 2019 20:05
Takes a Image uploaded via a FileInput element and resizes it, if it exceeds a certain size.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>FileInput -> Image -> Canvas -> Bytes</title>
</head>
@lot224
lot224 / TTT2.html
Created October 7, 2019 05:11
Sam's TTT2.html
<!doctype html>
<html>
<head>
<title>Tic Tac Toe</title>
<style>
button {
font-size: 40px;
height: 100px;
width: 100px;
@lot224
lot224 / menu.js
Created November 1, 2019 15:32
nodejs simple file menu
const fs = require('fs');
const path = require('path');
const readline = require('readline');
const cwd = process.cwd();
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
const files = [];
const filterExtension = null; // ".json"
@lot224
lot224 / main.js
Last active January 11, 2022 17:41
Flat Array of filenames to html tree structure.
const files = [
"path/1/pages/home.html",
"path/1/pages/about.html",
"path/1/pages/settings.html",
"path/1/pages/contact.html",
"path/1/assets/images/background.jpeg",
"path/1/assets/images/logo.png",
"path/1/assets/images/arrow-left.png",
"path/1/assets/images/arrow-right.png",