Skip to content

Instantly share code, notes, and snippets.

View 4074's full-sized avatar
💭
I may be slow to respond.

Marco 4074

💭
I may be slow to respond.
  • Invoker Lab
  • GuangZhou, China
View GitHub Profile
@4074
4074 / test.md
Created December 23, 2022 10:18

aaa

@4074
4074 / cloc.sh
Created October 27, 2022 19:35
Count lines of code
git ls-files | grep -E '.*\.(ts|tsx|js|html|css|scss|less)$' | xargs cat | wc -l
@4074
4074 / 📊 Weekly development breakdown
Last active October 29, 2020 00:39
Weekly development breakdown
TypeScript 7 hrs 5 mins █████████████████▌░░░ 83.6%
SCSS 36 mins █▌░░░░░░░░░░░░░░░░░░░ 7.2%
JavaScript 27 mins █░░░░░░░░░░░░░░░░░░░░ 5.3%
JSON 16 mins ▋░░░░░░░░░░░░░░░░░░░░ 3.2%
Markdown 2 mins ░░░░░░░░░░░░░░░░░░░░░ 0.6%
set name=app-name
set imagePort=8080
set exportPort=8080
docker build -t %name% .
REM Get exits container Id.
for /F %%i in ('docker ps -a -q --filter="name=%name%"') do ( set containerId=%%i)
docker stop %containerId%
@4074
4074 / analytics.js
Created August 27, 2019 05:06 — forked from zmmbreeze/analytics.js
GA的源码 analytics.js
(function() {
/**
* 记录方法使用情况的类
* @param {Array.<boolean>} umMap 初始的使用情况
*/
var UsageManager = function(umMap) {
this.umMap = umMap || [];
};
/**
* 记录新的使用情况
@4074
4074 / md5.js
Created January 7, 2019 01:34
md5.js
require('crypto').createHash('md5').update('123456').digest("hex")
@4074
4074 / gist:08f0d274861c3f037e0feea0bf713b50
Created January 13, 2017 07:03
react-redux-universal-hot-example custom modification
origin repo [https://github.com/erikras/react-redux-universal-hot-example](https://github.com/erikras/react-redux-universal-hot-example)
1. package.json
- remove dependencies about bootstrap
- remove dependencies about eslint
- remove dependencies about karma
- remove scripts about eslint, test
2. remove `karma.config.js`
2. dev.config.js
- remove `eslint-loader`

Today Widget 开发指引

开发环境:

  • Xcode 8.1
  • Swift 2.3
  • iOS 10.1

添加控件

  1. 添加 target:project -> targets -> add target -> App Extensions -> Today Extension
  2. 不使用 storyboard 的话,修改 info.plist
    • 删除 MainInterface.storyboard
@4074
4074 / TouchIDAuthentication.swift
Created September 23, 2016 02:41
Authentication with TouchID
import LocalAuthentication
let context = LAContext()
// Custom falllback button text
context.localizedFallbackTitle = "Password Enter"
// Determine TouchID available or not
if context.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error: nil) {
// Trigger TouchID Authentication
func createImageFromImageAndText(image: UIImage, text: String, font: UIFont, color: UIColor, spacing: CGFloat = 5) -> UIImage {
let string = NSString(string: text)
let textSize = string.sizeWithAttributes([NSFontAttributeName: font])
let size = CGSize(
width: textSize.width + spacing + image.size.width,
height: max(textSize.height, image.size.height)
)
UIGraphicsBeginImageContextWithOptions(size, false, 0)
let context = UIGraphicsGetCurrentContext()