Skip to content

Instantly share code, notes, and snippets.

Aymeric Aymkdn

Block or report user

Report or block Aymkdn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Aymkdn
Aymkdn / htmlToPdf.js
Last active Jun 26, 2019
html to PdfMake convertor
View htmlToPdf.js
// source: https://github.com/OpenSlides/OpenSlides/blob/f4f8b8422f9b3fbab58e35ac3f8f870d35813b7d/client/src/app/core/ui-services/html-to-pdf.service.ts
// and https://github.com/bpampuch/pdfmake/issues/205
/**
To use it:
import htmlToPdf from './htmlToPdf.js'
htmlToPdf('<b>my bold text</b>');
*/
var LineNumberingMode = {
@Aymkdn
Aymkdn / linkify
Created Jun 5, 2018
Parse URL in a string and convert in a link
View linkify
var urlRegex =/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
function linkify(text, safeText) {
safeText = (safeText===false? false : true);
if (safeText) text=escapeHtml(text);
return text.replace(urlRegex, function(url) {
return '<a href="' + url + '">' + url + '</a>';
});
}
@Aymkdn
Aymkdn / notifier.js
Last active Nov 14, 2017
Have Google Home to speak
View notifier.js
// npm install castv2-client google-tts-api
var Client = require('castv2-client').Client;
var client = new Client();
var DefaultMediaReceiver = require('castv2-client').DefaultMediaReceiver;
var GoogleTTS = require('google-tts-api');
var host = "192.168.0.13"; // IP Address of the Google Home
var text = "Bonjour et bienvenue"; // Text to speach
var lang = "fr-FR"; // language
GoogleTTS(text, lang, 1)
.then(function(url) {
View htmlstring.xml
<?xml version="1.0" encoding="UTF-8" ?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<author>Todd Vierling</author>
<description>HTML selector that returns a flat, escaped string rather than a node tree. Suitable for use with Pipes and other applications wishing to embed HTML in another XML-like container.</description>
<sampleQuery>select * from {table} where url='http://www.yahoo.com/' and xpath='//a'</sampleQuery>
</meta>
<bindings>
<select itemPath="" produces="XML">
<urls>
@Aymkdn
Aymkdn / jsonpost.xml
Last active Jan 2, 2019
Post JSON using YQL Open Table
View jsonpost.xml
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<author>Johannes Charman</author>
<description>JSON pages that need post data (this table is based on htmlpost by Christian Heilmann)</description>
<sampleQuery>select * from {table} where url='http://search.twitter.com/search.json' and postdata="q=test"</sampleQuery>
<documentationURL></documentationURL>
</meta>
<bindings>
<select itemPath="" produces="XML">
@Aymkdn
Aymkdn / CompareLibrairies.js
Created May 18, 2017
Use node to compare two Sharepoint librairies and copy the source to the destination. It will create the folders and files, but it will also update the Modified date and Modifier author in the destination to match the source
View CompareLibrairies.js
// Command: node index.js "http://my.site.com/my_root/my_source_libary/" "http://my.othersite.com/my_root/my_destination_libary/"
if (process.argv.length !== 4) throw "ERROR: please provide the source and the destination on the command line";
const colors = require('colors');
// load credentials
const credentials = require('../credentials');
const $SP = require('sharepointplus');
const sp = $SP().auth(credentials);
var requestdigest = '';
// contains the references to the items to update in the dest lib
@Aymkdn
Aymkdn / Date.parseFrom.js
Created Jan 30, 2017
Date.parseFrom() permits to parse a string to a JavaScript Date
View Date.parseFrom.js
/**
* Parse a string to a Date
* @param {String} strDate
* @param {String} format Supported format including YYYY, YY, MM, M, DD, D, with - and / separators
* @return {Date|Throw} the JS Date object, or throw Error("Invalid Date") if strDate is invalid
* @compatibility IE9+
* @example
* Date.parseFrom("1/10/2017", "MM/DD/YYYY"); // -> new Date(2017,0,10)
*/
Date.parseFrom=function(strDate, format) {
@Aymkdn
Aymkdn / loadExt.js
Last active Nov 24, 2017
To load JS and CSS files with vanilla JavaScript
View loadExt.js
// long version
function loadExt(files, after) {
var _this=this;
_this.files = files;
_this.js = [];
_this.head = document.getElementsByTagName("head")[0];
_this.after = after || function(){};
_this.loadStyle = function(file) {
var link = document.createElement("link");
link.rel = "stylesheet";
@Aymkdn
Aymkdn / method1a.js
Last active Oct 27, 2016
Examples to retrieve a manager in Sharepoint 2013
View method1a.js
// Retrieve Manager for a username
// using REST API
var siteUrl = _spPageContextInfo.siteAbsoluteUrl;
var accountName = 'domain\\login';
// I suppose you use jQuery
$.ajax({
url: siteUrl + "/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='" + encodeURIComponent(accountName) + "'",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
@Aymkdn
Aymkdn / multiple_approve.js
Created Sep 15, 2016
Multiple Approve/Reject in Sharepoint 2010 (jQuery + approval.js)
View multiple_approve.js
/*! jQuery v3.1.0 | (c) jQuery Foundation | jquery.org/license */
!function(a,b){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){"use strict";var c=[],d=a.document,e=Object.getPrototypeOf,f=c.slice,g=c.concat,h=c.push,i=c.indexOf,j={},k=j.toString,l=j.hasOwnProperty,m=l.toString,n=m.call(Object),o={};function p(a,b){b=b||d;var c=b.createElement("script");c.text=a,b.head.appendChild(c).parentNode.removeChild(c)}var q="3.1.0",r=function(a,b){return new r.fn.init(a,b)},s=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,t=/^-ms-/,u=/-([a-z])/g,v=function(a,b){return b.toUpperCase()};r.fn=r.prototype={jquery:q,constructor:r,length:0,toArray:function(){return f.call(this)},get:function(a){return null!=a?a<0?this[a+this.length]:this[a]:f.call(this)},pushStack:function(a){var b=r.merge(this.constructor(),a);return b.p
You can’t perform that action at this time.