Skip to content

Instantly share code, notes, and snippets.

View AmarPrabhu's full-sized avatar
🎯
Focusing

Amar Prabhu AmarPrabhu

🎯
Focusing
View GitHub Profile
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@AmarPrabhu
AmarPrabhu / ghost.conf
Created February 12, 2016 12:32
ghost upstart service
#/etc/init/ghost.conf
description "Ghost Blog"
author "Your Name"
# Start the service after everything loaded
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
# Automatically restart service
respawn
respawn limit 99 5
script
@AmarPrabhu
AmarPrabhu / Cue-splitter.sh
Created July 29, 2015 09:25
Split files according to .cue file
#taken from:
#http://danilodellaquila.com/blog/how-to-split-an-audio-.flac-file-using-ubuntu-linux
#install the essential packages
sudo apt-get install cuetools shntool flac
#shnsplit is the program used to split tracks,
#while cuebreakpoints it reads the break-points from file.cue and pipe them to shnsplit.
cuebreakpoints file.cue | shnsplit -o flac file.flac
module.exports.bootstrap = function (cb) {
// Ensure we have 2dsphere index on Property so GeoSpatial queries can work!
sails.models.YOURMODEL.native(function (err, collection) {
collection.ensureIndex({ coordinates: '2dsphere' }, function () {
// It's very important to trigger this callack method when you are finished
// with the bootstrap! (otherwise your server will never lift, since it's waiting on the bootstrap)
cb();
module.exports = {
/**
*
* Using raw socket.io functionality from a Sails.js controller
*
*/
index: function (req,res) {
function interval(duration, fn){
this.baseline = undefined
this.run = function(){
if(this.baseline === undefined){
this.baseline = new Date().getTime()
}
fn()
var end = new Date().getTime()
this.baseline += duration
@AmarPrabhu
AmarPrabhu / fonts.sh
Created May 26, 2014 06:49
Install ttf fonts like fontawesome for Ubuntu
sudo mkdir fonts
sudo cp /usr/local/share/fonts/truetype/ fonts
cd /usr/local/share/fonts/truetype/
sudo chown root fonts/
fc-cache
@AmarPrabhu
AmarPrabhu / brightness.sh
Created May 10, 2014 07:04
Fix for brightness adjustment in Intel chipset based laptops - Xubuntu 14.04
sudo vim /etc/default/grub
# add the below line
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_backlight=vendor"
sudo halt
@AmarPrabhu
AmarPrabhu / gitcache.sh
Created May 5, 2014 07:45
Git credential cache - remember password
git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=36000'
#here it caches the password for 10Hrs (time in secs)
#!/usr/bin/python
def poorMansConvert(di, inPath, outType, outPath):
from apiclient.http import MediaFileUpload
valid_output = [
'text/html','text/plain','application/rtf','application/vnd.oasis.opendocument.text',\
'application/pdf','application/vnd.openxmlformats-officedocument.wordprocessingml.document',\
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet','application/x-vnd.oasis.opendocument.spreadsheet',\
'image/jpeg','image/png','image/svg+xml','application/vnd.openxmlformats-officedocument.presentationml.presentation'