Skip to content

Instantly share code, notes, and snippets.

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

<jaxcoder /> codenamejason

:octocat:
🫠
View GitHub Profile
@codenamejason
codenamejason / Encoder.js
Created December 6, 2017 15:31
Encoder for classifier
// Encoder for classifier
function jquerySelectorEncode(nameToEncode) {
var encodedString = nameToEncode.replace(/\./g, "\\.");
encodedString = encodedString.replace(/\:/g, "\\:");
encodedString = encodedString.replace(/\\/g, "\\\\");
encodedString = encodedString.replace(/\#/g, "\\#");
encodedString = encodedString.replace(/\//g, "\\/");
encodedString = encodedString.replace(/\s/g, "\\");
encodedString = encodedString.replace(/\"/g, "\\\"");
encodedString = encodedString.replace(/\'/g, "\\\'");
@codenamejason
codenamejason / GetMatchingItemFromSelectables.js
Created December 6, 2017 15:29
Get Matching Item From Selectables
function GetMatchingItemFromSelectables(item, selectablesList) {
var chosenIndex = -1;
if (item !== undefined && item !== null) {
if (item.Key !== undefined) {//this section is deprecated, old way of doing selectables
for (var t = 0; t < selectablesList.length; t++) {
if (selectablesList[t].Key === item.Key) {
return selectablesList[t];
}
@codenamejason
codenamejason / GetIndexes.sql
Created December 6, 2017 14:36
Get the indexes for an object
SELECT *
FROM sys.indexes
WHERE
--name='YourIndexName' AND
object_id = OBJECT_ID('<SCHEMA>.<TABLE>')
var validation = {
isEmailAddress:function(str) {
var pattern =/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
return pattern.test(str); // returns a boolean
},
isNotEmpty:function (str) {
var pattern =/\S+/;
return pattern.test(str); // returns a boolean
@codenamejason
codenamejason / numericText.js
Created September 18, 2017 16:22
Converts number to money for knockout.js
ko.bindingHandlers.numericText = {
update: function(element, valueAccessor, allBindingsAccessor) {
var value = ko.utils.unwrapObservable(valueAccessor());
var precision = ko.utils.unwrapObservable(allBindingsAccessor().precision) ||
ko.bindingHandlers.numericText.defaultPrecision;
if (value === undefined || value === null) {
return;
}
var formattedValue = Number(value).toFixed(precision);
ko.bindingHandlers.text.update(element,
@codenamejason
codenamejason / GetAllProperties.js
Created August 24, 2017 14:12
This can be useful to reveal "hidden" properties (properties in the prototype chain which are not accessible through the object, because another property has the same name earlier in the prototype chain). Listing accessible properties only can easily be done by removing duplicates in the array.
function listAllProperties(o) {
var objectToInspect;
var result = [];
for(objectToInspect = o; objectToInspect !== null; objectToInspect = Object.getPrototypeOf(objectToInspect)) {
result = result.concat(Object.getOwnPropertyNames(objectToInspect));
}
return result;
}
function validateEmail()
{
var emailID = document.myForm.EMail.value;
atpos = emailID.indexOf("@");
dotpos = emailID.lastIndexOf(".");
if (atpos < 1 || ( dotpos - atpos < 2 ))
{
alert("Please enter correct email ID")
document.myForm.EMail.focus() ;
@codenamejason
codenamejason / ko-money.js
Last active July 26, 2017 19:25 — forked from jakiestfu/ko-money.js
Used to display formatted money via Knockout binding
(function(){
var toMoney = function(num){
if(num === null || num === undefined){
return 0;
}
// Use this if your number is a string:
// return '$' + (Number(num).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,') );
return '$' + (num.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,') );
};
@codenamejason
codenamejason / Scrambler.js
Created July 13, 2017 23:42
Scrables a string to privatize it
function Encode(str) {
// Rreplace every letter in the string with the letter following it
// by first getting the charCode number of the letter, adding 1 to it, then
// converting this new charCode number to a letter using the fromCharCode function
// we also check to see if the character is z and if so we simply convert the z to an a
var codedString = str.replace(/[a-z]/gi,
function(char) {
return (char === 'z' || char === 'Z') ? 'a' : String.fromCharCode(char.charCodeAt() + 1);
});
public class ToggleVR : MonoBehavior
{
// Toggle VR settings.
private void Update ()
{
// If V is pressed, VRSettings.enabled
if(Input.GetKeyDown(KeyCode.V))
{
VRSettings.enabled = !VRSettings.enabled;
Debug.Log("Changed VRSettings.enabled to: " + VRSettings.enabled);