This file contains hidden or 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 UIKit | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
// Override point for customization after application launch. |
This file contains hidden or 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 UIKit | |
import UserNotifications | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
let notificationDelegate = CustomNotifications() |
This file contains hidden or 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 Foundation | |
import UserNotifications | |
class CustomNotificationDelegate: NSObject, UNUserNotificationCenterDelegate { | |
func userNotificationCenter(_ center: UNUserNotificationCenter, | |
willPresent notification: UNNotification, | |
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { | |
//Play sound, show alert (will occur if enabled by user AND scheduled in the notification request). |
This file contains hidden or 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 csv | |
import sys | |
def getmaxsize(): | |
"""Returns max field size.""" | |
return csv.field_size_limit(sys.maxsize) | |
def setmaxsize(size = 500 * 1024 * 1024): | |
"""Sets max field size as high as possible.""" |
This file contains hidden or 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
dbpath = "/.../test.db" | |
>>> import sqlite3 | |
>>> #Create the database. | |
>>> connection = sqlite3.connect(dbpath) | |
>>> cursor = connection.cursor() | |
>>> cursor.execute("CREATE TABLE Test (testcolumn TEXT);") | |
<sqlite3.Cursor object at 0x111952ce0> | |
>>> cursor.execute("INSERT INTO Test VALUES(NULL);") | |
<sqlite3.Cursor object at 0x111952ce0> |
This file contains hidden or 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 StreamTSV | |
import sqliteops | |
import create_statements as cts | |
import os | |
table_urls = [("Title", "https://datasets.imdbws.com/title.basics.tsv.gz"), | |
("Name", "https://datasets.imdbws.com/name.basics.tsv.gz"), |
This file contains hidden or 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
create_Title = ("CREATE TABLE IF NOT EXISTS Title (" | |
"tconst TEXT PRIMARY KEY, " | |
"title_type TEXT, " | |
"primary_title TEXT, " | |
"original_title TEXT, " | |
"is_adult INTEGER, " | |
"start_year INTEGER, " | |
"end_year INTEGER, " | |
"runtime_minutes INTEGER, " | |
"genres TEXT);") |
This file contains hidden or 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
aws_secret_access_key = "BmUejjI9Fp23FAOJoijeRAJse/fAEIfo4FAJFIwe" | |
#It is absolutely infeasible to find a string which hashes to something | |
#that even remotely resembles your aws_secret_access_key. | |
the_password_I_will_enter = "MySecretPassword" | |
#Note that the_password_I_will_enter is a string rather than a bytes object: | |
""" | |
>>> isinstance("MySecretPassword", str) |
This file contains hidden or 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
>>> aws_access_key_id = "BLPEVU91RZCTCC4CE01J" | |
>>> aws_secret_access_key = "AOIjf2CEW2faefAErwrt43G/9OaJfijvansEJfib" | |
>>> region_name = "us-east-1" | |
>>> the_password_I_type = "MySecretPassword" | |
>>> ciphertext = encrypt(the_password_I_type.encode(), aws_secret_access_key.encode()) | |
>>> #Let's take a look! | |
>>> ciphertext | |
'OJ+T8lHBRqxGyZjTsJjP634iBhjJImYyaep/nv03aCnQkv9+8+I/m+2m1dsAv9JGu6JjnUcVyQSd5WPUEAqSYg==' |
This file contains hidden or 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 java.io.*; | |
class Main { | |
public static void main(String[] args) { | |
String fileName = "blog.txt"; | |
FileReader fileReader = new FileReader(fileName); | |
BufferedReader br = new BufferedReader(fileReader); | |
String line; | |
OlderNewer