This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
r/DailyProgrammer Challenge #364 | |
Dice Roller | |
2018 - 06 - 18 | |
https://www.reddit.com/r/dailyprogrammer/comments/8s0cy1/20180618_challenge_364_easy_create_a_dice_roller/?st=jiklnspm&sh=2cffa04e | |
""" | |
from random import randint | |
def identify_dice(dice_string): | |
i = dice_string.find('d') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ForegroundColour=62,69,78 | |
BackgroundColour=253,241,212 | |
CursorColour=62,69,78 | |
Black=62,69,78 | |
BoldBlack=58,72,91 | |
Red=102,0,0 | |
BoldRed=128,0,0 | |
Green=133,153,0 | |
BoldGreen=133,153,0 | |
Yellow=102,68,0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl 'https://q0tmlopf1j-dsn.algolia.net/1/indexes/*/queries?x-algolia-agent=Algolia%20for%20vanilla%20JavaScript%20(lite)%203.27.0%3BJS%20Helper%202.25.1&x-algolia-application-id=Q0TMLOPF1J&x-algolia-api-key=30a0c84a152d179ea8aa1a7a59374d08' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Firefox/68.0' -H 'Accept: application/json' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'content-type: application/x-www-form-urlencoded' -H 'Origin: https://www.carnegiehall.org' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Cache-Control: max-age=0, no-cache' -H 'Pragma: no-cache' --data '{"requests":[{"indexName":"sitecore-events","params":"query=&hitsPerPage=10&page=0&facets=%5B%22eventtype%22%2C%22seasonnumber%22%2C%22facilityfacet%22%2C%22genre%22%2C%22instrument%22%5D&tagFilters=&facetFilters=%5B%22eventtype%3ACarnegie%20Hall%20Presents%22%2C%22eventtype%3AFree%20Events%22%2C%22facilityfacet%3AOffsite%22%2C%5B%22facilityfacet%3AOffsite%22%5D%5D&numericFilters=%5B%22startdate%3E15724417131 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const url = 'http://localhost:3000/toys'; | |
document.addEventListener("DOMContentLoaded", () => { | |
const toyCollection = document.querySelector('#toy-collection') | |
fetch(url) | |
.then(resp => resp.json()) | |
.then(toys => { | |
for(const toy of toys) { | |
const toyDiv = document.createElement('div') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DirectUploadController < ApplicationController | |
def create | |
response = generate_direct_upload(blob_params) | |
render json: response | |
end | |
private | |
def blob_params | |
params.require(:file).permit(:filename, :byte_size, :checksum, :content_type, metadata: {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UsersController < ApplicationController | |
def create | |
resume = params[:pdf] | |
params = user_params.except(:pdf) | |
user = User.create!(params) | |
user.resume.attach(resume) if resume.present? && !!user | |
render json: user.as_json(root: false, methods: :resume_url).except('updated_at') | |
end | |
private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CryptoJS from 'crypto-js' | |
// Note that for larger files, you may want to hash them incrementally. | |
// Taken from https://stackoverflow.com/questions/768268/ | |
const md5FromFile = (file) => { | |
// FileReader is event driven, does not return promise | |
// Wrap with promise api so we can call w/ async await | |
// https://stackoverflow.com/questions/34495796 | |
return new Promise((resolve, reject) => { | |
const reader = new FileReader() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { fileChecksum } from 'utils/checksum' | |
const createPresignedUrl = async(file, byte_size, checksum) => { | |
let options = { | |
method: 'POST', | |
headers: { | |
'Accept': 'application/json', | |
'Content-Type': 'application/json', | |
}, | |
body: JSON.stringify({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for sending the request | |
require "uri" | |
require "net/http" | |
require "json" | |
# for loading our environment variables | |
require "dotenv/load" | |
# for scraping our blog | |
require "open-uri" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ flask run | |
* Environment: production | |
WARNING: This is a development server. Do not use it in a production deployment. | |
Use a production WSGI server instead. | |
* Debug mode: off | |
Usage: flask run [OPTIONS] | |
Error: While importing "app", an ImportError was raised: | |
Traceback (most recent call last): |
OlderNewer