Skip to content

Instantly share code, notes, and snippets.

View joshisa's full-sized avatar
🎯
Focusing

Sanjay Joshi joshisa

🎯
Focusing
View GitHub Profile
@joshisa
joshisa / GenerateCloudantAPIKey
Last active August 29, 2015 14:01
Demonstrates a way to create an API Key User with Cloudant and set permissions on that API Key
// Demonstrates a way to create an API Key User with Cloudant and set permissions
var dbname = 'somedb';
var cloudantCreds = {
username: 'cloudantusername',
password: 'cloudantpassword'
};
var auth = 'Basic ' + new Buffer( cloudantCreds.username + ':' + cloudantCreds.password).toString('base64');
var options = {
var cloudantCreds = {
username: 'cloudantusername',
password: 'cloudantpassword'
};
var dbname = 'cloudantdbname';
var auth = 'Basic ' + new Buffer( cloudantCreds.username + ':' + cloudantCreds.password).toString('base64');
var options = {
@joshisa
joshisa / gist:7a261ccf4b230df64be8
Created June 18, 2015 19:22
Python Response Codes within Requests Module
_codes = {
# Informational.
100: ('continue',),
101: ('switching_protocols',),
102: ('processing',),
103: ('checkpoint',),
122: ('uri_too_long', 'request_uri_too_long'),
200: ('ok', 'okay', 'all_ok', 'all_okay', 'all_good', '\\o/', '✓'),
201: ('created',),
#!/bin/sh
echo "What should the Application be called (no spaces allowed e.g. GCal)?"
read inputline
name=$inputline
echo "What is the url (e.g. https://www.google.com/calendar/render)?"
read inputline
url=$inputline
@joshisa
joshisa / posts.js
Last active September 24, 2016 10:48 — forked from glennblock/posts.js
Embedded gist syntax for Ghost. Place in ./core/server/api/posts.js.
//the code below will embed replace [gist id=x] tags with an embedded gist similar to the way the Wordpress Gist
//plugin works. I wrote this in order to import posts from Wordpress. See //GB: for the changes.
//SPJ: Updated for compatibility with Ghost 0.6.4
/**
* ### Read
* Find a post, by ID, UUID, or Slug
*
* @public
* @param {{id_or_slug (required), context, status, include, ...}} options
@joshisa
joshisa / useful_pandas_snippets.py
Last active August 31, 2015 20:44 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
#List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
#Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
#Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(value_list)]
@joshisa
joshisa / useful_git_commands
Last active October 8, 2015 05:45
Useful Git Commands
Source: http://orga.cat/posts/most-useful-git-commands
Not all commands written here are git commands, but all of them are related to git. Please refer to the documentation for more details.
Set your details
git config --global user.name "John Doe"
git config --global user.email "john@example.com"
Use --global to set the configuration for all projects. If git config is used without --global and run inside a project directory, the settings are set for the specific project.
Make git ignore file modes
Verifying that +boilerupnc is my blockchain ID. https://onename.com/boilerupnc
# Installing the very useful iPython extension autotime (src: https://github.com/cpcloud/ipython-autotime)
%install_ext https://raw.github.com/cpcloud/ipython-autotime/master/autotime.py
%load_ext autotime
def get_file_content(credentials):
'''For given credentials, this functions returns a StringIO object containg the file content.'''
url1 = ''.join([credentials['auth_url'], '/v3/auth/tokens'])
data = {'auth': {'identity': {'methods': ['password'],
'password': {'user': {'name': credentials['username'],'domain': {'id': credentials['domainId']},

Keybase proof

I hereby claim:

  • I am joshisa on github.
  • I am boilerupnc (https://keybase.io/boilerupnc) on keybase.
  • I have a public key ASDafqvWKxiRU-OJ7L6B116RAs-bi_xZtS1Ce9MbConUnQo

To claim this, I am signing this object: