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
@JsonInclude(JsonInclude.Include.NON_NULL) | |
@JsonIgnoreProperties(ignoreUnknown = true) | |
@Entity | |
public class Data { | |
@NotNull | |
@Id | |
@Column(length = 255, updatable = false, nullable = false, unique = true) | |
private String 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
extension UILabel { | |
func textWidth() -> CGFloat { | |
return UILabel.textWidth(label: self) | |
} | |
class func textWidth(label: UILabel) -> CGFloat { | |
return textWidth(label: label, text: label.text!) | |
} | |
class func textWidth(label: UILabel, text: String) -> CGFloat { |
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
// Call this in layoutSubView or viewDidLoad | |
self.imageView.layer.sublayers?.forEach { $0.removeFromSuperlayer() } | |
let width = self.bounds.width | |
let height = self.bounds.height | |
let sHeight:CGFloat = 60.0 | |
let shadow = UIColor.black.withAlphaComponent(0.6).cgColor | |
// Add gradient bar for image on top | |
let topImageGradient = CAGradientLayer() |
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 co.threelines.puffin.util.GeoSpatialUtil; | |
import com.spatial4j.core.shape.Point; | |
import org.apache.commons.lang3.tuple.Pair; | |
import java.util.Random; | |
/** | |
* Created by Fuxing | |
* Date: 5/7/2015 | |
* Time: 3:22 AM |
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 countLabelLines(label: UILabel) -> Int { | |
// Call self.layoutIfNeeded() if your view uses auto layout | |
let myText = label.text! as NSString | |
let rect = CGSize(width: label.bounds.width, height: CGFloat.greatestFiniteMagnitude) | |
let labelSize = myText.boundingRect(with: rect, options: .usesLineFragmentOrigin, attributes: [NSAttributedStringKey.font: label.font], context: nil) | |
return Int(ceil(CGFloat(labelSize.height) / label.font.lineHeight)) | |
} |
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
const express = require('express') | |
const SamlStrategy = require('passport-saml').Strategy | |
const passport = require('passport') | |
const cookieSession = require('cookie-session') | |
const cookieParser = require('cookie-parser') | |
// Create express instance | |
const app = express() |
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 collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { | |
let text = collections[indexPath.row].name | |
let width = UILabel.textWidth(font: titleFont, text: text) | |
return CGSize(width: width + left + right, height: height) | |
} |
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
Table table = dynamoDB.getTable(UserActivity.Table.TableName); | |
Map<String, Object> valueMap = new HashMap<>(); | |
valueMap.put(":user_id", getUserId()); | |
valueMap.put(":state", UserActivity.STATE_ACTIVE); | |
valueMap.put(":type", type); | |
QuerySpec spec = new QuerySpec() | |
.withNameMap(new NameMap() | |
.with("#s", "State").with("#t", "Type")) |
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 javax.validation.ConstraintValidator; | |
import javax.validation.ConstraintValidatorContext; | |
/** | |
* Created by: Fuxing | |
*/ | |
public class EnumValidator implements ConstraintValidator<ValidEnum, Enum> { | |
@Override | |
public boolean isValid(Enum value, ConstraintValidatorContext context) { | |
if (value == null) return false; |
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 dev.fuxing.utils; | |
import com.fasterxml.jackson.core.JsonProcessingException; | |
import com.fasterxml.jackson.databind.JsonNode; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import com.fasterxml.jackson.databind.node.ArrayNode; | |
import com.fasterxml.jackson.databind.node.ObjectNode; | |
import com.fasterxml.jackson.databind.type.CollectionType; | |
import com.fasterxml.jackson.databind.type.MapType; | |
import dev.fuxing.err.JsonException; |
NewerOlder