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
/** | |
* Original code developed by Robert Nyman, http://www.robertnyman.com | |
* Code/licensing: http://code.google.com/p/getelementsbyclassname/ | |
* | |
* Arcnovus modifications: | |
* - Tweaked code to pass JSLint validation (all vars declared together, no more assignment in expressions). | |
* - Added 'item' method to array returned in order to mimick nodeList | |
*/ | |
(function (window, document) { | |
'use strict'; |
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
/** | |
* This Gist has been modified to use a custom flag on the config object instead of an HTTP Header in order to | |
* indicate wether or not to specifically handle the error. | |
* THIS CODE IS UNTESTED!! | |
*/ | |
//var HEADER_NAME = 'MyApp-Handle-Errors-Generically'; // We don't want to use Headers, we use a flag on the config object instead | |
var specificallyHandleInProgress = false; | |
angular.module('myApp').factory('RequestsErrorHandler', ['$q', function($q) { |
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
# Install the Parse Command Line Tool | |
export TMP_FILE=/tmp/parse.tmp | |
export latest=`curl -X GET https://api.parse.com/1/supported?version=latest|grep -Po '(\d.\d.\d)'` | |
export url="https://github.com/ParsePlatform/parse-cli/releases/download/release_${latest}/parse_linux" | |
curl --progress-bar --compressed -Lo ${TMP_FILE} ${url} | |
mv /tmp/parse.tmp ${HOME}/bin/parse | |
chmod 755 ${HOME}/bin/parse | |
# Avoid login prompt by using a Parse account key | |
# Note: Make sure you have created an account key at https://dashboard.parse.com/account/overview |
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 s = "some_string_to_change", | |
len= s.length, | |
i, | |
upped = false; | |
result = ""; | |
for(i=0;i<len;i++) { | |
if(s[i] === "_") { | |
result += s[i+1].toUpperCase(); | |
upped = 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
var s = "some_string_to_change", | |
len= s.length, | |
i, | |
upped = false; // we will use this to make sure we don't double count a character | |
result = ""; // this is where we will store the result | |
for(i=0;i<len;i++) { | |
if(s[i] === "_") { // if we find an underscore | |
result += s[i+1].toUpperCase(); // add the next character, uppercased, to our result | |
upped = true; // make sure we don't add this character again |
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 s = "some_string_to_change", | |
a = s.split("_"), // this gives us 4 strings and removes the underscore | |
result = a[0]; // this adds the first string to our result | |
for(i=1;i<a.length;i++) { // loop through each string | |
result+= a[i][0].toUpperCase(); // append the uppercase first letter of the string | |
result+= a[i].substring(1); // append the rest of the string | |
} | |
console.log(result); // log the result to the console |
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 s = "some_string_to_change", | |
result = s.replace(/_./g, rep); // do a global search (g) for an "_" followed by a single character (.) and run the rep function each time | |
function rep(v) { | |
return v[1].toUpperCase(); // return the second character of the matched string, uppercased. | |
} | |
console.log(result); |
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 requiredParam (param) { | |
const requiredParamError = new Error( | |
`Required parameter, "${param}" is missing.` | |
) | |
// preserve original stack trace | |
if (typeof Error.captureStackTrace === ‘function’) { | |
Error.captureStackTrace( | |
requiredParamError, | |
requiredParam | |
) |
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
'use strict'; // avoid ambiguity and sloppy errors | |
/** | |
* Tests whether or not a given string is a Palindrome | |
* @param {string} stringToTest - the string to test. | |
*/ | |
function isPalindrome(stringToTest) { | |
if (typeof stringToTest !== "string") { | |
throw new TypeError("isPalindrome() expected a string, but got " + | |
Object.prototype.toString.call(stringToTest) + " instead!"); |
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
// A custom React Hook for using CKEditor with SSR | |
// particularly with NextJS. | |
// https://ckeditor.com | https://nextjs.org | |
import React, { useRef, useState, useEffect } from 'react' | |
export default function useCKEditor () { | |
const editorRef = useRef() | |
const [isEditorLoaded, setIsEditorLoaded] = useState(false) | |
const { CKEditor, InlineEditor } = editorRef.current || {} |
OlderNewer