Skip to content

Instantly share code, notes, and snippets.

import json, re, shlex, urllib.request
watch = []
def getPrice(item):
listings = json.loads(urllib.request.urlopen(makeUrl(item)).read().decode("utf-8"))["listinginfo"]
lowest = None
for id, obj in list(listings.items()):
try:
price = obj["converted_price"]

Fixing npm On Mac OS X for Homebrew Users

If you just want to fix the issue quickly, scroll down to the "solution" section below.

Explanation of the issue

If you're a Homebrew user and you installed node via Homebrew, there is a major philosophical issue with the way Homebrew and NPM work together. If you install node with Homebrew and then try to do npm update npm -g, you may see an error like this:

$ npm update npm -g
var Promise = require('bluebird');
var knex = require('knex')({
client: 'mysql',
connection: {
host: '127.0.0.1',
user: 'root',
password: '',
database: 'steam',
charset: 'utf8'
var Promise = require('bluebird');
var knex = require('knex')({
client: 'mysql',
connection: {
host: '127.0.0.1',
user: 'root',
password: '',
database: 'steam',
charset: 'utf8'
@mikebobadilla
mikebobadilla / pubsub.js
Last active August 29, 2015 14:26 — forked from learncodeacademy/pubsub.js
Basic Javascript PubSub Pattern
//events - a super-basic Javascript (publish subscribe) pattern
var events = {
events: {},
on: function (eventName, fn) {
this.events[eventName] = this.events[eventName] || [];
this.events[eventName].push(fn);
},
off: function(eventName, fn) {
if (this.events[eventName]) {
@mikebobadilla
mikebobadilla / gist:6e8e56a07197acae9be1
Created January 9, 2016 19:18
Format Date Function
function formatDate(date) {
var hours = date.getHours();
var minutes = date.getMinutes();
var ampm = hours >= 12 ? 'pm' : 'am';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
minutes = minutes < 10 ? '0'+minutes : minutes;
var strTime = hours + ':' + minutes + ' ' + ampm;
return date.getMonth()+1 + "/" + date.getDate() + "/" + date.getFullYear() + " " + strTime;
}
@mikebobadilla
mikebobadilla / gist:0af3672e54cbddb1ad5a
Created January 10, 2016 04:29
Excel serial number conversion to date in javascript
function ExcelDateToJSDate(serial) {
var utc_days = Math.floor(serial - 25569);
var utc_value = utc_days * 86400;
var date_info = new Date(utc_value * 1000);
var fractional_day = serial - Math.floor(serial) + 0.0000001;
var total_seconds = Math.floor(86400 * fractional_day);
var seconds = total_seconds % 60;
@mikebobadilla
mikebobadilla / Sizes.md
Created February 9, 2016 06:14 — forked from jperl/Sizes.md
Meteor App Icon and Launch Screen Size Guide

###Icons

Name Size
iphone_2x 120x120
iphone_3x 180x180
ipad 76x76
ipad_2x 152x152
android_ldpi 36x36
android_mdpi 48x48
# This gist illustrates how to create and execute a payment with Paypal using their REST API.
# For additional informations, check the documentation: https://developer.paypal.com/docs/api/
# Note 1: I assume that you have already created a developer account for Paypal and an application.
# To test that your code is working, use the sandbox accounts.
# https://developer.paypal.com/webapps/developer/applications/accounts
# Note 2: we will not use the Paypal REST API SDK package for Node.js
# https://github.com/paypal/rest-api-sdk-nodejs
@mikebobadilla
mikebobadilla / dabblet.css
Last active September 28, 2016 16:33
Untitled
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
}/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;