Skip to content

Instantly share code, notes, and snippets.

View sean7218's full-sized avatar
🛠️

Sean Zhang sean7218

🛠️
View GitHub Profile
@sean7218
sean7218 / draft.py
Created December 18, 2017 14:04
draft.py
class StackView(View):
def get(request):
return render(request, 'stacker/stack.html', context)
#include <stdio.h>
int main(){
printf("HELLO WORLD\n");
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
if ([selectedRowsArray containsObject:[contentArray objectAtIndex:indexPath.row]]) {
@sean7218
sean7218 / UIImageView.swift
Created August 13, 2018 18:20
load the image from url
extension UIImageView {
func load(url: URL) {
DispatchQueue.global().async { [weak self] in
if let data = try? Data(contentsOf: url) {
if let image = UIImage(data: data) {
DispatchQueue.main.async {
self?.image = image
}
}
}
class SnappingCollectionViewLayout: UICollectionViewFlowLayout {
override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint {
guard let collectionView = collectionView else { return super.targetContentOffset(forProposedContentOffset: proposedContentOffset, withScrollingVelocity: velocity) }
var offsetAdjustment = CGFloat.greatestFiniteMagnitude
let horizontalOffset = proposedContentOffset.x + collectionView.contentInset.left
let targetRect = CGRect(x: proposedContentOffset.x, y: 0, width: collectionView.bounds.size.width, height: collectionView.bounds.size.height)
for family in UIFont.familyNames.sorted() {
let name = UIFont.fontNames(forFamilyName: family)
print("Family \(family) and Name: \(name)")
}
/*
Family Academy Engraved LET and Name: ["AcademyEngravedLetPlain"]
Family Al Nile and Name: ["AlNile", "AlNile-Bold"]
Family American Typewriter and Name: ["AmericanTypewriter-CondensedBold", "AmericanTypewriter-Condensed", "AmericanTypewriter-CondensedLight", "AmericanTypewriter", "AmericanTypewriter-Bold", "AmericanTypewriter-Semibold", "AmericanTypewriter-Light"]
@sean7218
sean7218 / .gitlab-ci.yml
Created October 30, 2019 01:26 — forked from Mazuh/.gitlab-ci.yml
Example of gitlab CI/CD for a create-react-app application on Amazon S3 Bucket.
image: nikolaik/python-nodejs:latest
stages:
- install
- test
- deploy
prodInstall:
stage: install
script: