Skip to content

Instantly share code, notes, and snippets.

View doitian's full-sized avatar
🎯
Focusing

ian doitian

🎯
Focusing
View GitHub Profile
@doitian
doitian / mongoid_ext.rb
Created June 17, 2014 04:51
Use foreign_key in inverse_of relation
require 'mongoid/relations/metadata'
class Mongoid::Relations::Metadata
def determine_inverse_foreign_key
if has_key?(:inverse_of)
if inverse_class_name? && inverse_of
inverse_class_name.constantize.relations[inverse_of.to_s].foreign_key
else
inverse_of ? "#{inverse_of.to_s.singularize}#{relation.foreign_key_suffix}" : nil
end
@doitian
doitian / omnifocus-2-evernote.scpt
Last active August 29, 2015 14:06
Send OmniFocus 2 Pro tasks to Evernote (create Todos notebook first)
on escapeHtml(theText)
do shell script "ruby -rcgi -e 'ARGV.each {|a| puts CGI.escape_html(%Q<#{a}>)}' -- " & quoted form of theText
end escapeHtml
set theLines to {}
tell application "OmniFocus"
-- If no document is open, open one
tell default document
if number of document window is 0 then
@doitian
doitian / docker.yml
Created October 10, 2014 10:53
Tmuxinator config for boot2docker
# ~/.tmuxinator/docker.yml
name: docker
root: ~/testbed/docker
windows:
- shell: |
unset DYLD_LIBRARY_PATH; \
unset LD_LIBRARY_PATH; \
tmux set-environment -u DYLD_LIBRARY_PATH; \
@doitian
doitian / -
Created October 14, 2014 06:32
<?php
header('Content-Type: text/calendar; charset=utf-8');
$url = 'https://tower.im/calendars/ical/' . htmlspecialchars($_GET['id']) . '.ics';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
$lastkey = NULL;
$event = NULL;
@doitian
doitian / tower-ical.php
Last active August 29, 2015 14:07
Tower 日历加上时间信息
<?php
header('Content-Type: text/calendar; charset=utf-8');
$url = 'https://tower.im/calendars/ical/' . htmlspecialchars($_GET['id']) . '.ics';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$output = curl_exec($ch);
$lastkey = NULL;
$event = NULL;
@doitian
doitian / iy-anything.el
Created April 18, 2009 13:35
merge proel into anything
;;{{{ Anything
(require 'anything-config)
(setq anything-input-idle-delay 0.2)
(setq anything-idle-delay 0.7)
(setq anything-quick-update t)
(setq anything-c-locate-db-file (expand-file-name "~/.localdb"))
(setq anything-c-locate-options `("locate" "-d" ,anything-c-locate-db-file "-i" "-r"))
(setq anything-candidate-separator
@doitian
doitian / ClockTimer.h
Created May 6, 2009 01:28
ClockTimer.h
/**
* @file utility/ClockTimer.h
*
* Created <2009-03-02 16:37:39 Ian Yang>
* Last Updated <2009-03-02 16:37:45 Ian Yang>
*/
#ifndef UTILITY_CLOCK_TIMER_H
#define UTILITY_CLOCK_TIMER_H
#include <boost/date_time/posix_time/posix_time.hpp>
@doitian
doitian / send_daily_report.sh
Created May 20, 2009 01:15
send daily report
#!/bin/sh
####################
# Configs
#####
VAR_NAME='First Last'
VAR_ADDR='xxx@mail.com'
# cc to me ? yes/no
VAR_CC_ME='yes'
(defvar iy/calendar-copy-date-format-history '("%Y-%m-%d"))
(defun iy/calendar-copy-date (arg)
"Copy date under the cursor. Read format from minibuffer if ARG,
use recently used format if no ARG. See the function `format-time-string'
for the document of time format string"
(interactive "P")
(let ((date (calendar-cursor-to-date t))
(format (if arg
(completing-read
"Date Format:"
// ==UserScript==
// @name Mirrorrr It
// @namespace mirrorrr.appspot.com
// @include http://*.blogspot.com/*
// @include https://*.blogspot.com/*
// @exclude http://mirrorrr.appspot.com/*
// @exclude https://mirrorrr.appspot.com/*
// ==/UserScript==
location.href = location.href.replace(/^https?:\/\//, 'https://mirrorrr.appspot.com/');