Skip to content

Instantly share code, notes, and snippets.

View AmarPrabhu's full-sized avatar
🎯
Focusing

Amar Prabhu AmarPrabhu

🎯
Focusing
View GitHub Profile
@AmarPrabhu
AmarPrabhu / Guayadeque.sh
Last active August 29, 2015 14:00
Shell commands to control Guayadeque Player
dbus-send --print-reply --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Stop
#XF86AudioStop
dbus-send --print-reply --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Play
dbus-send --print-reply --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Pause
#XF86AudioPlay
dbus-send --print-reply --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Next
#XF86AudioNext
cat /etc/apt/sources.list | perl -ne '$H{$_}++ or print' > /tmp/sources.list && sudo mv /tmp/sources.list /etc/apt/sources.list
@AmarPrabhu
AmarPrabhu / Chrome-Driver.sh
Last active August 29, 2015 13:57
Installs Chrome Driver latest version and configures path, permissions
wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/2.9/chromedriver_linux64.zip && sudo unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/;
#set permissions
sudo chmod -R a+rwx /usr/local/bin/chromedriver
@AmarPrabhu
AmarPrabhu / formidable.js
Created January 11, 2014 09:42
Form upload using Node Formidable
exports.fileUpload = function(req, res) {
var form = new formidable.IncomingForm(),
files = [],
uploadedFilePath,
fields = [];
form.uploadDir = '/your_path/files';
form.keepExtensions = true;
form.on('field', function(field, value) {
fields.push([field, value]);
})
@AmarPrabhu
AmarPrabhu / frisbee.js
Created January 3, 2014 10:20
Frisbee Modelling in Javascript
function frisbee ()
{
//everything in SI units
var g = -9.81, //deceleration due to gravity
m = 0.175, //mass - change as needed
RHO = 1.23, //density of air
AREA = 0.0568, //area for the frisbee - change as needed
CL0 = 0.1, //lift coefficient parameters
CLA = 1.4,
CD0 = 0.08, //drag coefficient parameters
@AmarPrabhu
AmarPrabhu / Node Async foreachlimit
Created August 26, 2013 09:59
iterate over a collection, perform an asynchronous task for each item, but only let x tasks run at the same time, and when they're all done do something else. From: http://www.sebastianseilund.com/nodejs-async-in-practice
app.delete('/messages/:messageIds', function(req, res, next) {
var messageIds = req.params.messageIds.split(',');
async.forEachLimit(messageIds, 5, function(messageId, callback) {
db.delete('messages', messageId, callback);
}, function(err) {
if (err) return next(err);
res.json({
success: true,
message: messageIds.length+' message(s) was deleted.'
});
@AmarPrabhu
AmarPrabhu / AWS Bucket Transfer
Created August 26, 2013 09:55
AWS Bucket Object transfer between source bucket and destination bucket From: http://www.sebastianseilund.com/nodejs-async-in-practice
//Prepare S3 access and bucket names
var awssum = require('awssum');
var s3 = new awssum.load('amazon/s3').S3({
accessKeyId: '...',
secretAccessKey: '..',
});
var sourceBucket = 'old-bucket';
var destinationBucket = 'new-bucket';
var listObjectsDone = false;
@AmarPrabhu
AmarPrabhu / Q Index Quora
Created August 25, 2013 12:32
Scroll long pages on quora.com automatically and calculate Q Index of a user.
function pageScroll()
{
window.scrollBy(0,100);//based on bandwidth, decrease for slower speeds
if(($(window).scrollTop() >= $(document).height() - $(window).height() - 200) )
{
if(($(window).scrollTop() >= $(document).height() - $(window).height()))
{
counter++;
if(counter >200)//increase if no of answers is huge
{
{
"Version": "2008-10-17",
"Id": "0c762de8-f56b-488d-a4a4-20d1cb31df2f",
"Statement": [
{
"Sid": "Allow in my domains",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
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