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
package main | |
import ( | |
"crypto" | |
"crypto/rsa" | |
"crypto/sha256" | |
"encoding/base64" | |
"encoding/json" | |
"math/big" | |
"math/rand" | |
"strings" |
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
package main | |
import ( | |
"fmt" | |
"math/big" | |
) | |
func encrypt(plainText string, e, n int) (cipherText []int) { | |
for _, p := range plainText { | |
//Exp sets c = p**e mod |n| | |
c := new(big.Int). | |
Exp(big.NewInt(int64(p)), big.NewInt(int64(e)), big.NewInt(int64(n))). |
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
#!/usr/bin/env python | |
from __future__ import print_function | |
import json | |
import subprocess | |
import multiprocessing | |
import sys | |
import os | |
import signal | |
import threading |
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
#!/usr/bin/python | |
# -*- coding: ascii -*- | |
# A pythonic implementation of the Aho-Corasick string searching algorithm which (I hope | |
# you will find) needs no documentation if you are reading the white paper along-side. | |
# https://en.wikipedia.org/wiki/Aho?Corasick_algorithm | |
from collections import deque, namedtuple | |
from typing import Iterable, Dict, List, Callable, Optional, Set, Generator | |
FAILURE = () |
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 CloudKit | |
import XCPlayground | |
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true | |
func main() { | |
let filePath = Bundle.main.path(forResource: "sandboxReceipt", ofType: "") | |
// get the contentData | |
let base64 = FileManager.default.contents(atPath: filePath!)!.base64EncodedString() |
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
let df = DateFormatter() | |
df.dateFormat = "yyyy-MM-dd HH:mm:ss Z" | |
let startDate = df.date(from: "2017-09-27 14:50:19 +0000")! | |
let endDate = df.date(from: "2017-09-27 15:14:28 +0000")! | |
let cmm = CMMotionActivityManager() | |
let lowestConfidence = CMMotionActivityConfidence.low | |
cmm.queryActivityStarting(from: startDate, to: endDate, to: OperationQueue.main) { | |
(activities, error) in | |
guard let activities = activities else { |
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 CoreData | |
class GenericTableFetchResultsController: NSObject { | |
fileprivate var tableView: UITableView! | |
fileprivate var rowAnimation: UITableViewRowAnimation! | |
init(tableView: UITableView, rowAnimation: UITableViewRowAnimation) { | |
self.tableView = tableView |
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 CoreLocation | |
extension CLLocationCoordinate2D { | |
/** | |
Calculates a bbox around this CLLocationCoordinat2D by describing a distance that is roughly analagous to | |
the radius of a circle with a center at this coordinate and the radius is the distance and inscribes the circle | |
to the bbox created. | |
This tangential point method of calculating the box is described in Handbook of Mathematics By I.N. Bronshtein, | |
K.A. Semendyayev, Gerhard Musiol, Heiner Mühlig |
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 CoreData | |
class GenericCollectionFetchResultsController: NSObject { | |
fileprivate var blockOperation = BlockOperation() | |
//This flag is a workaround to a bug in iOS: http://openradar.appspot.com/12954582 | |
fileprivate var shouldReloadCollectionView = false | |
fileprivate var collectionView: UICollectionView! | |