Skip to content

Instantly share code, notes, and snippets.

@13hoop
13hoop / .html
Created March 29, 2017 05:50
lazy loadImages
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
* {
margin: 0;
padding: 0;
}
@13hoop
13hoop / .html
Created March 30, 2017 11:23
auto-loading + lazy loading
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>news like sspai</title>
<style>
* {margin: 0;padding: 0}
html {
@13hoop
13hoop / .html
Last active April 10, 2017 23:56
sildeshow dome
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>轮播</title>
<link rel="stylesheet" href="style.css">
<style>
.banner {
margin: 0 auto;
width: 1000px;
@13hoop
13hoop / .html
Created April 9, 2017 16:37
slideDome_ fadeout/in
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>渐变轮播DEMO</title>
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<style>
ul,a,li {
margin:0;
padding: 0;
@13hoop
13hoop / .js
Last active May 22, 2017 09:13
export function currentUser() {
let user = AV.User.current()
if (user) {
// let r = parseUserFromAVUser(user)
// console.log( '-- user --: ' + r['objectId'])
return parseUserFromAVUser(user)
} else {
return undefined
}
}
@13hoop
13hoop / goroutines.swift
Created February 18, 2018 15:37 — forked from chriseidhof/goroutines.swift
goroutines.swift
import Foundation
protocol Channel: IteratorProtocol {
func send(_ value: Element?)
}
/// A blocking channel for sending values.
///
/// `send` and `receive` must run in separate separate execution contexts, otherwise you get a deadlock.
final class BlockingChannel<A>: Channel {
@13hoop
13hoop / protocol001.swift
Created December 6, 2018 01:51
协议 的实现效果是可以被延续的,本质上这是一种多态,而不是继承 ,故其不可以被重写,因为override的只能是 父类 的 methord
protocol SoundsFunc {
func voice () -> String
}
class Computer {
var name: String
init(name: String) {
self.name = name;
}
func calculat() {
//-------- swift 集合类型解读 - 1210
/*
--> Sequence 协议
这个协议是内置集合类型的核心,正是它让 针对元素序列的通用操作 成为可能
其规定了要实现跟返回一个 迭代器(Iterator)
protocol Sequence {
associatedtype Iterator: IteratorProtocol // 这里使用了 关联类型,作用就是协议中的 “范型” 或者 “alias”
func makeIterator() -> Iterator
}
--> IteratorProtocol 协议,一般只有在自定义序列类型的时候才使用
@13hoop
13hoop / SequenceDemo1212.swift
Last active December 12, 2018 01:54
补充1211的东西,除了Sequence本身之外,还要注意一下 代码组合 的方式,并非继承, 而是通过 protocol
//-------- swift 集合类型解读 之 Sequence - 1212
/*
另一个 完备的模拟使用,比如在 终端上的打印所有的输入过程
*/
// a 实现一个 Iterator
struct PrefixIterator: IteratorProtocol {
let str: String
var offset: String.Index
package net.jmecn.math;
/**
* 四元数
*
*
*/
public class Quaternion {
public float x, y, z, w;