Skip to content

Instantly share code, notes, and snippets.

View sfengyuan's full-sized avatar
🎯
Focusing

sunfy sfengyuan

🎯
Focusing
  • China
View GitHub Profile
@sfengyuan
sfengyuan / KeyboardInterrupted.py
Created October 12, 2022 14:25
Catch KeyboardInterrupt
import signal
import sys
user_stop = False
def signal_handler(sig, frm):
global user_stop
user_stop = True
signal.signal(signal.SIGINT, signal_handler)
# signal.pause()
@sfengyuan
sfengyuan / Chnese_punctuation_list.txt
Created September 26, 2022 17:14
Chinese punctuation list
'。?!,、;:“”‘’( ) [ ] { }——……《 》〈 〉.·— ____/'
@sfengyuan
sfengyuan / clean-bad-unicode.js
Last active August 7, 2022 15:35
clean bad Unicode
/*
date: 2022/8/7 23:34
*/
export default function (str) {
const garbageSpaces = [
'\u00A0', // No-Break Space
'\u3000', // ideographic space
'\u2000', // En quad space
'\u2001', // Em quad space
'\u2002', // En space
@sfengyuan
sfengyuan / main.js
Last active September 18, 2021 15:30
Install chrome extension devtools to Electron projects
import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer';
...
app.on('ready', () => {
const mainWindow = createWindow()
if (process.env.mode === 'development') {
installExtension(VUEJS_DEVTOOLS)
.then((name) => console.log('installed ', name))
.catch((err) => console.log('An error occurred: ', err));
const ses = mainWindow.webContents.session
@sfengyuan
sfengyuan / reset.css
Last active January 30, 2021 16:28
CSS reset
/* css reset */
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font: inherit;
font-size: 100%;
vertical-align: baseline;
}
{"lastUpload":"2020-03-09T14:58:32.697Z","extensionVersion":"v3.4.3"}
# frozen_string_literal: true
# https://pintia.cn/problem-sets/17/problems/260
# input example: 19 *
# output example:
# *****
# ***
# *
# ***
# *****
@sfengyuan
sfengyuan / keybinding.json.txt
Last active January 28, 2019 12:23
vs code key bindings
// Place your key bindings in this file to overwrite the defaults
[
// -------- edit
{
"key": "ctrl+shift+up",
"command": "editor.action.moveLinesUpAction",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+shift+down",
@sfengyuan
sfengyuan / .babelrc
Last active June 15, 2018 06:21
js config
{
"presets": [
[
"env",
{"modules": false}
],
["stage-3"]
],
"plugins": ["transform-runtime"],
"env": {
@sfengyuan
sfengyuan / insertText.js
Created December 19, 2017 08:30
Insert text to textarea
/**
* Insert <text> to <areaId>, then [selectedText] will be selected.
*
* @export module.insertAtCaret
* @param {string} areaId - ID of textarea
* @param {string} text - text to be inserted
* @param {string} [selectedText=undefined] - a sub string of param <text>,
* will be selected after insertion, and also be replaced by the current selected text in textarea
*/
export function insertAtCaret (areaId, text, selectedText = undefined) {