Skip to content

Instantly share code, notes, and snippets.

View FlintyLemming's full-sized avatar
🎯
Focusing

FlintyLemming FlintyLemming

🎯
Focusing
View GitHub Profile
@FlintyLemming
FlintyLemming / playground.swift
Last active September 13, 2021 09:31
16进制颜色转换 #iOS画面
import UIKit
extension UIColor {
convenience init(hexcode: String, alpha: CGFloat = 1.0) {
let string = hexcode.replacingOccurrences(of: "#", with: "")
let char = string.map { String($0) }
let r = CGFloat(Int(char[0]+char[1], radix:16) ?? 0) / 255.0
let g = CGFloat(Int(char[2]+char[3], radix:16) ?? 0) / 255.0
let b = CGFloat(Int(char[4]+char[5], radix:16) ?? 0) / 255.0
@FlintyLemming
FlintyLemming / run.sh
Created September 13, 2021 09:27
DDNS 计划任务 #NAS
curl -4 "https://ddns.flinty.moe:4CBbvDalUOfxvXr0@dyn.dns.he.net/nic/update?hostname=ddns.flinty.moe"
*/* 1 * * * curl -4 "https://ddns.flinty.moe:4CBbvDalUOfxvXr0@dyn.dns.he.net/nic/update?hostname=ddns.flinty.moe"
@FlintyLemming
FlintyLemming / playground.swift
Created September 13, 2021 09:24
调整 Label 的行距 #iOS画面
let paraph = NSMutableParagraphStyle()
paraph.lineSpacing = 6
let attributes = [NSAttributedString.Key.font:UIFont.systemFont(ofSize: 13),
NSAttributedString.Key.paragraphStyle: paraph]
caot901010View.errorMsgTextLabel.attributedText = NSAttributedString(string: errorParam.messageText, attributes: attributes)
@FlintyLemming
FlintyLemming / query.sql
Created September 13, 2021 09:24
在所有存储过程中搜索 #数据库
SELECT
NAME
FROM
sysobjects o,
syscomments s
WHERE
o.id = s.id
AND TEXT LIKE '%word%'
AND o.xtype = 'P'
@FlintyLemming
FlintyLemming / function.js
Created September 13, 2021 09:23
Js 时间转 SQL Server 时间 #前后端
dateToSQL: function (jsTime) {
var year = jsTime.getFullYear().toString();
var month = (jsTime.getMonth() + 1).toString();
if (month.length = 1) {
month = "0" + month
};
var date = jsTime.getDate().toString();
if (date.length = 1) {
date = "0" + date
};
@FlintyLemming
FlintyLemming / embed.html
Created September 13, 2021 09:22
Unsplash Banner #前端
<a style="background-color:black;color:white;text-decoration:none;padding:4px 6px;font-family:-apple-system, BlinkMacSystemFont, &quot;San Francisco&quot;, &quot;Helvetica Neue&quot;, Helvetica, Ubuntu, Roboto, Noto, &quot;Segoe UI&quot;, Arial, sans-serif;font-size:12px;font-weight:bold;line-height:1.2;display:inline-block;border-radius:3px" href="https://unsplash.com/@mylovefromjesus?utm_medium=referral&amp;utm_campaign=photographer-credit&amp;utm_content=creditBadge" target="_blank" rel="noopener noreferrer" title="Download free do whatever you want high-resolution photos from Jung Ho Park"><span style="display:inline-block;padding:2px 3px"><svg xmlns="http://www.w3.org/2000/svg" style="height:12px;width:auto;position:relative;vertical-align:middle;top:-2px;fill:white" viewBox="0 0 32 32"><title>unsplash-logo</title><path d="M10 9V0h12v9H10zm12 5h10v18H0V14h10v9h12v-9z"></path></svg></span><span style="display:inline-block;padding:2px 3px">Photo by on Unsplash</span></a>
@FlintyLemming
FlintyLemming / playground.cs
Last active September 13, 2021 09:20
C# DateTime 相关用法 #学习
// 字符串转 DateTime
string dateString = "20210601";
DateTime date = DateTime.ParseExact(dateString, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
// for 循环
List<string> dateList = new List<string>();
DateTime startTime = Convert.ToDateTime("2021-06-01");
DateTime endTime = Convert.ToDateTime("2021-07-01");
for (DateTime time = startTime; time <= endTime; time = time.AddDays(1))
{
@FlintyLemming
FlintyLemming / playground.cs
Created September 13, 2021 09:19
判断一个数组中是否存在某个数组值 #简单逻辑
int[] ia = {1,2,3};
int id = Array.IndexOf(ia,1); // 这里的1就是你要查找的值
if(id==-1)
// 不存在
else
// 存在
@FlintyLemming
FlintyLemming / function.js
Created September 13, 2021 09:19
将文本拷贝到剪贴板 #前端
function copyToClipboard(elementId) {
// Create an auxiliary hidden input
var aux = document.createElement("input");
// Get the text from the element passed into the input
aux.setAttribute("value", document.getElementById(elementId).innerHTML);
// Append the aux input to the body
document.body.appendChild(aux);
@FlintyLemming
FlintyLemming / playground.cs
Last active September 13, 2021 09:17
判断颜色深浅 #cs
public bool IsLightColor(Color color)
{
return (0.299 * color.R + 0.587 * color.G + 0.114 * color.B) / 255 > 0.5;
}