Skip to content

Instantly share code, notes, and snippets.

@swapnilshrikhande
swapnilshrikhande / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@swapnilshrikhande
swapnilshrikhande / bubblesort.js
Last active August 29, 2015 14:10 — forked from bencevans/gist:4117847
bubblesort.js
function bubbleSort (sortingArray) {
var goto = sortingArray.length - 1;
for(var key in sortingArray) {
for(var i = 0; i <= goto - 1; i++) {
if(sortingArray[i] > sortingArray[i + 1]) {
// Swap
var temp = sortingArray[i];
sortingArray[i] = sortingArray[i +1];
sortingArray[i + 1] = temp;
}
/*
This game is for Unix only.
It is a simple yet easily navigable Tic-Tac-Toe game for the Unix terminal. To run this file, go
to your awesome Unix terminal and (after you have downloaded this text file, of course) and
navigate to this file. Then, compile and link the program with your handy compiler which will
almost definitely be installed unless you have removed it using the command 'gcc TicTacToe.c'.
This creates an executeable. To run it, you can simply type './a.out'. If you want to have a more
memorable file and/or prevent conflicts, simply change the name with the 'mv' tool
('mv a.out TicTacToe') or use the '-o' ("output file") when compiling
/**
* Luhn algorithm in JavaScript: validate credit card number supplied as string of numbers
* @author ShirtlessKirk. Copyright (c) 2012.
* @license WTFPL (http://www.wtfpl.net/txt/copying)
*/
var luhnChk = (function (arr) {
return function (ccNum) {
var
len = ccNum.length,
bit = 1,
@swapnilshrikhande
swapnilshrikhande / tableSorter.js
Last active August 2, 2016 13:44 — forked from mangeshpawar/tableSorter.js
Table Sorting Utility Supporting Standard Salesforce Form Elements
var ts = ts || {};
var sortStatus = {};
ts.getValue = function(tdElem){
var inputElemLst = $(tdElem).find("input:not([type='hidden']):first");
return inputElemLst.length ? inputElemLst.val() : $(tdElem).text();
};
ts.handleSortClick = function(event){
@swapnilshrikhande
swapnilshrikhande / function.php
Created April 26, 2016 10:08 — forked from YugalXD/function.php
Send mail with mailgun api by PHP CURL.
<?php
define('MAILGUN_URL', 'https://api.mailgun.net/v3/DOMAIN_NAME');
define('MAILGUN_KEY', 'KEY');
function sendmailbymailgun($to,$toname,$mailfromnane,$mailfrom,$subject,$html,$text,$tag,$replyto){
$array_data = array(
'from'=> $mailfromname .'<'.$mailfrom.'>',
'to'=>$toname.'<'.$to.'>',
'subject'=>$subject,
'html'=>$html,
@swapnilshrikhande
swapnilshrikhande / Pdf_of_Attachment
Created December 2, 2016 09:00 — forked from SeemaKurawale111/Pdf_of_Attachment
Generate PDF attachment of opprtunity details
<apex:page standardController="Opportunity" extensions="Pdf_of_Attachment_Extension" renderAs="pdf">
<apex:pageBlock >
<apex:pageBlockSection columns="1" >
<apex:pageBlockSectionItem >Opportunity Name: {!Opportunity.Name} </apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >CloseDate : {!Opportunity.CloseDate} </apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >StageName : {!Opportunity.StageName} </apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >Probability : {!Opportunity.Probability} </apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:repeat var="attachment" value="{!attachments}">
<apex:image url="/servlet/servlet.FileDownload?file={!attachment.Id}"/><br></br>
input[type=checkbox] {
opacity: 1;
float:left;
}
input[type=checkbox] {
margin: 0 0 0 20px;
position: relative;
cursor: pointer;
font-size: 16px;
@swapnilshrikhande
swapnilshrikhande / WebDriverExtensionsGroovyExampleTest.groovy
Created June 27, 2017 09:55 — forked from andidev/WebDriverExtensionsGroovyExampleTest.groovy
Example of a WebDriver Extensions Test written in Groovy
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.WebElement;
import com.github.webdriverextensions.junitrunner.WebDriverRunner;
import com.github.webdriverextensions.junitrunner.annotations.*;
import static com.github.webdriverextensions.Bot.*;
import static java.util.concurrent.TimeUnit.SECONDS;
@swapnilshrikhande
swapnilshrikhande / TriggerEvent.js
Created July 26, 2017 08:43 — forked from anonymous/TriggerEvent.js
Trigger the Change Event using plain js
function triggerChangeEvent(element){
if ("createEvent" in document) {
var evt = document.createEvent("HTMLEvents");
evt.initEvent("change", false, true);
element.dispatchEvent(evt);
}
else
element.fireEvent("onchange");