Skip to content

Instantly share code, notes, and snippets.

View arcdev1's full-sized avatar

Bill Sourour arcdev1

  • Arcnovus
  • Ottawa, Canada
View GitHub Profile
/**
* 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 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) {
@arcdev1
arcdev1 / deploy2parse.sh
Last active January 13, 2016 12:49
Deploy to Parse from Codeship
# 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
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;
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
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
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);
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
)
'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!");
@arcdev1
arcdev1 / use-ck-editor.js
Last active March 10, 2023 16:33
A custom React Hook for using CKEditor with SSR particularly with NextJS. https://ckeditor.com | https://nextjs.org
// 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 || {}