Skip to content

Instantly share code, notes, and snippets.

import UIKit
/* Example of how to use it:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var label: UILabel!
@IBOutlet weak var textView: UITextView!
@lionhylra
lionhylra / NSAttributedString+compose.swift
Last active January 20, 2020 04:39
A NSAttributedString extension that adds a convenient method for composing a NSAttributedString with links and images.
import UIKit
// How to use:
/*
let label = UILabel()
let textView = UITextView()
label.attributedText = .compose(
"Please go to ",
.link(label: "Google",
@lionhylra
lionhylra / scrollable_overlay
Created November 24, 2013 06:01
类似于perinterest的overlay效果
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.noscroll{
overflow:hidden;
}
.mask{
position:fixed;
overflow-y:scroll;
@lionhylra
lionhylra / loadImgByUrl.js
Created November 16, 2013 04:46
jQuery常用 通过url加载图片 | 图片统一尺寸 | 窗口时滚动加载 | 窗口平滑滚动 | 密码强度
var nextimage = "http://www.gbtags.com/gb/networks/uploadimgthumb/55d67b14-fb25-45e7-acc8-211a41047ef0.jpg";
$(document).ready(function(){
window.setTimeout(function(){
var img = $("<img>").attr("src", nextimage).load(function(){
$('div').append(img);
});
}, 100);
});
@lionhylra
lionhylra / LinQ.cs
Created November 2, 2013 05:27
controller
public ActionResult SearchIndex(string searchString)
{
var movies = from m in db.Movies
select m;
if (!String.IsNullOrEmpty(searchString))
{
movies = movies.Where(s => s.Title.Contains(searchString));
}
@lionhylra
lionhylra / animation.css
Created November 2, 2013 03:29
CSS3 animation basic
/*basic*/
@keyframes myfirst
{
from {background: red;}
to {background: yellow;}
}
@-webkit-keyframes myfirst /* Safari and Chrome */
{
from {background: red;}
@lionhylra
lionhylra / 3column-all-dynamic.css
Created October 30, 2013 11:08
页面布局Layout 3 columns / left and right, content are all dynamic. 3 columns / left and right fixed, content is dynamic.
#left {
position: absolute;
left: 2%;
width: 22%;
top: 106px;
background-color: #ffffff;
}
#content {
position: absolute;
left: 25%;
@lionhylra
lionhylra / triangle.html
Created October 29, 2013 03:33
三角形箭头
<!DOCTYPE html>
<html>
<head>
<style>
html,body{text-align: center;}
body{
text-align: center;
margin: 0;
padding:0;
background-color: gray;
@lionhylra
lionhylra / html5.html
Created October 21, 2013 05:57
html5 template
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Free Web tutorials">
<meta name="keywords" content="HTML,CSS,XML,JavaScript">
<meta name="author" content="Ståle Refsnes">
<meta charset="UTF-8">
<style type="text/css">
div{
color:red;
@lionhylra
lionhylra / animation.css
Created October 5, 2013 14:47
元素出现动画
/* Effect 1: opacity */
.grid.effect-1 li.animate {
-webkit-animation: fadeIn 0.65s ease forwards;
-moz-animation: fadeIn 0.65s ease forwards;
animation: fadeIn 0.65s ease forwards;
}
@-webkit-keyframes fadeIn {
to { opacity: 1; }
}