Skip to content

Instantly share code, notes, and snippets.

View vamdt's full-sized avatar

vamdt vamdt

  • Foggy Beijing
View GitHub Profile
module CurrentUser
def signed_in?
!current_user.nil?
end
def sign_in(user)
self.current_user, session["user_id"] = user, user.id
end
def sign_out
'autologin.vbs
'自动打开某网站并填写表单
Dim ie
Set ie=CreateObject("InternetExplorer.Application") '创建IE应用程序对象
ie.Visible=True '设置IE窗体可见
ie.Navigate "http://www.xxt.cn" '导航到相应网站
While ie.busy Or ie.readystate <> 4 '等待网页加载完毕
Wend
'填写表单并点击登录
ie.document.frames(0).document.loginForm.userName.value="username"
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell]
[HKEY_CLASSES_ROOT\*\shell\openwemacs]
@="&Edit with Emacs"
[HKEY_CLASSES_ROOT\*\shell\openwemacs\command]
@="E:\\tools\\emacs\\bin\\runemacs.exe \"%1\""
[HKEY_CLASSES_ROOT\Directory\shell\openwemacs]
@="Edit &with Emacs"
[HKEY_CLASSES_ROOT\Directory\shell\openwemacs\command]
#!/usr/bin/env bash
JMETER_PATH=/path/to/jmeter
JMETER_PLAN_DIR=/path/to/jmx
set -xe
cd $(dirname $0)
pwd
for file in $(ls $JMETER_PLAN_DIR); do
@vamdt
vamdt / telnet_send_email.sh
Last active March 17, 2016 07:19
telnet send mail, for test
telnet mail.host 25
ehlo mail.host #握手
mail from:<test@mail.host> #发送方
rcpt to: <testing@target.mail.host> #收件方
data #正文
TO: testing@target.mail.host
FROM: test@mail.host
SUBJECT: telnet test
test,aha
#!/bin/bash
sudo apt-get install -y xfonts-utils fontconfig
cd `dirname $0`
mkdir msyh
cd msyh
curl -O https://coding.net/u/vamdt/p/fonts/git/raw/master/msyh.ttf
curl -O https://coding.net/u/vamdt/p/fonts/git/raw/master/msyhbd.ttf
cd ..
sudo cp -r ./msyh /usr/share/fonts/truetype/
defmodule Fib do
def fib(n) when n < 2 do
n
end
def fib(n) when n >= 2 do
fib(n-1) + fib(n-2)
end
@vamdt
vamdt / Vagrantfile
Created April 1, 2016 11:24
My common vagrant file
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "u14"
# config.vm.box_url = "http://mirrors.opencas.cn/ubuntu-vagrant/vagrant/trusty/20160323.1/trusty-server-cloudimg-amd64-vagrant-disk1.box"
config.vm.hostname = "vamdt"
@vamdt
vamdt / UTF8MB4ConnectionCustomizer.java
Created June 18, 2016 08:52
UTF8MB4ConnectionCustomizer
package com.vamdt.api.common
import com.mchange.v2.c3p0.AbstractConnectionCustomizer;
import java.sql.Connection;
import java.sql.Statement;
public class UTF8MB4ConnectionCustomizer extends AbstractConnectionCustomizer {
@Override
public void onAcquire(Connection c, String parentDataSourceIdentityToken) throws Exception {
@vamdt
vamdt / cmder_aliases
Last active July 30, 2016 05:17
cmder\config\aliases
e.=explorer .
gl=git log --oneline --all --graph --decorate $*
ls=ls --color --show-control-chars $*
pwd=cd
clear=cls
history=cat %CMDER_ROOT%\config\.history
unalias=alias /d $1
g=git $*
gs=git status $*