Skip to content

Instantly share code, notes, and snippets.

View d1y's full-sized avatar
💤

小猫 d1y

💤
View GitHub Profile
@d1y
d1y / .bashrc
Created March 30, 2020 05:45 — forked from vsouza/.bashrc
Golang setup in Mac OSX with HomeBrew. Set `GOPATH` and `GOROOT` variables in zshell, fish or bash.
# Set variables in .bashrc file
# don't forget to change your path correctly!
export GOPATH=$HOME/golang
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
@d1y
d1y / workingDir.go
Created March 30, 2020 03:57 — forked from arxdsilva/working_directory.go
How to get the current working directory in golang
package main
// More info on Getwd()
// https://golang.org/src/os/getwd.go
//
import(
"os"
"fmt"
"log"
)
@d1y
d1y / gui.vbs
Created January 11, 2020 14:08
vbs-gui 示例
set ie=wscript.createobject("internetexplorer.application","event_") '创建ie对象'
ie.menubar=0 '取消菜单栏'
ie.addressbar=0 '取消地址栏'
ie.toolbar=0 '取消工具栏'
ie.statusbar=0 '取消状态栏'
ie.width=400 '宽400'
ie.height=400 '高400'
ie.resizable=0 '不允许用户改变窗口大小'
ie.navigate "about:blank" '打开空白页面'
ie.left=fix((ie.document.parentwindow.screen.availwidth-ie.width)/2) '水平居中'
@d1y
d1y / electron_full.js
Created January 5, 2020 17:20
electron 全屏
const electron = require('electron')
const { app } = electron
const { BrowserWindow } = electron
const path = require('path')
const url = require('url')
let mainWindow
let loadingScreen
@d1y
d1y / type.ts
Created January 5, 2020 07:36
typescript 限制输入值
import * as execa from 'execa'
type Desktop =
'kde' |
'gnome' |
// http://deepin.org
'dde' |
// https://elementary.io/
'pantheon' |
'win' |
@d1y
d1y / install_dbus.sh
Created January 1, 2020 02:57 — forked from berkin/install_dbus.sh
Install DBus under Mac OS X.
#!/usr/bin/env bash
# Created @ 13.01.2015 by Christian Mayer <http://fox21.at>
brew install dbus
cp /usr/local/Cellar/d-bus/1.8.8/org.freedesktop.dbus-session.plist ~/Library/LaunchAgents
# Load DBus
launchctl load -w ~/Library/LaunchAgents/org.freedesktop.dbus-session.plist
@d1y
d1y / gui.py
Created December 23, 2019 09:21
kivy demo
import os
import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
# to use buttons:
from kivy.uix.button import Button
kivy.require("1.10.1")
@d1y
d1y / react.jsx
Created December 22, 2019 11:35
css 自动隐藏滚动
const App = ()=> {
render() {
return (
<div style={{
width: '50vh',
overflow: 'scroll'
}}>
<div style={{ height: `120vh` }}></div>
</div>
)
@d1y
d1y / isURL.ts
Last active December 21, 2019 07:22
判断是否是url
// source: https://github.com/segmentio/is-url/blob/master/index.js
export const isUrl = (str: string): boolean => {
let protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/
let localhostDomainRE = /^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/
let nonLocalhostDomainRE = /^[^\s\.]+\.\S{2,}$/
if (typeof str !== 'string') return false
let match = str.match(protocolAndDomainRE)
if (!match) return false
let everythingAfterProtocol = match[1]
if (!everythingAfterProtocol) return false
@d1y
d1y / uniapp_tab.vue
Created December 19, 2019 03:08
uniapp中tab栏实例
<template>
<view class="tabs">
<scroll-view ref="tabbar1" id="tab-bar" class="tab-bar" :scroll="false" :scroll-x="true" :show-scrollbar="false"
:scroll-into-view="scrollInto">
<view style="flex-direction: column;">
<view style="flex-direction: row;">
<view class="uni-tab-item" v-for="(tab,index) in tabList" :key="tab.id" :id="tab.id" :ref="'tabitem'+index"
:data-id="index" :data-current="index" @click="ontabtap">
<text class="uni-tab-item-title" :class="tabIndex==index ? 'uni-tab-item-title-active' : ''">{{tab.name}}</text>
</view>