Skip to content

Instantly share code, notes, and snippets.

View superRaytin's full-sized avatar

Leon Shi superRaytin

View GitHub Profile
@superRaytin
superRaytin / simpleToast.js
Created December 19, 2022 06:56
Simple Toast
const wrapStyle = `display: flex; justify-content: center; padding: 2rem 1.5rem; font-size: 1.4rem; color: #fff; background: rgba(0, 0, 0, 0.7); border-radius: 1.6rem; position: fixed; top: 50%; left: 50%; z-index: var(--dxm-toast-z-index); transform: translate3d(-50%, -50%, 1px);`;
const contentStyle = `display: flex; flex-direction: column; align-items: center; text-align: center;`;
const simpleToast = {
info: (content, duration = 2) => {
if (window.simpleToastTimer) {
clearTimeout(window.simpleToastTimer);
}
const toastEleId = '__simple_toast';
@superRaytin
superRaytin / cloudSettings
Last active April 14, 2021 09:43
personal settings for vscode
{"lastUpload":"2021-04-14T09:43:11.829Z","extensionVersion":"v3.4.3"}
@superRaytin
superRaytin / replaceContent.sh
Created December 6, 2019 08:11
replace specified content with some else string
#!/bin/sh
# replace name of html entry with fixed "index.html" in cmd file
targetCmdPath="${PWD}/{{ slug }}.sketchplugin/Contents/Sketch/my-command.js"
sed -i -r -E "s/(_webpack_resources\/).+(\.html)/\1index\2/" "$targetCmdPath"
# copy index.html to _webpack_resources
htmlPath="${PWD}/src/dist/index.html"
webpackResourcePath="${PWD}/{{ slug }}.sketchplugin/Contents/Resources/_webpack_resources"
/bin/cp -f "$htmlPath" "$webpackResourcePath"
@superRaytin
superRaytin / electronMainIpcHelper.js
Created July 12, 2019 03:00
IPC helper for the main process of Electron
import { ipcMain as ipc, BrowserWindow } from 'electron'
// 向渲染进程发送消息
export function send(channel, ...args) {
const currentWindow = BrowserWindow.getFocusedWindow()
return new Promise((resolve) => {
if (currentWindow) {
currentWindow.webContents.send(channel, ...args)
ipc.once(`${channel}`, (event, count, ...res) => {
resolve({ event, payload: res.length === 1 ? res[0] : res })
@superRaytin
superRaytin / electronRendererIpcHelper.js
Created July 12, 2019 02:58
IPC helper for the renderer process of Electron
import { ipcRenderer as ipc } from 'electron'
let ipcCount = 0
// 向主进程发送消息,并等待主进程的回复
export function send(channel, ...args) {
const localCount = ipcCount += 1
return new Promise((resolve) => {
ipc.once(`${channel}-${ipcCount}`, (event, ...res) => {
resolve({ event, payload: res.length === 1 ? res[0] : res })
@superRaytin
superRaytin / findLover.pl
Last active July 4, 2019 19:33
A Prolog program to find people's lover
% A Prolog program to find people's lover
% --------------------------------
man(george). man(jack). man(tony).
woman(lucy). woman(fiona). woman(peggy).
% % A man can only fall in love with one woman
% % Women are already in different rooms and they like to eat different foods
uniq(A, B, C) :- woman(A), woman(B), woman(C), \+A=B, \+A=C, \+B=C.
-- Copyright (c) 2015-present, Facebook, Inc.
-- All rights reserved.
--
-- This source code is licensed under the BSD-style license found in the
-- LICENSE file in the root directory of this source tree. An additional grant
-- of patent rights can be found in the PATENTS file in the same directory.
on run argv
set theURL to item 1 of argv
tell application "Chrome"
@superRaytin
superRaytin / react-project-package.json
Last active November 9, 2015 12:34
Initial package.json for React project.
{
"name": "React-awesome",
"version": "0.0.1",
"description": "react awesome project",
"author": "superRaytin@163.com",
"contributors": [],
"repository": "http://github.com/superRaytin/React-awesome",
"dependencies": {
"react": "^0.13.3",
"keymirror": "^0.1.1"