Skip to content

Instantly share code, notes, and snippets.

Avatar

Thanos Polychronakis thanpolas

View GitHub Profile
@thanpolas
thanpolas / stdquote.js
Created Jun 6, 2021
Normalize all UTF quotes in Javascript
View stdquote.js
/**
* Will normalize quotes in a given string. There are many variations of quotes
* in the unicode character set, this function attempts to convert any variation
* of quote to the standard Quotation Mark - U+0022 Standard Universal: "
*
* @param {string} str The string to normalize
* @return {string} Normalized string.
* @see https://unicode-table.com/en/sets/quotation-marks/
*/
helpers.stdQuote = (str) => {
View keybase.md

Keybase proof

I hereby claim:

  • I am thanpolas on github.
  • I am thanpolas (https://keybase.io/thanpolas) on keybase.
  • I have a public key ASCWHXwoj4IjP1CA1lp-qmFAHe3t_kebLO6KeNNWzK5XBgo

To claim this, I am signing this object:

@thanpolas
thanpolas / hidden-iframe.js
Last active Aug 8, 2018
In the absence of CORS support the Hidden Iframe technique is the only way to submit a big amount of data (over 2kb that jsonp can handle).
View hidden-iframe.js
/**
* @fileOverview Hidden iFrame implementation for browsers without CORS.
*
* Usage:
* var iframe = new Iframe();
* iframe.submit(url, {data: yourData}, function(err) {});
*
* The server will get a POST request on the defined URL with the data
* JSON encoded in the body attribute named "data".
*/
View dabblet.css
/**
* the mark
*/
body {
text-align: center;
margin-top: 20px;
}
.thanpolas {
font-size: 202px;
-webkit-border-radius: 12px;
@thanpolas
thanpolas / singleton-class.js
Created Sep 16, 2016
ES6 Singleton Pattern
View singleton-class.js
/**
* @fileOverview Singleton pattern on ES6.
*/
import logger from './logger.midd';
/**
* The class statement.
*
*/
@thanpolas
thanpolas / test.js
Created Apr 11, 2013
Testing promises with mocha
View test.js
var assert = require('chai').assert;
var when = require('when');
var def1 = when.defer();
function getProm() {
return def1.promise;
}
@thanpolas
thanpolas / Gruntfie.js
Last active Dec 26, 2015
Grunt Config for node server + livereload
View Gruntfie.js
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
express: {
options: {
// Override defaults here
},
web: {
options: {
@thanpolas
thanpolas / doodle.js
Created Jun 11, 2013
Promises doodle
View doodle.js
function retProm() {
var def = when.defer();
return def.resolve();
}
console.log('one');
retProm().then(function(){console.log('two'));
console.log('three');
@thanpolas
thanpolas / Gruntfile.js
Last active Dec 18, 2015
Node Server + Grunt Watch Tasks + Livereload using one command: grunt
View Gruntfile.js
module.exports = function (grunt) {
grunt.initConfig({
watch: {
options: {
livereload: true
},
// triggering livereload when the .css file is updated
// (compared to triggering when sass completes)
// allows livereload to not do a full page refresh
styles: {
@thanpolas
thanpolas / perf.js
Last active Dec 16, 2015
when.sequence execution penalty
View perf.js
//var PerfTime = require('perf-time');
//var _ = require('underscore');
var Perf = module.exports = function() {
this.startTime = null;
// this.t = new PerfTime();
this.t = {
get: function() {
return Date.now();
}