Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rongyi
rongyi / simple_snake_demo.c
Created December 16, 2012 05:45
a short snake demo for a douban friend
#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 July 26, 2013 06:53
check network interface status
#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 July 29, 2013 02:59
get iface index
#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 / gist:6102334
Created July 29, 2013 05:42
get arp type
#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 / backtrace example
Created March 31, 2014 06:06
how to print backtrace in C, remember add gcc option '-rdynamic' when compile
#include <execinfo.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#define BACKTRACE_SIZE 256
static void
@rongyi
rongyi / print environ using C
Created April 23, 2014 09:09
print environ
#include <unistd.h>
#include <stdio.h>
extern char **environ;
int main()
{
int i = 0;
while(environ[i]) {
printf("%s\n", environ[i++]);
{
"libs": [
"browser",
"underscore",
"jquery"
],
"plugins": {
"node": {}
}
}
@rongyi
rongyi / gist:3fbbd112e7798039cd8c
Created March 20, 2015 08:49
two ways to get cpu cores
#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 05:27
show gnome-terminal tab at bottom
// 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 / nodejs-repl-eval.el
Created August 26, 2016 04:41 — forked from emallson/nodejs-repl-eval.el
Evaluation functions for the `nodejs-repl' Emacs package.
;;; 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)