Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Amar Prabhu AmarPrabhu

🎯
Focusing
View GitHub Profile
View exportjson.js
// 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 Feb 12, 2016
ghost upstart service
View ghost.conf
#/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 Jul 29, 2015
Split files according to .cue file
View Cue-splitter.sh
#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
View bootstrap.js
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();
View using-raw-socket-io-in-sails.js
module.exports = {
/**
*
* Using raw socket.io functionality from a Sails.js controller
*
*/
index: function (req,res) {
View interval.js
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
Install ttf fonts like fontawesome for Ubuntu
View fonts.sh
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
Fix for brightness adjustment in Intel chipset based laptops - Xubuntu 14.04
View brightness.sh
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
Git credential cache - remember password
View gitcache.sh
git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=36000'
#here it caches the password for 10Hrs (time in secs)
View poorMansConvert.py
#!/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'
You can’t perform that action at this time.