Skip to content

Instantly share code, notes, and snippets.

▶ ipython
Python 3.7.3 (default, Dec 13 2019, 19:58:14)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.14.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: def outer():
...: message = 'hi'
...:
In [2]: def outer():
@dmatt
dmatt / gist:e26d5c24eb184ce7d0587a28a9010681
Created January 23, 2018 01:07
JSON_Desk_Zapier_Webhook.json
{
"case_created_at":"{{case.created_at}}",
"Link":"{{case.direct_url}}",
"email": "{{customer.email}}",
"labels":"{{case.labels}}",
"body":"{{case.interactions.last.interactionable.body}}"
}
// Make API call to darksky to get weather temp and description
$.ajax({
method: 'GET',
dataType: 'jsonp',
url: 'https://api.darksky.net/forecast/[KEY]/' + coordinates,
data: {
exclude: '[minutely,daily,alerts,flags]'
},
units: '[si]',
})
@dmatt
dmatt / minimalist.html
Last active August 29, 2015 14:01
Tumblr minimalist theme + Disqus
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
==========================================================================
____ ___ __ __
/\ _`\ __ /\_ \ /\ \/\ \ __
\ \ \L\ \\_\ __ _ __\//\ \ \ \ \ \ \ ___ /\_\ ___ ___
\ \ ,__//\ \/\ \/'\ /'__`\\ \ \ \ \ \ \ \ /' _ `\/\ \ / __`\/' _ `\
\ \ \/ \ \ \/> <//\ __/ \_\ \_ \ \ \_\ \/\ \/\ \ \ \/\ \L\ \\ \/\ \
import requests
import json
case_list = ['251756', '251755']
for case_id in case_list:
url = 'https://disqus.desk.com/api/v2/cases/'+str(case_id)
headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
# this requires that the agent enters Task in issue_ticket and label feild so that no context is lost
@dmatt
dmatt / hello.py
Last active December 24, 2015 02:29
current hello.py code
import os
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello World
@app.route('/')
@dmatt
dmatt / shortname_redirect.html
Created July 25, 2013 17:50
How to embed the embed.js file directly without using the shortname redirect method.
<HTML>
<head>
</head>
<body>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'EXAMPLE'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
@dmatt
dmatt / BattleShip.py
Last active December 17, 2015 23:29
Codecademy - Battleship 1 player, 1 ship, 4 turns
from random import randint
board = []
for x in range(5):
board.append(["O"] * 5)
def print_board(board):
for row in board:
print " ".join(row)
@dmatt
dmatt / PygLatin.py
Last active December 17, 2015 04:09
Code Academy - Pyg Latin Translator
pyg = 'ay'
print "Welcome to the Pyg Latin Translator"
original = raw_input('Enter a word to be translated:')
if len(original) > 0 and original.isalpha():
word = original.lower()
first = word[0]
if first in ["a","e","i","o","u"]:
new_word = word+pyg