Skip to content

Instantly share code, notes, and snippets.

@shreyansb
shreyansb / gist:11275498
Created April 25, 2014 01:52
delete "/tmp/tmp.*" files older than 7 days
find /tmp -name "tmp.*" -mtime +7 -delete
*~
*.pyc
.vagrant
venv
@shreyansb
shreyansb / gist:6224466
Created August 13, 2013 18:58
create a self signed ssl cert
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048
openssl rsa -passin pass:x -in server.pass.key -out server.key
rm server.pass.key
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
@shreyansb
shreyansb / es.sh
Last active December 20, 2015 01:39
cd ~
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install openjdk-7-jre-headless -y
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.2.deb
sudo dpkg -i elasticsearch-0.90.2.deb
sudo service elasticsearch start
# Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
@shreyansb
shreyansb / gist:4989834
Created February 19, 2013 20:57
trouble dirtying a hasMany associated field with pushObject
App.Video = DS.Model.extends({
responses: DS.hasMany('App.Video')
});
// in a controller
save: function() {
var v = this.get('model');
var r = App.Video.find(this.get('responseId'));
v.get('responses').pushObject(r);
console.log(v.get('isDirty')); // false
@shreyansb
shreyansb / golang_errors.py
Created January 13, 2013 21:38
#golang style errors in python. like it so far.
@app.route("/<user_id>/facebook_id", methods=["PUT"])
def put_facebook_id(user_id):
fb_d, err = get_facebook_data_from_cookie(request)
if err:
return json_error(err)
else:
# save and return success
pass
def get_facebook_data_from_cookie(request):
@shreyansb
shreyansb / daily_startup_tip.js
Created October 8, 2012 20:03
a google script to send everyone who filled out a google form an email every day with a startup tip
function email_one_tip_a_day() {
// pick a tip
var data_sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('tips');
var num_rows = 90;
var row_num = Math.floor((Math.random()*num_rows)+1);;
var dataRange = data_sheet.getRange(row_num, 1, 1, 1);
var tip = dataRange.getValues();
// email it to some people
var todays_date = Utilities.formatDate(new Date(), "EST", "d MMMM");
@shreyansb
shreyansb / fullscreen.html
Created September 12, 2012 01:39
is the viewing browser in fullscreen mode?
<html>
<head>
<script>
function isFullscreen() {
if ((window.screen.height === window.innerHeight) &&
(window.screen.width === window.innerWidth)) {
return true;
} else {
return false;
}
@shreyansb
shreyansb / cpublock.go
Created September 7, 2012 14:05
this will block the cpu entirely
package main
import (
"fmt"
"runtime"
"time"
)
func main() {
// THIS is totally required; without it, you're blocking the CPU regardless
@shreyansb
shreyansb / gist:2968207
Created June 21, 2012 20:03
decimals in python 2.6 - very odd.
[[email protected] ~ ]$ python2.7
Python 2.7.1 (r271:86832, Aug 5 2011, 03:30:24)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from decimal import Decimal
>>> Decimal('500') < 5597.22
True
>>> quit()
[[email protected] ~ ]$ python2.6