Skip to content

Instantly share code, notes, and snippets.

View AbhiPrasad's full-sized avatar

Abhijeet Prasad AbhiPrasad

View GitHub Profile
@AbhiPrasad
AbhiPrasad / reverse-string.js
Created January 20, 2017 21:04
Reverse a string in javascript
function reverseString(str) {
var ogstr = "";
var strLength = str.length;
for (var i = strLength; i >= 0; i--) {
ogstr += str.charAt(i);
}
return ogstr;
}
//from https://developer.mozilla.org/en/docs/Web/API/Battery_Status_API
navigator.getBattery().then(function(battery) {
function updateAllBatteryInfo(){
updateChargeInfo();
updateLevelInfo();
updateChargingInfo();
updateDischargingInfo();
}
updateAllBatteryInfo();
String.prototype.replaceAt = function(index, character) {
return this.substr(0, index) + character + this.substr(index + character.length);
}
@AbhiPrasad
AbhiPrasad / genrandomnum.js
Created January 24, 2017 17:00
Generate a random number in javascript (between a min and max)
Math.floor(Math.random() * (max - min + 1)) + min
rm(list=ls())
//from https://developer.chrome.com/extensions/manifest
{
// Required
"manifest_version": 2,
"name": "My Extension",
"version": "versionString",
// Recommended
"default_locale": "en",
@AbhiPrasad
AbhiPrasad / debug_to_console.php
Created February 23, 2017 17:01
This outputs a php variable to the console (useful for debugging)
<?php
function debug_to_console( $data ) {
if ( is_array( $data ) )
$output = "<script>console.log( 'Debug Objects: " . implode( ',', $data) . "' );</script>";
else
$output = "<script>console.log( 'Debug Objects: " . $data . "' );</script>";
echo $output;
@AbhiPrasad
AbhiPrasad / git_revert.git
Created March 3, 2017 15:05
Revert git commits
git revert --no-commit 0766c053..HEAD
git commit
@AbhiPrasad
AbhiPrasad / backbone-boilerplate.js
Created March 22, 2017 17:52
A simple boilerplate to test backbone stuff
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://underscorejs.org/underscore-min.js"></script>

Keybase proof

I hereby claim:

  • I am abhiprasad on github.
  • I am abhijeetprasad (https://keybase.io/abhijeetprasad) on keybase.
  • I have a public key whose fingerprint is 8932 7218 5B12 A5BA A6F1 DF6A 8A1B BA05 1A5D BDC8

To claim this, I am signing this object: