Skip to content

Instantly share code, notes, and snippets.

@sp2hari
sp2hari / run1.cc
Created May 8, 2012 05:16
Code snippets for Interviewstreet Sample Test
/* This is the correct working solution */
#include <iostream>
using namespace std;
int main() {
int n, sum = 0;
cin >> n;
for (int i=0; i<=n; i++) {
sum += i;
}
cout << sum << endl;
@sp2hari
sp2hari / errorception.js
Created September 20, 2014 12:04
Close all errors from errorception project
setInterval (function() {
document.getElementById("selectAll").click(); document.getElementById("statusClose").click(); }
, 5000);
@sp2hari
sp2hari / app.js
Last active August 29, 2015 14:12
Nodejs custom log
app.use(express.logger(function(tokens, req, res) {
return '{"request_method" : "'+req.method+'", "url" : "'+req.url+'", "user_agent" : "'+req.headers['user-agent']+'", "duration" : "'+String((Date.now() - req._startTime)/1000)+'", "namespace" : "autocomplete", "response_status" : "'+(res.headerSent ? res.statusCode : null)+'", "timestamp": "'+new Date().toUTCString()+'", "remote_ip": "'+req.ip+'", "request_uid" : "'+req.headers["X-Request-Unique-Id"]+'", "start_time" : "'+req._startTime+'", "end_time" : "'+new Date().toUTCString()+'" }'
}));
@sp2hari
sp2hari / install_all_firefox.sh
Created August 14, 2015 04:48
Script to download/install all firefox versions
#!/bin/bash
default_versions_future="beta aurora nightly ux"
default_versions_current="39"
default_versions_past="2 3 3.5 3.6 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38"
versions_usage_point_one="3.6 12 16 17 22 23 25"
versions_usage_point_two="21 24 26"
versions_usage_point_three=""
versions_usage_point_four_up="27 28 29"
@sp2hari
sp2hari / script.js
Last active May 8, 2020 13:35
Mail Merge to PDF Files
/*
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
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.
@sp2hari
sp2hari / Code.gs
Created June 13, 2020 20:05
Mail Merge to PDF Files - v2
/*
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
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.
@sp2hari
sp2hari / unPause.gs
Created July 3, 2020 20:51
Google Script for Inbox Pause
function unPause() {
var pausedLabel = GmailApp.getUserLabelByName("Inbox-Paused");
if (pausedLabel) {
var threads = pausedLabel.getThreads();
for (var i = 0; i < threads.length; i++) {
threads[i].moveToInbox();
pausedLabel.removeFromThread(threads[i]);
}
}
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
jQuery(document).ready(function(){
jQuery(".book-wrap").mouseenter(function(){
jQuery(this).addClass("rotate");
});
jQuery(".book-wrap").mouseleave(function(){
jQuery(this).removeClass("rotate");
});
<!doctype html>
<html>
<head>
<style class="cp-pen-styles">#featureAnimation,#featureBox{background-color:#fff;overflow:hidden;line-height:normal;font-size:80%;z-index:1000;}#featureAnimation{position:fixed;visibility:hidden;}#featureBox{position:absolute;}.star{position:absolute;background-color:#161616;display:none;z-index:1001;}.dot{position:absolute;background-color:#91e600;}.page-box{opacity:0;}</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/gsap/1.11.2/TweenMax.min.js'></script></head>
<body id="home" class="fixed-header">
<div id="featureBox"></div><div class="feature" id="featureAnimation"><div id="featureBackground" style="pointer-events:none;"></div></div>
<script type="text/javascript">
/* verge 1.9.1+201402130803 | https://github.com/ryanve/verge | * MIT License 2013 Ryan Van Etten | Script to fetch viewport dimensions */
@sp2hari
sp2hari / domaintracker.js
Created December 3, 2022 06:14
Domain Tracker in Google Sheets
const DEBUG_MODE = true;
const MAX_ROWS = 30;
function onOpen() {
SpreadsheetApp
.getUi()
.createMenu('Tracker')
.addItem('Update Domain Data', 'updateAllDomainData')
.addToUi()
}