Skip to content

Instantly share code, notes, and snippets.

View pixnbit's full-sized avatar

Xiaochao Yang pixnbit

  • San Francisco Bay Area
  • 08:02 (UTC -07:00)
View GitHub Profile
@pixnbit
pixnbit / TwitchService.java
Created January 18, 2023 17:11
TwitchService with generics
package com.laioffer.twitch.external;
import com.laioffer.twitch.external.model.Clip;
import com.laioffer.twitch.external.model.Stream;
import com.laioffer.twitch.external.model.Game;
import com.laioffer.twitch.external.model.TwitchToken;
import com.laioffer.twitch.external.model.Video;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClientResponseException;
@pixnbit
pixnbit / ContactPhonesTest.kt
Created April 14, 2021 02:09 — forked from mustafo/ContactPhonesTest.kt
The right way to use one to many relationship in jdbi with kotlin
import org.jdbi.v3.core.kotlin.KotlinMapper
import org.jdbi.v3.core.mapper.RowMapperFactory
import org.junit.jupiter.api.Test
import tj.alif.core.app.db.RepositoryTest
import org.jdbi.v3.core.result.RowView
data class Contact (
val id: Int,
val name: String,
@pixnbit
pixnbit / AppReviews
Created February 26, 2018 05:57 — forked from kgn/AppReviews
App Reviews - Python script to retrieve App Store reviews and save them to a CSV file
#!/usr/bin/env python
try:
# For Python 3.0 and later
from urllib.request import urlopen
except ImportError:
# Fall back to Python 2's urllib2
from urllib2 import urlopen
import json
CIFilter *resizeFilter = [CIFilter filterWithName:@"CILanczosScaleTransform"];
[resizeFilter setValue:ciImage forKey:@"inputImage"];
[resizeFilter setValue:[NSNumber numberWithFloat:1.0f] forKey:@"inputAspectRatio"];
[resizeFilter setValue:[NSNumber numberWithFloat:xRatio] forKey:@"inputScale"];
CIFilter *cropFilter = [CIFilter filterWithName:@"CICrop"];
CIVector *cropRect = [CIVector vectorWithX:rect.origin.x Y:rect.origin.y Z:rect.size.width W:rect.size.height];
[cropFilter setValue:resizeFilter.outputImage forKey:@"inputImage"];
[cropFilter setValue:cropRect forKey:@"inputRectangle"];
CIImage *croppedImage = cropFilter.outputImage;
@pixnbit
pixnbit / TransformFromPointCorrespondence.m
Last active August 28, 2018 15:29
Calculate the affine transform matrix from 3 point correspondance in Objective-C (with Accelerate framework for LAPACK matrix inverse)
CGPoint p1, p2, p3, q1, q2, q3;
// TODO: initialize points
double A[36];
A[ 0] = p1.x; A[ 1] = p1.y; A[ 2] = 0; A[ 3] = 0; A[ 4] = 1; A[ 5] = 0;
A[ 6] = 0; A[ 7] = 0; A[ 8] = p1.x; A[ 9] = p1.y; A[10] = 0; A[11] = 1;
A[12] = p2.x; A[13] = p2.y; A[14] = 0; A[15] = 0; A[16] = 1; A[17] = 0;
A[18] = 0; A[19] = 0; A[20] = p2.x; A[21] = p2.y; A[22] = 0; A[23] = 1;
@pixnbit
pixnbit / CIFaceFeature+UIImageOrientation.h
Last active May 3, 2018 01:59
Category on CIFaceFeature to convert CGPoint and CGRect with respect to UIImageOrientation, also with handy helpers to convert locations inside of a given UIView size.
//
// CIFaceFeature+UIImageOrientation.h
//
//
// Created by Xiaochao Yang on 6/9/13.
// Copyright (c) 2013 Xiaochao Yang. All rights reserved.
//
#import <CoreImage/CoreImage.h>