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
from bs4 import BeautifulSoup | |
from urllib.request import urlopen | |
import requests | |
import zipfile | |
import io | |
""" | |
Fails file extraction requires a password :( | |
""" |
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 sqlite3 | |
import pdb | |
class DatabaseConnector(object): | |
_max_connections = 3 | |
_current_connections = 0 | |
def __init__(self, server, database, schema): | |
self.server = server, | |
self.database = database, |
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 sqlite3 | |
import pdb | |
from abc import ABCMeta, abstractmethod | |
class DatabaseConnector(metaclass=ABCMeta): | |
"""A class to help you connect to various databases""" | |
__metaclass__ = ABCMeta | |
_max_connections = 3 | |
_current_connections = 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
/* | |
Setup a recursive CTE to iterate over ascii ranges and remove | |
any characters within given ranges. Remember max recursion depth | |
is sql server is 100 by default | |
*/ | |
--Initial increment handler | |
DECLARE @controlcharacter int = 32, | |
--Second increment handler | |
@extendedcharacter int = 256; |
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 asyncio | |
import aioodbc | |
import pyodbc | |
from concurrent.futures import ThreadPoolExecutor | |
loop = asyncio.get_event_loop() | |
async def conn_attributes(conn): | |
conn.setdecoding(pyodbc.SQL_CHAR, encoding='utf-8') | |
conn.setdecoding(pyodbc.SQL_WCHAR, encoding='utf-8') |
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
#!/usr/bin/env python3 | |
# pip3 install selenium | |
from selenium import webdriver | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.support.ui import WebDriverWait | |
from selenium.webdriver.support import expected_conditions as EC | |
from selenium.webdriver.chrome.options import Options | |
import time |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" | |
"http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>org.gnu.emacs.daemon</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/opt/local/bin/emacs</string> |
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
#!/usr/bin/env bash | |
set -euo pipefail | |
I don't normally use bash, but found this to be interesting: | |
The first statement is a Mac, GNU/Linux, and BSD portable way of finding the location of the bash interpreter. The second statement combines | |
“set -e” which ensures that your script stops on first command failure. By default, when a command fails, BASH executes the next command. Looking at the logs, you might feel that the script executed successfully while some commands might have failed. Caveat: Be careful about applying it to existing scripts. | |
“set -u” which ensures that your script exits on the first unset variable encountered. Otherwise, bash replaces the unset variables with empty default values. | |
“set -o pipefail” which ensures that if any command in a set of piped commands failed, the overall exit status is the status of the failed command. Otherwise, the exit status is the status of the last command. |
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
//! Example based on the AutoFac 'getting started' example | |
//! (http://autofac.readthedocs.io/en/latest/getting-started/index.html) | |
use shaku::{module, Component, Interface}; | |
use std::sync::Arc; | |
module! { | |
pub AutoFacModule { | |
components = [ConsoleOutput, TodayWriter], | |
providers = [] |
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 PlaygroundSupport | |
import MetalKit | |
guard let device = MTLCreateSystemDefaultDevice() else { | |
fatalError("GPU Is Not Supported") | |
} | |
let frame = CGRect(x: 0, y: 0, width: 600, height: 600) | |
let view = MTKView(frame: frame, device: device) |
OlderNewer