Skip to content

Instantly share code, notes, and snippets.

View ShiningRay's full-sized avatar
💭
.eth -> .gpt

代码之力 ShiningRay

💭
.eth -> .gpt
View GitHub Profile
@ShiningRay
ShiningRay / .vimrc
Created March 11, 2013 03:10 — forked from anonymous/.vimrc
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
@ShiningRay
ShiningRay / gist:5290061
Created April 2, 2013 05:05
Use alt+wasd for curor moving on HHKB
<?xml version="1.0"?>
<root>
<devicevendordef>
<vendorname>TOPRE</vendorname>
<vendorid>0x0853</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>HHKB_PRO2</productname>
<productid>0x0100</productid>
@ShiningRay
ShiningRay / gist:5347594
Created April 9, 2013 17:24
Tiny forth (copy from else where)
class ForthInterpreter
attr_reader :stack, :dict
def initialize
@stack = []
@dict = {
:"." => Proc.new { print @stack.pop },
:".s" => Proc.new { puts @stack },
:cr => Proc.new { puts },
#!/usr/bin/env ruby
# the stack
$stack = []
def pop() $stack.pop || ufe end
def push(f) $stack<<f end
# poor man's Exception class
def ufe() raise("Stack underflow") end
# lambda constructor helpers
@ShiningRay
ShiningRay / disable.bas
Created February 25, 2016 09:44
Disable System Hotkey in Windows
#include "windows.bi"
Dim shared as HANDLE hook
function LowLevelKeyboardProc(byval nCode as long, byval wParam as WPARAM, byval lParam as LPARAM) as LRESULT
if nCode < 0 then
return CallNextHookEx(NULL, nCode, wParam, lParam)
end if
var s = cptr(LPKBDLLHOOKSTRUCT, lParam)
@ShiningRay
ShiningRay / 0_reuse_code.js
Created April 23, 2016 03:43
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ShiningRay
ShiningRay / test.rb
Created January 11, 2017 07:17
def ... end syntax vs define_method
class Test
def initialize
@a = 100
end
a = 100
def test1
a
end
@ShiningRay
ShiningRay / init.lua
Created April 7, 2017 09:16
automaticly focus the frontmost window when mouse changed to another screen
-- hs.logger.setGlobalLogLevel('debug')
local logger = hs.logger.new('focus')
hs.timer.doEvery(3, function()
local current = hs.mouse.getCurrentScreen()
-- hs.rawprint(current)
if current and current ~= hs.screen.mainScreen() then
local windows = hs.window.orderedWindows()
for _, l in ipairs(windows) do
if l:screen() == current and l:isStandard() and l:isVisible() then
### Keybase proof
I hereby claim:
* I am shiningray on github.
* I am shiningray (https://keybase.io/shiningray) on keybase.
* I have a public key ASB2sATNtdPsmMsCGDEJqYzhArE4fU8xht1gDMk3dWtJego
To claim this, I am signing this object:
@ShiningRay
ShiningRay / device.js
Created December 9, 2018 03:45
nanomsg req/rep load balancer example
var nano = require('nanomsg');
const async = require('async')
function createWorker(index) {
var worker = nano.socket('rep')
const endpoint = 'inproc://worker' + index;
worker.bind(endpoint);
worker.index = index;
worker.on('data', (buf) => {
var a = buf.toString();