Skip to content

Instantly share code, notes, and snippets.

Avatar

rongyi rongyi

View GitHub Profile
@rongyi
rongyi / backtrace example
Created Mar 31, 2014
how to print backtrace in C, remember add gcc option '-rdynamic' when compile
View backtrace example
#include <execinfo.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#define BACKTRACE_SIZE 256
static void
View print environ using C
#include <unistd.h>
#include <stdio.h>
extern char **environ;
int main()
{
int i = 0;
while(environ[i]) {
printf("%s\n", environ[i++]);
View .tern-project
{
"libs": [
"browser",
"underscore",
"jquery"
],
"plugins": {
"node": {}
}
}
@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;
@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 / simple_snake_demo.c
Created Dec 16, 2012
a short snake demo for a douban friend
View simple_snake_demo.c
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
static void direction_up(void);
static void direction_down(void);
static void direction_left(void);
static void direction_right(void);
static void direction_up(void)
@rongyi
rongyi / check iface
Created Jul 26, 2013
check network interface status
View check iface
#include <stdio.h>
#include <stdlib.h>
#include <linux/sockios.h>
#include <linux/ethtool.h>
#include <stdint.h>
#include <sys/types.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <linux/if.h>
@rongyi
rongyi / gist:6101910
Created Jul 29, 2013
get iface index
View gist:6101910
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/ethtool.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <linux/if.h>
#include <string.h>
#include <errno.h>
View gist:6102334
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/ethtool.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <linux/if.h>
#include <string.h>
#include <errno.h>
@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)
You can’t perform that action at this time.