This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([], function () { | |
"use strict"; | |
function parse(querystring) { | |
var obj = {}; | |
if (querystring) { | |
var params = querystring.split(/&|\?/); | |
for (var i = 0; i < params.length; i++) { | |
var param = params[i]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using StackExchange.Redis; | |
namespace ConsoleApplication1 | |
{ | |
public static class RedisExtensions | |
{ | |
public static RedisValue Get(this IDatabase db, RedisKey key, Func<RedisValue> loadFunc, TimeSpan slidingDuration) | |
{ | |
var ret = db.StringGet(key); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ko from 'knockout'; | |
import $ from 'jquery'; | |
var templateFromUrlLoader = { | |
loadTemplate(name, templateConfig, callback) { | |
if (templateConfig.fromUrl) { | |
var fullUrl = templateConfig.fromUrl; | |
$.get(fullUrl, markupString => { | |
ko.components.defaultLoader.loadTemplate(name, markupString, callback); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// traditional version | |
function toggleValueInArray1(val, arr) { | |
var ix = arr.indexOf(val); | |
if(ix === -1){ | |
// add to array | |
arr.push(val); | |
} | |
else | |
{ | |
// remove from array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const angular = require("angular"); | |
angular | |
.module("modulename") | |
.directive('attachFocusFunction', function($parse) { | |
return { | |
scope: false, | |
link(scope, element, attributes) { | |
let expr = $parse(attributes.attachFocusFunction); | |
if(!expr.assign){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Returns a new array, with the element at pos replaced with replacement item or calling the replacement function on arr[pos] | |
function changeAtIndex(arr, pos, replacement) { | |
if (typeof replacement == "function") { | |
replacement = replacement(arr[pos]); | |
} | |
return [...arr.slice(0, pos), replacement, ...arr.slice(pos + 1)]; | |
} | |
// Returns a new array, with the first element matching the predicate function replaced with replacement item or calling the replacement function on arr[pos] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const angular = require("angular"); | |
const _ = require("lodash"); | |
angular | |
.module("modulename") | |
.directive("componentBinder", function($compile, $parse) { | |
return { | |
restrict: "E", | |
scope: { | |
componentName: "<", | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.1.0", | |
"command": "mocha", | |
"isShellCommand": true, | |
"showOutput": "silent", | |
"args": [ | |
"--reporter", | |
"tap", | |
"--colors" | |
], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Function to turn node style functions with callbacks into promises. | |
// This is useful when using async/await, since promises can be awaited upon. | |
const callback = (resolve, reject) => (err, res) => err ? reject(err) : resolve(res); | |
const awaitable = async action => new Promise((resolve, reject) => action(callback(resolve, reject))) | |
module.exports = awaitable; | |
// Usage: | |
// const fs = require("fs"); | |
// const awaitable = require("./awaitable"); |
OlderNewer