Instantly share code, notes, and snippets.

View script.pseudo
function does_file_exist(filename):
...
function get_modified_at(filename):
...
function print_file_is_deleted(filename):
...
function print_file_is_created(filename):
View diff.py
"""
Hacky shell tool for finding dict deep diffs
a = {
'b': {
'c': 2,
'd': 3
},
'e': 2
}
View eval.py
def get_pupil_from_direction(classroom, x, y, dx, dy):
x += dx
y += dy
if min(x, y) < 0:
return None
if y >= len(classroom):
return None
if x >= len(classroom[y]):
return None
return classroom[y][x]
View ContainerExample.js
import { connect } from 'react-redux';
const mapStateToProps = ({ refreshThing }) => {
return {
refreshInterval: 60000,
refreshEnabled: true,
};
};
const mapDispatchToProps = dispatch => {
View script.py
def main(argv):
print('Hi')
the_name = input('Your name, please?\n> ')
print('Hi {} <3'.format(name))
View handler.py
# This file is your Lambda function
import base64
import json
import boto3
def save_to_bucket(event, context):
AWS_BUCKET_NAME = 'my-bucket-name'
s3 = boto3.resource('s3')
View handler.py
# This file is your Lambda function
import json
import boto3
def save_to_bucket(event, context):
AWS_BUCKET_NAME = 'my-bucket-name'
s3 = boto3.resource('s3')
bucket = s3.Bucket(AWS_BUCKET_NAME)
path = 'my-path-name.txt'
View handler.py
# This file is your Lambda function
import json
def mirror_query_strings(event, context):
body = {
"queryStrings": event['queryStringParameters']
}
return {
"statusCode": 200,
View index.js
// This allows you to use <a href="#id-of-tab"> as well as handle direct links and back button (popstate)
(function(){
var url = document.location.toString();
if (url.match('#')) {
$('.nav-tabs a[href="#' + url.split('#')[1] + '"]').tab('show');
}
// Change hash for page-reload
$('.nav-tabs a').on('shown.bs.tab', function (e) {
window.location.hash = e.target.hash;
View serve-static.js
// index.html up at localhost:8080/status
//
// requirements: mime (npm install mime --save)
const path = require('path');
const fs = require('fs');
var mime = require('mime');
const serveFile = filePath => (req, res) => {
const fullPath = path.join(__dirname, filePath);