From cb4fddc56b072c7cf526a9d26bf87bfb418fa1b6 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Mon, 15 Aug 2016 17:50:23 +0200 Subject: [PATCH 1/4] new conversions: dec<->hex, dec<->bin --- .gitignore | 2 ++ dencode.js | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/.gitignore b/.gitignore index b25c15b..6d9446a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *~ +.idea/ +*.iml diff --git a/dencode.js b/dencode.js index f3897c8..a076423 100644 --- a/dencode.js +++ b/dencode.js @@ -99,6 +99,40 @@ } } }, + { + "id": "hextodec", + "name": "Decode hex as decimal", + "convert": function (input) { + try { + return { + "status": "OK", + "content": parseInt(input, 16).toString(10) + }; + } catch (exception) { + return { + "status": "ERROR", + "content": "Invalid number (integer) string." + }; + } + } + }, + { + "id": "bintodec", + "name": "Decode binary as decimal", + "convert": function (input) { + try { + return { + "status": "OK", + "content": parseInt(input, 2).toString(10) + }; + } catch (exception) { + return { + "status": "ERROR", + "content": "Invalid number (integer) string." + }; + } + } + }, { "id": "base64encode", "name": "Encode Base64", @@ -154,6 +188,40 @@ "content": quotedPrintable.encode(utf8.encode(input)) }; } + }, + { + "id": "dectohex", + "name": "Encode decimal as hex", + "convert": function (input) { + try { + return { + "status": "OK", + "content": parseInt(input).toString(16) + }; + } catch (exception) { + return { + "status": "ERROR", + "content": "Invalid number (integer) string." + }; + } + } + }, + { + "id": "dectobin", + "name": "Encode decimal as binary", + "convert": function (input) { + try { + return { + "status": "OK", + "content": parseInt(input).toString(2) + }; + } catch (exception) { + return { + "status": "ERROR", + "content": "Invalid number (integer) string." + }; + } + } } ]; From 56d6f1a0be03294da2b98457b8bde967af3e3097 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Mon, 15 Aug 2016 20:28:23 +0200 Subject: [PATCH 2/4] initial CI enabling --- .gitignore | 1 + .gitlab-ci.yml | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ deploy.sh | 21 ++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 deploy.sh diff --git a/.gitignore b/.gitignore index b25c15b..1f2b28d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *~ +.idea/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..6dc8594 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,78 @@ +variables: + NPMPATH: "node_modules/.bin" + +stages: +# - build +# - cleanup_build + - deploy +# - cleanup + +.run_deploy: &run_deploy + script: + - chmod +x ./deploy.sh + - ./deploy.sh + +#build_job: +# stage: build +# script: +# - npm install +# - $NPMPATH/bower install +# - $NPMPATH/grunt +# tags: +# - javascript +# except: +# - tags +# artifacts: +# paths: +# - dist/*.min.* +# - info/ +# - resources/ +# - index.html +# - manifest.appcache + +#cleanup_build_job: +# stage: cleanup_build +# script: +# - rm -rf node_modules +# - rm -rf bower_components +# - rm -rf dist +# when: on_failure + +develop: + stage: deploy + <<: *run_deploy + environment: develop + except: + - tags + - master + - develop + variables: + ENVIRON: develop + TARGET: $WWW_DEPLOY_ROOT_DEVELOP + +staging: + stage: deploy + <<: *run_deploy + environment: staging + only: + - develop + variables: + ENVIRON: staging + TARGET: $WWW_DEPLOY_ROOT_STAGING + +production: + stage: deploy + <<: *run_deploy + environment: production + only: + - master + variables: + ENVIRON: production + TARGET: $WWW_DEPLOY_ROOT_PRODUCTION + +#cleanup_job: +# stage: cleanup +# script: +# - rm -rf node_modules +# - rm -rf bower_components +# when: always diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..777b0ae --- /dev/null +++ b/deploy.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +declare destination +case "${TARGET}" in + "${WWW_DEPLOY_ROOT_DEVELOP}") + destination="${TARGET}/${CI_BUILD_REF_NAME}" + ;; + "${WWW_DEPLOY_ROOT_STAGING}"|"${WWW_DEPLOY_ROOT_PRODUCTION}") + destination="${TARGET}" + ;; + *) + echo "Invalid TARGET specified. Aborting deployment." + exit 1 + ;; +esac + +rm -rf "${destination}/*" +rm -rf "${destination}/.??*" +cp -a dencode.css dencode.js index.html quoted-printable.js utf8.js "${destination}" + +echo "Deployment successful." From 1a4e8f1c8cd2aecaa964e9d6eacc98b02df85996 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Mon, 15 Aug 2016 20:33:48 +0200 Subject: [PATCH 3/4] comment unneeded variable --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6dc8594..916c442 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ -variables: - NPMPATH: "node_modules/.bin" +#variables: +# NPMPATH: "node_modules/.bin" stages: # - build From bc6cd67d5429c766f472718a33d202c4a8dc7db3 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Mon, 15 Aug 2016 20:37:48 +0200 Subject: [PATCH 4/4] improved deployment script: create target directory if it doesn't exist --- deploy.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/deploy.sh b/deploy.sh index 777b0ae..ab6faf6 100644 --- a/deploy.sh +++ b/deploy.sh @@ -14,6 +14,10 @@ case "${TARGET}" in ;; esac +if [[ ! -d "${destination}" ]] ; then + mkdir -p "${destination}" || echo "Failed to create target directory for deployment!" +fi + rm -rf "${destination}/*" rm -rf "${destination}/.??*" cp -a dencode.css dencode.js index.html quoted-printable.js utf8.js "${destination}"