Skip to content

Instantly share code, notes, and snippets.

View IAMIronmanSam's full-sized avatar
🎯
Focusing

Tony Stark IAMIronmanSam

🎯
Focusing
View GitHub Profile
@IAMIronmanSam
IAMIronmanSam / CSOM.js
Last active June 20, 2023 14:30
CSOM to update and create & update list item
function CSOMOperations(columnData,listName,action,itemID){
var context = SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists();
var targetList = list.getByTitle(listName);
var item;
switch(action){
case 'create':
var listItemCreation = new SP.ListItemCreationInformation();
item = targetList.addItem(listItemCreation);
@IAMIronmanSam
IAMIronmanSam / bootstrap-custom.css
Created March 5, 2015 03:56
Custom bootstrap for sharepoint specific
/*bootstrap 3 resets for SharePoint*/
/*border-box causes many issues with SP*/
*, *:before, *:after {
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
}
/*reset elements that B3 is expecting to be border-box*/
* [class^="col-"], * [class^="col-"]:before, * [class^="col-"]:after,
.container, .container:before, .container:after,
@IAMIronmanSam
IAMIronmanSam / pem2cer.sh
Created September 9, 2016 23:31
.PEM to .CER using openssl
openssl x509 -inform PEM -in cacert.pem -outform DER -out certificate.cer
@IAMIronmanSam
IAMIronmanSam / toSum.js
Created May 3, 2019 04:19
Find possible sum pairs in array
function toSum(numArray,sum){
let pairs = [];
let hash = [];
for(let i = 0;i < numArray.length; i++){
let counterPart = sum - numArray[i];
if(hash.indexOf(counterPart) != -1){
pairs.push([numArray[i],counterPart]);
}
hash.push(numArray[i]);
}
function countUniqueString(arr){
const lookup = {};
for (let letter of arr) {
// if letter exists, increment, otherwise set to 1
lookup[letter] ? lookup[letter] += 1 : lookup[letter] = 1;
}
return Object.keys(lookup);
}
countUniqueString('aabbbbbcccdefffff')
function search(array, val) {
let min = 0;
let max = array.length - 1;
while (min <= max) {
let middle = Math.floor((min + max) / 2);
let currentElement = array[middle];
if (array[middle] < val) {
function countUniqueValues(arr){
if(arr.length === 0) return 0;
var i = 0;
for(var j = 1; j < arr.length; j++){
if(arr[i] !== arr[j]){
i++;
arr[i] = arr[j]
}
}
return i + 1;
function maxSubarraySum(arr, num){
let maxSum = 0;
let tempSum = 0;
if (arr.length < num) return null;
for (let i = 0; i < num; i++) {
maxSum += arr[i];
}
tempSum = maxSum;
for (let i = num; i < arr.length; i++) {
tempSum = tempSum - arr[i - num] + arr[i];
function sumZero(arr){
let left = 0;
let right = arr.length - 1;
//Moving from left and right to middle
while(left < right){
//First element + Last element
let sum = arr[left] + arr [right];
if(sum === 0){
//Found a first matching pair
return [arr[left], arr[right]];
@IAMIronmanSam
IAMIronmanSam / Anagram.js
Last active March 27, 2019 06:38
Check given word is Anagram or not
function validAnagram(first, second) {
if (first.length !== second.length) {
return false;
}
const lookup = {};
for (let letter of first) {
// if letter exists, increment, otherwise set to 1
lookup[letter] ? lookup[letter] += 1 : lookup[letter] = 1;