Skip to content

Instantly share code, notes, and snippets.

Avatar

rongyi rongyi

View GitHub Profile
View gist:ca94f01ebf1fbcb7023e69a2a429e6f3
package main
import (
"errors"
"fmt"
"io"
"log"
"net"
"strings"
"time"
@rongyi
rongyi / main.go
Created Nov 10, 2017 — forked from mschoebel/main.go
Snippet: login/logout (Golang)
View main.go
package main
import (
"fmt"
"github.com/gorilla/mux"
"github.com/gorilla/securecookie"
"net/http"
)
// cookie handling
View timed function
#!/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
View cmd function
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import shlex
import subprocess
import select
@rongyi
rongyi / stardict2txt.py
Last active May 17, 2020
convert a stardict dictionary to txt
View stardict2txt.py
#!/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.
View gist:436a54de5162dd5a765c381e88608120
package main
import (
"log"
"time"
)
const (
// MaxWorker : max work count
MaxWorker = 100
@rongyi
rongyi / gist:32796d775240cb7cc58e7c6e3e56f59d
Created Sep 2, 2016 — forked from nschum/gist:2626303
better "enum class" indent in Emacs
View gist:32796d775240cb7cc58e7c6e3e56f59d
;; 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)
@rongyi
rongyi / nodejs-repl-eval.el
Created Aug 26, 2016 — forked from emallson/nodejs-repl-eval.el
Evaluation functions for the `nodejs-repl' Emacs package.
View nodejs-repl-eval.el
;;; nodejs-repl-eval.el --- Summary
;;; Commentary:
;;;
;;; Evaluation functions for the `nodejs-repl' package. Written on a stormy
;;; night between days of node hacking.
;;;
;;; Code:
(require 'js2-mode)
(require 'nodejs-repl)
@rongyi
rongyi / bottom_gnome_termial_tab
Created May 17, 2015
show gnome-terminal tab at bottom
View bottom_gnome_termial_tab
// add the code below to terminal_window_init function at line about 2034
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (priv->notebook), GTK_POS_BOTTOM);
@rongyi
rongyi / gist:3fbbd112e7798039cd8c
Created Mar 20, 2015
two ways to get cpu cores
View gist:3fbbd112e7798039cd8c
#include <thread>
#include <iostream>
#include <unistd.h>
using std::cout;
using std::endl;
int main()
{
cout << std::thread::hardware_concurrency() << endl;
cout << sysconf(_SC_NPROCESSORS_ONLN) << endl;
You can’t perform that action at this time.