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
/// Aggregated continuation, uses `CheckedContinuation` for DEBUG build, uses `UnsafeContinuation` for RELEASE build. | |
public struct Continuation<T, E>: Sendable where E: Error { | |
#if DEBUG | |
public let continuation: CheckedContinuation<T, E> | |
public init(continuation: CheckedContinuation<T, E>) { | |
self.continuation = continuation | |
} | |
#else |
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
// | |
// NSObject+Observation.swift | |
// Pods | |
// | |
// Created by Honghao Zhang on 2016-02-11. | |
// | |
// | |
import Foundation |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
// Compare old data model with new data model and perform batch update for collection view | |
/** | |
* Perform batch update on collection view, use old stories and new stories to make comparison | |
* groupId property of story is used for comparison | |
* | |
* PRE: make sure collection view's data model is update with newArray | |
* | |
* After animation completed, visible cells' view are updated | |
* |
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
def isPrime(n): | |
'''check if integer n is a prime''' | |
# make sure n is a positive integer | |
n = abs(int(n)) | |
# 0 and 1 are not primes | |
if n < 2: | |
return False | |
# 2 is the only even prime number | |
if n == 2: | |
return True |
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 python | |
from random import randint | |
from copy import deepcopy | |
def find_mincut(n, e): | |
mincut = len(e) | |
N = 2000 | |
for x in range(N): | |
nodes = deepcopy(n) |
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
#include<iostream> | |
#include<set> | |
using namespace std; | |
class Node { | |
public: | |
int data; | |
Node *next; | |
Node(int dat) { | |
data = dat; |
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
#include<iostream> | |
using namespace std; | |
class Node { | |
public: | |
int data; | |
Node *next; | |
Node(int dat) { | |
data = dat; | |
next = NULL; |
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
#include<iostream> | |
using namespace std; | |
void countSort(int a[], int size, int k) { | |
int *b = (int *)malloc(sizeof(int) * k); | |
memset(b, 0, sizeof(int) * k); | |
for (int i = 0; i < size; i++) { | |
b[a[i]]++; | |
} | |
for (int i = 1; i < k; i++) { |
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
include<set> | |
include<cstring> | |
using namespace std; | |
bool checkSame(string a, string b) { | |
if (a.length() != b.length()) { | |
return false; | |
} | |
map<char, int> testMap; | |
int length = (int)a.length(); |
NewerOlder