Skip to content

Instantly share code, notes, and snippets.

@HereOrCode
HereOrCode / index.js
Created January 31, 2023 09:30
translate file
const arguments = process.argv.slice(2);
const [filePath] = arguments;
main(filePath);
function main(filePath) {
const path = require('path');
const { root, dir, name, ext } = path.parse(filePath);
@HereOrCode
HereOrCode / readme.md
Created January 14, 2023 13:25
Completely uninstall Cocos Creator on Mac

Creator is a standard mac application which creates following folders and files:

~/Library/Preferences/com.cocos.creator.plist
~/Library/Application Support/CocosCreator/

#if you install v1.0.2
~/Library/Application Support/com.cocos.creator.ShipIt 

~/Library/Saved Application State/com.cocos.creator.savedState
~/.CocosCreator/
@HereOrCode
HereOrCode / Debian Motd.md
Last active February 27, 2023 13:04
Debian Motd

How to use

you need to set the following in /etc/ssh/sshd_config
vim /etc/ssh/sshd_config
PrintMotd yes

sudo apt-get update
sudo apt-get install figlet
@HereOrCode
HereOrCode / build.cjs
Last active December 13, 2022 11:41
Build Browser Extension Zip
// build.cjs
#!/usr/bin/env node
const fs = require('fs')
const path = require('path')
// eslint-disable-next-line
var archiver = require('archiver')
const extPackageJson = require('../src/manifest.json')
@HereOrCode
HereOrCode / debug.swift
Last active June 12, 2022 05:50
Printing file name, function name, line number in Swift.
func log(_ items: Any...,
withShortFileName: Bool = true,
file: String = #file,
function: String = #function,
line: Int = #line)
{
#if DEBUG
var fileName: String = ""
if withShortFileName {
@HereOrCode
HereOrCode / 1-protocols.swift
Last active May 11, 2022 09:19
UILabel and UITextView add line spacing
import UIKit
protocol LabelLineSpacingable where Self: UILabel {
func lineSpacing(_ value: CGFloat)
}
protocol TextViewLineSpacingable where Self: UITextView {
func lineSpacing(_ value: CGFloat,
content: String,
withColor color: UIColor?,
@HereOrCode
HereOrCode / lookaround_demo.js
Created April 20, 2022 08:43
零宽断言示例
// 正向零宽断言
// 肯定
const testStr1 = "iPhone3iPhone4iPhone5iPhoneNumber";
const reg1 = /iPhone(?=\d)/g;
const result1 = testStr1.replace(reg1, "MyPhone");
console.log(result1);
// MyPhone3MyPhone4MyPhone5iPhoneNumber
// 否定
const testStr2 = "iPhone3iPhone4iPhone5iPhoneNumber";
@HereOrCode
HereOrCode / Recognizing-Text-in-Images.md
Created April 13, 2022 06:38
Recognizing Text in Images

Add text-recognition features to your app using the Vision framework.

What you need to know

If not otherwise specified, Vision biases its results toward English. To alter its default behavior, provide an array of supported languages in the request’s recognitionLanguages property. The order in which you provide the languages dictates their relative importance. To recognize traditional and simplified Chinese, specify zh-Hant and zh-Hans as the first elements in the request’s recognitionLanguages property. English is the only other language that you can pair with Chinese.

Detect text from image

@HereOrCode
HereOrCode / make-your-own-blog-with-jekyll.md
Created April 13, 2022 06:33
Make your own blog with Jekyll

Building a website nowadays is not as hard or expensive as it was in the past. These days, you do not have to learn a crazy programming language to have your site up and running.

Install Jekyll

# First install rbenv
brew install rbenv

# Second install ruby 2.7
# Why, detaill see: https://talk.jekyllrb.com/t/error-no-implicit-conversion-of-hash-into-integer/5890
@HereOrCode
HereOrCode / CoreData.md
Created March 7, 2022 11:16
CoreData fetchRequest methods
//  here are the five different ways to set up a fetch request so you’re not caught by surprise:
// 1
let fetchRequest1 = NSFetchRequest<Venue>()
let entity = 
  NSEntityDescription.entity(forEntityName: "Venue",
                             in: managedContext)!
fetchRequest1.entity = entity

// 2