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
/** | |
* Given an object with a property, it tests if the property is a number and returns the round of that | |
* Otherwise returns the value provided by defaultValue, or null | |
* @param obj The object that contains the property to test | |
* @param prop The property that will be tested | |
* @param decimalsToRound The number of decimals to round to | |
* @param defaultValue The default value provided if it cannot complete the transaction | |
*/ | |
export const roundOrDefault = (obj: any, prop: string, decimalsToRound: number, defaultValue = null) => { | |
if (!obj) { |
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
from django.conf.urls import url | |
from django.core.urlresolvers import reverse_lazy | |
from django.contrib.auth.views import password_reset, password_reset_done, password_reset_confirm, password_reset_complete | |
urlpatterns = [ | |
url(r'^$', password_reset, {'post_reset_redirect' : reverse_lazy('password_reset_done')}, name="password_reset"), | |
url(r'^done/$', password_reset_done, name="password_reset_done"), | |
url(r'^(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$', password_reset_confirm, {'post_reset_confirm': reverse_lazy('password_reset_complete')}, name="password_reset_confirm"), | |
url(r'^complete$', password_reset_complete, name="password_reset_complete"), | |
] |
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 commandManager = workbook.commandManager(); | |
commandManager.register('showListDown', () => openDropdown(sheet, workbook)); | |
commandManager.setShortcutKey('showListDown', GC.Spread.Commands.Key.down, false, false, true); |
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
export const getListValidatorFromArray = (spread: GC.Spread.Sheets.Workbook, data: any[]) => { | |
// saving validation list values in a hidden sheet | |
spread.addSheet(spread.getSheetCount()); | |
const sheet = spread.getSheet(spread.getSheetCount() - 1); | |
sheet.visible(false); | |
for (let i = 0; i < data.length; i++) { | |
sheet.setValue(i, 0, data[i]); | |
} | |
// create validator based on the values | |
const dv = GC.Spread.Sheets.DataValidation.createFormulaListValidator( |
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 System.Collections.Generic; | |
using System.Configuration; | |
using System.IO; | |
using System.Runtime.Serialization.Formatters.Binary; | |
using StackExchange.Redis; | |
using WebApp; | |
namespace ClassLib.CacheExtension |
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
/* | |
Example for quick Java compilation and unit tests in VS Code. | |
Works well with simple BlueJ projects. | |
Hit Ctrl+Shift+B to compile currently open file with javac. | |
Hit Ctrl+Shift+T to test currently open test class. | |
See red wiggles for compilation errors / failed assertions or click exclamation mark in the status bar. | |
Uses a few workarounds for individual commands per task and filename without extension. | |
This is written for Windows but it should be easy to adopt for Linux and Mac. | |
*/ | |
{ |
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
var Person = function(firstAndLast) { | |
//this.fullName = firstAndLast; | |
var fullName = firstAndLast; | |
var splitName = fullName.split(" "); | |
var first = splitName[0]; | |
var last = splitName[1]; | |
this.getFirstName = function (){ | |
//return first; | |
return fullName.split(" ")[0]; |
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 binaryAgent(str) { | |
var parsedString = str.split(" "); | |
for (i=0; i<parsedString.length; i++){ | |
parsedString[i] = String.fromCharCode(parseInt(parsedString[i],2)); | |
} | |
str = parsedString.join(""); | |
return str; | |
} |
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 steamroller(arr) { | |
// I'm a steamroller, baby | |
return arr.reduce(function (flat, toFlatten) { | |
return flat.concat(Array.isArray(toFlatten) ? steamroller(toFlatten) : toFlatten); //ternary | |
}, []); | |
/* | |
Uses the same concat flatten example on the MDN, but with recursion to further flatten | |
ex: | |
var flattened = [[0, 1], [2, 3], [4, 5]].reduce(function(a, b) { |
NewerOlder