Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Leon Shi superRaytin

🎯
Focusing
Block or report user

Report or block superRaytin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@superRaytin
superRaytin / electronMainIpcHelper.js
Created Jul 12, 2019
IPC helper for the main process of Electron
View electronMainIpcHelper.js
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 Jul 12, 2019
IPC helper for the renderer process of Electron
View electronRendererIpcHelper.js
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 Jul 4, 2019
A Prolog program to find people's lover
View findLover.pl
% 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.
View openChrome.applescript
-- 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 Nov 9, 2015
Initial package.json for React project.
View react-project-package.json
{
"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"
You can’t perform that action at this time.