Skip to content

Instantly share code, notes, and snippets.

View summea's full-sized avatar
💭
learning

summea summea

💭
learning
View GitHub Profile
@summea
summea / get_example.py
Last active March 16, 2021 14:20
Examples of Getting and Posting JSON to a Remote Server and Getting a Response Back using Python
# Importing the json module to be able to work with json data more easily.
import json
# Importing "Request" and "urlopen" from urllib.request module to be able
# to make a remote call to fetch the remote json data.
from urllib.request import Request, urlopen
# Build the request that will later be made to remote server.
# In this case, the server is a fake json data service.
# Using the "GET" method here because we are fetching data from remote
@summea
summea / poll.html
Created July 20, 2020 23:27
Poll Example
<html>
<head>
<title>Example</title>
</head>
<body>
What is your favorite season?
<input type="radio" id="answer_1a" name="answer_1" value="Fall" />
<label for="answer_1a">Fall</label>
<input type="radio" id="answer_1b" name="answer_1" value="Winter" />
<label for="answer_1b">Winter</label>
@summea
summea / example.html
Created July 16, 2020 04:11
Example JavaScript Page
<html>
<head>
<title>Example</title>
</head>
<body>
Question: <input id="question" /><br><br>
<button onclick="getAnswer()">Get Answer</button><br><br>
Answer: <textarea id="answer"></textarea><br><br>
<script>
function getAnswer() {
@summea
summea / gist:d153982adfec8e824cbb93bfaae478fc
Last active February 27, 2017 20:55
Setting up SSL for RabbitMQ
To fix the following error:
<<< TLS 1.2 Alert [length 0002], fatal unknown_ca
02 30
SSL3 alert read:fatal:unknown CA
SSL_connect:error in SSLv3 write certificate verify A
write:errno=104
DigiCert:
1. Download certifcate files (PEM format)
/usr/local/lib/python3.5/site-packages/requests/cacert.pem
Traceback (most recent call last):
File "test.py", line 24, in <module>
ssl_keyfile = '/home/summersan/kafka-ssl/nocrypt-key.pem')
File "/usr/local/lib/python3.5/site-packages/kafka/producer/kafka.py", line 334, in __init__
**self.config)
File "/usr/local/lib/python3.5/site-packages/kafka/client_async.py", line 199, in __init__
self._bootstrap(collect_hosts(self.config['bootstrap_servers']))
File "/usr/local/lib/python3.5/site-packages/kafka/client_async.py", line 229, in _bootstrap
bootstrap.connect()
<#
zip-files
=========
Gather a list of text files in a directory
and archive the files in a .zip file.
#>
$zipfile_folder = "files-for-backup"
$zipfile = "${zipfile_folder}.zip"
@summea
summea / gist:0337c1eb408bd8006781fd614bdd3460
Last active June 11, 2016 04:19
powershell: txt2html
<#
txt2html
========
Gather a list of text files in a directory
and convert the text files to html files.
#>
$list = ls *.txt
foreach ($item in $list) {
$filename = $item.name
$new_filename = $filename + ".html"