Skip to content

Instantly share code, notes, and snippets.

@rongyi
rongyi / gist:32796d775240cb7cc58e7c6e3e56f59d
Created September 2, 2016 07:51 — forked from nschum/gist:2626303
better "enum class" indent in Emacs
;; This hack fixes indentation for C++11's "enum class" in Emacs.
;; http://stackoverflow.com/questions/6497374/emacs-cc-mode-indentation-problem-with-c0x-enum-class/6550361#6550361
(defun inside-class-enum-p (pos)
"Checks if POS is within the braces of a C++ \"enum class\"."
(ignore-errors
(save-excursion
(goto-char pos)
(up-list -1)
(backward-sexp 1)
package main
import (
"log"
"time"
)
const (
// MaxWorker : max work count
MaxWorker = 100
@rongyi
rongyi / stardict2txt.py
Last active May 3, 2023 12:15
convert a stardict dictionary to txt
#!/usr/bin/python
# -*- coding: utf-8 -*-
import struct
import types
import gzip
class IfoFileException(Exception):
"""Exception while parsing the .ifo file.
Now version error in .ifo file is the only case raising this exception.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import shlex
import subprocess
import select
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''For running command line executables with a timeout'''
import subprocess
import threading
import shlex
import sys
import traceback
@rongyi
rongyi / main.go
Created November 10, 2017 08:25 — forked from mschoebel/main.go
Snippet: login/logout (Golang)
package main
import (
"fmt"
"github.com/gorilla/mux"
"github.com/gorilla/securecookie"
"net/http"
)
// cookie handling
package main
import (
"errors"
"fmt"
"io"
"log"
"net"
"strings"
"time"