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 <array> | |
template<typename T, size_t N, size_t M> | |
class matrix { | |
public: | |
template<size_t ... n> | |
constexpr explicit matrix(const T (&...list)[n]) : _data{} | |
{ | |
auto pos = &_data[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
std::string reverse_domain2(const std::string& s) { | |
std::string result; | |
auto index = 0; | |
for (const auto& c : s) { | |
if (c == '.') { | |
index = 0; | |
result.insert(result.begin() + index, '.'); | |
continue; | |
} |
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
data class Task(val name: String, val files: List<String>, val deps: List<String>) | |
fun globMatches(pattern: String, path: String): Boolean { | |
val start = "^" | |
val end = "$" | |
val regex = buildString { | |
append(start) | |
append(pattern.replace("([\\^\\[\\]\\.\\+\\?])".toRegex(), "\\\\$1").replace("*", "[^/]*")) | |
append(end) |
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
/** | |
* Apple's `Result` type ported to Kotlin. Instead of using enums with associated values, this implementation uses a | |
* sealed interface with implementations. | |
* | |
* ``` | |
* /* create a Result */ | |
* | |
* fun makeResult() = Result { // throw a `Throwable` or return a value } | |
* |
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
func index(countries: [Country]) { | |
let attributeSet = CSSearchableItemAttributeSet(itemContentType: kUTTypePNG as String) | |
let items = countries.map { (country) -> CSSearchableItem in | |
attributeSet.title = country.name.common | |
attributeSet.contentDescription = "The flag of \(country.name.official)" | |
attributeSet.thumbnailData = UIImage(named: country.flagImageName)!.pngData()! | |
return CSSearchableItem( | |
uniqueIdentifier: country.id, |
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
class FlagListTableViewCell: UITableViewCell, ReusableView { | |
private let flagImageView = UIImageView() | |
private var cellHeightConstraint: NSLayoutConstraint! | |
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | |
super.init(style: style, reuseIdentifier: reuseIdentifier) | |
self.cellHeightConstraint = self.flagImageView.heightAnchor.constraint(equalToConstant: 0) | |
self.cellHeightConstraint.isActive = 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
package com.eecs1021; | |
import java.io.PrintStream; | |
import java.util.List; | |
import java.util.Objects; | |
import java.util.stream.Collectors; | |
import java.util.stream.Stream; | |
class Student { | |
private final String name; |
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
/** | |
* Recursively maps values of an object | |
* | |
* @param object the target object | |
* @param transformation a mapping function, which is applied recursively to the deepest values | |
*/ | |
function mapValues<O, K extends keyof O, R>(object: O, transformation: RecursiveTransform<O[K], R>): MappedObject<O, R> { | |
return Object.entries(object).reduce((prev, [key, value]) => { | |
prev[key] = typeof value === 'object' ? mapValues(value, transformation) : transformation(value); | |
return prev; |
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 jm.constants.Instruments; | |
import jm.constants.Pitches; | |
import jm.constants.RhythmValues; | |
import jm.music.data.*; | |
import jm.util.Play; | |
import java.util.List; | |
public class Main { | |
public static void main(String[] args) { |
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
query IssueComments($owner: String!, $name: String!, $num: Int!) { | |
rateLimit { | |
limit | |
cost | |
remaining | |
resetAt | |
} | |
repository(owner: $owner, name: $name) { | |
issue(number: $num) { | |
timelineItems(last: 10, itemTypes: [ADDED_TO_PROJECT_EVENT, REMOVED_FROM_PROJECT_EVENT, MOVED_COLUMNS_IN_PROJECT_EVENT, RENAMED_TITLE_EVENT]) { |
NewerOlder