Skip to content

Instantly share code, notes, and snippets.

@avishaan
avishaan / .bash_profile
Created September 11, 2014 20:42
Change iTerm color from command line
# a couple alias to switch iterm window from dark to light
alias itermlight='echo -e "\033]50;SetProfile=light\a"'
alias itermdark='echo -e "\033]50;SetProfile=dark\a"'
@avishaan
avishaan / jasmineMultiTestOneSpec.js
Created October 30, 2014 05:42
Jasmine test multi values with same 'it' spec
describe("A calculator", function() {
it("should square correctly", function() {
[
{ number: 2, answer: 4},
{ number: 3, answer: 9},
{ number: 4, answer: 16}
].forEach(function(problem, index, array){
// we will pretend to calculate with our fnc here
var calcAnswer = problem.number*problem.number;
expect(calcAnswer).toEqual(problem.answer);
@avishaan
avishaan / jasmineMultiTestOneSpecAsync.js
Created October 30, 2014 05:47
Jasmine test multiple values with one spec asyncly
describe("A calculator", function() {
it("should square correctly", function(done) {
[
{ number: 2, answer: 4},
{ number: 3, answer: 9},
{ number: 4, answer: 16}
].forEach(function(problem, index, array){
// we will pretend to calculate with our fnc here
setTimeout(function(){
var calcAnswer = problem.number*problem.number;
@avishaan
avishaan / .tern-project
Created August 12, 2015 21:43
TernJS MeteorJS general config file
{
"libs": [
"browser",
"jquery",
"underscore"
],
"loadEagerly": [
"*.js", "*/*.js", "*/*/*.js", "*/*/*/*.js"
],
"dontLoad": [
@avishaan
avishaan / dataFormatExamples.js
Last active July 11, 2016 01:43
Dashboard MongoDB object format
// basic json document template
var graphBaseTemplate = {
'_id': '0012938801abfe', //auto assigned by database
'kHospitalName': 'kKaiser',
'kHospitalId': '0012938801abf1',
'kGraphName': 'kCostSavings',
'kGraphId': '0012938801abf2',
'kDepartmentName': 'kHospitalWide',
'kDepartmentId': '0012938801abf3',
'datasets': datasets
@avishaan
avishaan / .vimrc
Last active July 21, 2016 12:50
My .vimrc that everyone has been asking for
" https://github.com/Valloric/YouCompleteMe/issues/611
"let $PATH = '/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib -DPYTHON_INCLUDE_DIR=/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7'.$PATH
let $PATH = '/usr/local/bin:'.$PATH
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
@avishaan
avishaan / jsdoc.js
Created October 13, 2016 04:32
"complex" jsdoc example
/**
* sort data
*
* @param {String[]} data - data points
* @param {String[]} labels - labels in same order as data points
* @param {Object} options - labels in same order as data points
* @param {Number} sort - direction to short (ascending, descending)
* @return {Object} sorted - sortedData object
* @return {Number[]} sorted.data - data sorted in order
* @return {String[]} sorted.labels - labels for data returned in matching order
@avishaan
avishaan / swapfile.h
Last active January 6, 2017 06:55
Create swapfile on
#!/bin/bash
#https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-16-04
sudo fallocate -l 2G /swapfile
ls -lh /swapfile
chmod 0600 /swapfile
sudo mkswap /swapfile
@avishaan
avishaan / image-resize.js
Created December 31, 2016 03:25
adjust image size
// Call this function *after* the page is completely loaded!
function resize_images(maxht, maxwt, minht, minwt) {
var imgs = document.getElementsByTagName('img');
var resize_image = function(img, newht, newwt) {
img.height = newht;
img.width = newwt;
};
for (var i = 0; i < imgs.length; i++) {
@avishaan
avishaan / add-reading-list-from-chrome.scpt
Created July 30, 2017 01:15
Love using Chrome but miss being able to add the current page to your 'reading list' in Safari, run this script
-- Script will open Chrome, put url of active view onto clipboard, open Safari, add to reading list, wait for abit while added to reading list
tell application "Google Chrome"
activate
set the clipboard to (URL of active tab of first window as text)
end tell
tell application "Safari"
activate
add reading list item (get the clipboard)