Skip to content

Instantly share code, notes, and snippets.

View ngn999's full-sized avatar
💭
I may be slow to respond.

ngn999 ngn999

💭
I may be slow to respond.
View GitHub Profile
@ngn999
ngn999 / url-encode-ty.md
Last active August 29, 2015 14:09
url-encode-ty.md

在emacs里做url encoding. 最好你的环境是utf-8

(defun url-encode-ty ()
  (interactive)
  (let* ((origin-string (buffer-substring-no-properties (region-beginning) (region-end)))
         ;; (new-string (url-hexify-string origin-string))
         (new-string
 (with-temp-buffer
@staltz
staltz / introrx.md
Last active May 1, 2025 10:51
The introduction to Reactive Programming you've been missing
@stuntgoat
stuntgoat / indent_sql.el
Created February 10, 2014 08:55
An indentation heuristic for Emacs' sql-mode
(defun get-previous-indentation ()
"Get the column of the previous indented line"
(interactive)
(save-excursion
(progn
(move-beginning-of-line nil)
(skip-chars-backward "\n \t")
(back-to-indentation))
(current-column)))
@ngn999
ngn999 / maven.rb
Last active December 31, 2015 14:19
maven2
require 'formula'
class Maven <Formula
url 'http://apache.dataguru.cn/maven/maven-2/2.2.1/binaries/apache-maven-2.2.1-bin.tar.gz'
head 'http://www.apache.org/dist/maven/binaries/apache-maven-3.0-beta-2-bin.tar.gz'
homepage 'http://maven.apache.org/'
if ARGV.build_head?
md5 'a40881f56a3087828545f30921ff393f'
else
@ngn999
ngn999 / auctex.sh
Created October 2, 2013 10:32
install AUCTeX 11.87
./configure --with-emacs=/Applications/Emacs.app/Contents/MacOS/Emacs --with-lispdir=/Users/ngn999/.emacs.d/site-lisp/ --with-texmf-dir=/Users/ngn999/Library/texmf
@ngn999
ngn999 / getip.cpp
Last active December 22, 2015 19:29
get host ip
#include <sys/types.h>
#include <ifaddrs.h>
#include <netinet/in.h>
#include <arpa/inet.h>
bool getIP(string &ip)
{
struct ifaddrs *ifa_buf = NULL; /// /usr/include/ifaddrs.h
struct ifaddrs *ifa_iter = NULL;
void *tmp_addr_ptr = NULL;
@begriffs
begriffs / gist:6408415
Created September 2, 2013 01:12
Totally uninstall cabal, hsenv, and all Haskell packages on a mac
rm -fr ~/.ghc
rm -fr ~/Library/Haskell/*/lib
rm -fr ~/Library/Haskell/bin/*
rm -fr ~/Library/Haskell/repo-cache
rm -fr ~/.cabal/packages
# Then in your project
# rm -fr .hsenv
@ngn999
ngn999 / gist:6242366
Last active December 21, 2015 03:28
full-ack mode的设置

有时候,就算在用git,也希望 ack时,提示的Directory是buffer所在目录。

(defun ack-pwd ()
  "return the current buffer's directory"
  (file-name-directory buffer-file-name))
(global-set-key (kbd "<f8>") 'ack)

再将ack-pwd添加到ack-root-directory-functions的第一位:

@ngn999
ngn999 / tikz-uml-install.md
Last active December 9, 2016 21:36
how to install tikz-uml

tikz-uml都已经1.0b了, 快要正式发布了吧,哈哈. 但是安装手册还没写 :( . 在这儿补一个MacTeX下的手动安装步骤:

主要是那两个路径哈.

#!/bin/sh

mkdir -p ~/Library/texmf/tex/latex/tikz-uml/
mkdir -p ~/Library/texmf/doc/latex/tikz-uml/
@ngn999
ngn999 / zhoubao.md
Last active December 15, 2015 07:19
周报模板
定义一个 markdown-mode下的 snippet
<pre>
# -*- mode: snippet -*-
# name: zhoubao
# key: zhoubao
# binding: C-c C-n
# --
## ${1:#你的名字#}周报
`(concat "__" (yesterday-is 1) " ~ " (tommorow-is 5) "__")`