Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View hyrious's full-sized avatar
💤
lazy

hyrious hyrious

💤
lazy
View GitHub Profile
@hyrious
hyrious / AfterCleanInstall.reg
Created April 15, 2017 14:48
Clear Registry, Add Sublime Text Context Menu
Windows Registry Editor Version 5.00
; Sublime Text
[HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text]
"Icon"="D:\\Local\\Sublime Text 3\\sublime_text.exe, 0"
[HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\command]
@="D:\\Local\\Sublime Text 3\\sublime_text.exe \"%1\""
; BaiduYun
[-HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\YunShellExt]
@hyrious
hyrious / cache.rb
Last active April 20, 2017 13:04
Easy API Cache
@api_cache = {}
def api_cache id:, threshold:, due:, &blk
@api_cache[id] ||= { cache: {} }
due_time = case due
when Numeric then Time.now + due
when Time then due
end
proc do |*args| # args is the key
@api_cache[id][:cache].delete_if { |_key, item| item[:due] < Time.now }
unless @api_cache[id][:cache][args]
@hyrious
hyrious / build.cmd
Last active April 22, 2017 00:24
Stylus on Windows: Compile *.css and *.min.css
@set src=1px
@echo off
call stylus -o dist %src%.styl
copy /v /y %src%.styl %src%.min.styl >nul
call stylus -c -o dist %src%.min.styl
del %src%.min.styl
@hyrious
hyrious / setup_rubygem.cmd
Last active April 22, 2017 00:30
CMD Script - Setup RubyGem
REM https://github.com/ruby-china/rubygems-mirror/wiki
REM Download cacert.pem here -> http://curl.haxx.se/ca/cacert.pem
setx SSL_CERT_FILE D:\Local\Ruby\lib\cacert.pem
call gem update --system
call gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
call gem install bundler
call bundle config mirror.https://rubygems.org https://gems.ruby-china.org
@hyrious
hyrious / prmd.cmd
Last active April 23, 2017 05:47
preview *.md using marked.js, highlight.js, MathJax.js, and erb
@echo off
if "%~1" == "" goto no_param
:main
call erb filename="%~1" %~dp0\prmd.tt > "%TEMP%\%~n1.html"
start "" "%TEMP%\%~n1.html"
goto :EOF
:no_param
echo Please specify a *.md file.
@hyrious
hyrious / MeasureNet.ini
Created April 25, 2017 04:12
[Rainmeter] Just Another Disturbing Thing on my Desktop
[Rainmeter]
Update=1000
[Metadata]
Name=MeasureNetInOut
Author=hyrious
Information=Just Another Disturbing Thing on my Desktop
License=WTFPLv2
Version=0.01
[Variables]
Interface=Best
@hyrious
hyrious / phpctl.cmd
Last active April 27, 2017 11:13
php on Windows
@echo off
setlocal EnableDelayedExpansion
if "%*" == "" (
echo Nothing todoy. ^(^^_^^^)
) else if "%*" == "list" (
call tasklist /fi "ImageName eq php-cgi.exe"
) else if "%*" == "stop" (
<nul set /p=Killing php-cgi.exe..^
call taskkill /f /im php-cgi.exe >nul 2>&1
@hyrious
hyrious / times.cmd
Last active April 30, 2017 12:15
repeat n times do ...
@echo off
setlocal EnableDelayedExpansion
set T=%1
rem Preprocessing params
set cmdline=
shift
:pp_loop
if "%1" == "" goto :pp_next
set cmdline=%cmdline% %~1
@hyrious
hyrious / desktop.cmd
Last active May 6, 2017 04:29
Create desktop.ini ...
@echo off
setlocal
if exist desktop.ini ( attrib +A -S -H desktop.ini )
>desktop.ini echo [.ShellClassInfo]
>>desktop.ini echo LocalizedResourceName=%~1
>>desktop.ini echo IconResource=
>>desktop.ini echo InfoTip=%~2
class Befunge
attr_accessor :x, :y, :stack, :d, :ans, :code
def initialize code
@x, @y, @stack, @d, @ans, @code = 0, 0, [], '>', '', code.lines.map(&:chomp)
end
def c
@code[y][x]
end
def m
case d