Skip to content

Instantly share code, notes, and snippets.

View codenamejason's full-sized avatar
:octocat:
🫠

<jaxcoder /> codenamejason

:octocat:
🫠
View GitHub Profile
function service(name, constructor) {
return factory(name, ['$injector', function($injector) {
return $injector.instansiate(constructor);
}]);
}
@codenamejason
codenamejason / provide.factory.js
Created December 12, 2016 16:45
Using $provide.factory
function factory(name, factoryFn, enforce) {
return provider(name, {
$get: enforce != false ? enforceReturnValue(name, factoryFn) : factoryFn
});
}
<time itemprop="openingHours" datetime="Mo,Fr 08:00-16:00">Monday Through Friday 8-6pm</time>
/*Logo*/
ImageObject =
priceRange = "$$$"
paymentAccepted = "Cash, Credit,Paypal"
@codenamejason
codenamejason / RandomString.cs
Created July 19, 2016 14:06
Creates random string in C#
public static string RandomString(int length)
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var random = new Random();
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray());
}
//This example creates a big list with a nested list for each item on the page, each with all of the property names used in that item.
var outer = document.createElement('ul');
var items = document.getItems();
for (var item = 0; item < items.length; item += 1) {
var itemLi = document.createElement('li');
var inner = document.createElement('ul');
for (var name = 0; name < items[item].properties.names.length; name += 1) {
var propLi = document.createElement('li');
propLi.appendChild(document.createTextNode(items[item].properties.names[name]));
<tr data-bind="css: {rowAlt: $data.isActive() && ($index() % 2 == 1), rowInactive: $data.isActive() == false}">
// Detect local storage on client computer
function localStorageSupported() {
try {
return "localStorage" in window &&
window["localStorage"] !== null;
}
catch (e)
{
return false;
}
[Service Contract]
public interface ImathService
{
[Operational Contract]
Int32 Sum(Int32 a, Int32 b);
[Operational Contract]
Int32 Difference(Int32 a, Int32 b);
[Operational Contract]
Int32 Product(Int32 a, Int32 b);
[Operational Contract]
// Fires function(s) on pageload
function() {
setTimeout("timerFinished()", 5000);
}
// Method called after time
function timerFinished() {
alert("5 Seconds Have Passed!");
}
// Add an image
function createImage() {
// Add to bottom of page(s)
var img = document.CreateElement('img');
img.setAttribute("src", "/images/image.png");
("id", );
("width", "250");
("height", "250");
("style", "");
// Adds to bottom of page(s)