Skip to content

Instantly share code, notes, and snippets.

View erkobridee's full-sized avatar

Erko Bridee erkobridee

View GitHub Profile
@erkobridee
erkobridee / utils_hash.js
Last active January 25, 2019 21:03
node.js script to generate a hash value using the hash.js and the lodash
'use strict';
var _ = require('lodash'),
toHash = {}
;
//============================================================================//
// hash ids with mininum length = 8
var hashids = (function(){
@erkobridee
erkobridee / requestImageAsString.ts
Created January 23, 2019 13:59
example of how read an image from the server as a binary one and parse it to its base64 string
const readImageAsDataURL = async (imageBlob: Blob): Promise<string> => {
// https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL
const imageReader = new FileReader();
return new Promise<string>(resolve => {
const load = () => {
imageReader.removeEventListener('load', load);
resolve(imageReader.result as string);
};
imageReader.addEventListener('load', load, false);
imageReader.readAsDataURL(imageBlob);
// https://github.com/rexxars/react-markdown
// https://github.com/GregRos/typed-react-markdown
import * as ReactMarkdown from 'react-markdown';
<ReactMarkdown linkTarget="_blank">
  {intl.formatMessage(translations.message_with_links)}
/*
useful references:
String.prototype.replace()
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace
https://alligator.io/js/string-replace/
Encode and Decode HTML entities using pure Javascript
https://ourcodeworld.com/articles/read/188/encode-and-decode-html-entities-using-pure-javascript

Keybase proof

I hereby claim:

  • I am erkobridee on github.
  • I am erkobridee (https://keybase.io/erkobridee) on keybase.
  • I have a public key whose fingerprint is 8663 C7F5 106D 5DA5 15C2 5150 D108 59CA 450F 69E1

To claim this, I am signing this object:

@erkobridee
erkobridee / learn_angularjs.md
Last active September 14, 2017 15:14
learn angular.js (1.x)
@erkobridee
erkobridee / about_npm_deps_version.md
Created June 29, 2017 18:38
about set npm dependencies version

'^', '~', '<=', '*', ...

package.json > dependencies and devDependencies

exactly 1.3.2

"vendor/package": "1.3.2"
@erkobridee
erkobridee / prettyTime.js
Created May 20, 2017 02:04
output a pretty time string from a given milliseconds time
// value in milliseconds
function prettyTime(value){
var days = Math.floor(value/86400000);
value = value%86400000;
var hours = Math.floor(value/3600000);
value = value%3600000;
var minutes = Math.floor(value/60000);
value = value%60000;
var seconds = Math.floor(value/1000);
@erkobridee
erkobridee / spotlight_indexing.md
Created May 9, 2017 18:13
mac os enable/disable spotlight indexing

spotlight indexing

run as super user sudo

  • enable indexing
mdutil -a -i on
@erkobridee
erkobridee / example_01.js
Created April 19, 2017 03:12
es6 generators and symbols examples
function* shopping() {
// stuff on the sidewalk
// walking down the sidewalk
// go into the store with cash
const stuffFromStore = yield 'cash';
// walking to laundry place
const cleanClothes = yield 'laundry';