Skip to content

Instantly share code, notes, and snippets.

function logColor(color, args) {
console.log(`%c ${args.join(' ')}`, `color: ${color}`);
}
const log = {
aliceblue: (...args) => { logColor('aliceblue', args)},
antiquewhite: (...args) => { logColor('antiquewhite', args)},
aqua: (...args) => { logColor('aqua', args)},
aquamarine: (...args) => { logColor('aquamarine', args)},
azure: (...args) => { logColor('azure', args)},
@Aymkdn
Aymkdn / PeopleSearch_parameters.md
Last active June 1, 2020 23:22
Create a Sharepoint 2013 native People Picker in JavaScript (using jQuery, or using SharepointPlus)

Details about some of the options.

SearchPrincipalSource

The principal sources to search.

  • All (15) – Search all principal sources.
  • MembershipProvider (4) – Search the current membership provider.
  • None (0) – Search no principal sources.
  • RoleProvider (8) – Search the current role provider.
  • UserInfoList (1) – Search the user information list.
@jpvincent
jpvincent / optimizedFor.js
Last active November 25, 2021 17:12
never blocking loop mechanism, using setTimeout 0 trick and time control to break the loop and let the browser breath
/**
* NEVER BLOCKING LOOP : implementation of the infamous setTimeout 0 hack, with time checking in order to guarantee fluidity without sacrificing execution speed.
*
* USAGE :
* var array = ["a way too big array that is heavy to process"]
* optimizeFor({
* nbIterations: array.length,
* each:function( index ) {
* doSomethingUsefulWith( array[ index ] );
* },
@zplume
zplume / LS.SP.JSOM.js
Last active June 30, 2023 15:04
SharePoint 2013 REST / JSOM / Utility functions (work in progress)
(function() {
var nsName = "LS"; // root namespace name
var ns = window[nsName]; // root namespace alias
var utils = ns.Utils; // utils alias
ns.SP = ns.SP || {};
ns.SP.JSOM = {
Data: {
Sites: {} // cache for Taxonomy terms JSON
},
@Aymkdn
Aymkdn / Run a web page from a Github project in one click.md
Last active December 10, 2015 18:48
Run a web page from a Github project in one click. See README below.

When you visit a Github project with, for example, a demo.html page you can simply click on the "Run" button and the page will be loaded directly into your browser without the need to download the full git project in the correct directory and play with your browser to find where you downloaded it.

Instructions :

  1. Store the below PHP file to your web server;
  2. Edit the below Greasemonkey file with the URL of your webserver;
  3. Load the Greasemonkey script into your web browser;
  4. Go to any file stored on Github and you'll see a "Run" button just after the "History" button.

Once you did all the steps then you can try it. For example go to https://github.com/prezjordan/dynamo.js/blob/master/test/test.html and you should see the Run button:

@CatTail
CatTail / htmlentity.js
Created November 30, 2012 08:27
Javascript: encode(decode) html text into html entity
// encode(decode) html text into html entity
var decodeHtmlEntity = function(str) {
return str.replace(/&#(\d+);/g, function(match, dec) {
return String.fromCharCode(dec);
});
};
var encodeHtmlEntity = function(str) {
var buf = [];
for (var i=str.length-1;i>=0;i--) {
anonymous
anonymous / countryselect
Created November 22, 2012 18:19
List of country with their local name
^<select name="CountrySelect">
<option selected="selected">Select a country from this menu</option>
<option value="couaf.html">Afghanistan • افغانستان</option>
<option value="coual.html">Albania • Shqipëria</option>
<option value="coudz.html">Algeria • الجزائر</option>
<option value="couad.html">Andorra</option>
<option value="couao.html">Angola</option>
<option value="couag.html">Antigua and Barbuda</option>
<option value="couar.html">Argentina</option>
<option value="couam.html">Armenia • Հայաստան</option>
@media only screen and (min-width: 320px) {
/* Small screen, non-retina */
}
@media
only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 320px),