Skip to content

Instantly share code, notes, and snippets.

View liudangyi's full-sized avatar
🤖
Roboting

Dangyi Liu liudangyi

🤖
Roboting
View GitHub Profile
@liudangyi
liudangyi / brew-launch
Last active August 29, 2015 14:03
Homebrew launchctl script
#!/usr/bin/env ruby
DEFAULT = %w(mongodb memcached)
RUNNING = `launchctl list | grep homebrew.mxcl`.split.select{|s|s.sub!(/\Ahomebrew\.mxcl\./, "")}
BREW_PATH = `brew --prefix`.chomp
AVAILABLE = Dir.new("#{BREW_PATH}/opt").select{|name|File.exists?("#{BREW_PATH}/opt/#{name}/homebrew.mxcl.#{name}.plist")}
def start(app)
if AVAILABLE.include? app
@liudangyi
liudangyi / TaskPaper2Evernote.applescript
Last active December 9, 2015 20:38
Create a new note using a text file (e.g. Todo.taskpaper under document folder) in Evernote, and sync with it every 20 min.
-- e.g. replaceString("Hello hello", "hello", "Bye") --> "Hello Bye"
on replaceString(theText, oldString, newString)
-- ljr (http://applescript.bratis-lover.net/library/string/)
local ASTID, theText, oldString, newString, lst
set ASTID to AppleScript's text item delimiters
try
considering case
set AppleScript's text item delimiters to oldString
set lst to every text item of theText
@liudangyi
liudangyi / gist:4324850
Created December 18, 2012 03:53
Get the IPv4 address of eth0 in shell
ifconfig eth0 | grep inet | grep -v inet6 | awk '{print $2}' | sed 's/.*://g'
@liudangyi
liudangyi / npm_ignore_ssl.sh
Created December 18, 2012 19:30
Ignore SSL Errors with NPM Node Package Manager
npm config set strict-ssl false
@liudangyi
liudangyi / vimrc
Last active March 5, 2017 19:51
My vimrc file
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'flazz/vim-colorschemes'
" Plugin 'jiangmiao/auto-pairs'
Plugin 'ctrlpvim/ctrlp.vim'
@liudangyi
liudangyi / dns_forward.py
Created April 14, 2018 00:22
Fix FortiGate DDNS Update NOTZONE problem
#!/usr/bin/env python3
from __future__ import print_function
from netfilterqueue import NetfilterQueue
from scapy.layers.dns import *
def modify(pkt):
ip = IP(pkt.get_payload())
! CapsLock to Control_L
clear lock
clear control
keycode 66 = Control_L
add control = Control_L Control_R
! left Alt & right Alt
keycode 64 = Meta_L
keycode 108 = Meta_R