Skip to content

Instantly share code, notes, and snippets.

@Aymkdn
Aymkdn / LICENSE.txt
Created July 29, 2011 17:29 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@Aymkdn
Aymkdn / spservices-startworkflow.js
Created October 11, 2012 15:22
Start a workflow with Sharepoint (JavaScript)
/**
* Start a workflow
*
* @param {Object} params
* @param {String} params.listName The name of the list
* @param {Number} params.itemID The item ID
* @param {String} params.workflowName The name of the workflow
* @param {Array|Object} [params.parameters] An array of object with {Name:"Name of the parameter", Value:"Value of the parameter"}
* @param {Function} [params.after] Callback after the request is done
*/
@Aymkdn
Aymkdn / bookmarklet
Created October 24, 2012 14:22
Bookmarklet to show all the JS scripts into a page
javascript:(function(){function ajax(b){if(typeof XMLHttpRequest==="undefined"){XMLHttpRequest=function(){try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(c){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(c){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(c){}throw new Error("This browser does not support XMLHttpRequest.")}}var a=new XMLHttpRequest();if(!b.url){throw new Error("You must define 'url'")}a.open("GET",b.url);a.onreadystatechange=function(){if(a.readyState===4){if(a.status===200){var c=(a.responseXML?a.responseXML:a.responseText);if(typeof b.success==="function"){b.success(c,b)}}if(typeof b.after==="function"){b.after()}}};a.send()}var s=document.getElementsByTagName("SCRIPT"),tx="",sr=[],i,t;for(i=0;i<s.length;i++){with(s.item(i)){t=text;if(t){tx+=t}else{sr.push(src)}}}var __loadedScript=sr.length;with(window.open()){document.write('<textarea id="t">'+tx+"</textarea>");for(var i=0;i<sr.length;i++){ajax({url:sr[i],success:function(a,b){document.getElementById("t").value+="
@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:

/**
* 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"]
* optimizedFor({
* nbIterations: array.length,
* each:function( index ) {
* doSomethingUsefulWith( array[ index ] );
* },
@Aymkdn
Aymkdn / getid.js
Created October 21, 2015 06:42
Find the User ID from the User Information List in Sharepoint
// http://aymkdn.github.io/SharepointPlus/symbols/%24SP%28%29.html#.getUserInfo
$SP().getUserInfo("domain\\john_doe", function(info) {
if (typeof info === "string") {
console.log("Error:"+info); // there was a problem so we show it
} else
console.log("User ID = "+info.ID)
});
// query the User Information List
$SP().list("User Information List", "http://site.collection/root/dir").get({
@Aymkdn
Aymkdn / popup_draggable.html
Last active April 27, 2019 04:45
Draggable DIV cross-browser (from IE8) with pure JavaScript
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="popup" style="background-color:green;position:absolute;top:0px;left:0px;width:250px;height:250px;z-index:9999;box-shadow: 6px 6px 5px #888888;border-radius:6px;border:1px solid #4f4f4f;">
<div id="popup_bar" style="width:100%;background-color:#aaff66;position:relative;top:0;border-radius:6px 6px 0 0; text-align:center;height:24px;cursor:move">Title</div>
<p>Content of the popup</p>
</div>
</body>
@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.
@Aymkdn
Aymkdn / tiny_http.js
Created July 12, 2016 06:55
Tiny HTTP Get/Post
/*
m: method ("get", "post")
u: url
c: callback (with 'xhr' as a parameter)
a: async (true / default) or sync (false)
d: post_data (the data to post)
*/
function tiny_http(m,u,c,a,d){var _xhr=new(this.XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP");with(_xhr)onreadystatechange=function(){4^readyState||c(_xhr)},open(m,u,a),"post"===m.toLowerCase()?setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"):"",send(d)}
@Aymkdn
Aymkdn / multiple_approve.js
Created September 15, 2016 08:26
Multiple Approve/Reject in Sharepoint 2010 (jQuery + approval.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