Skip to content

Instantly share code, notes, and snippets.

@c02y
c02y / 0_reuse_code.js
Created September 29, 2015 02:41
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
>> sudo python3.3 setup.py install --optimize=1 [11:10:49](master|✔)
running install
running build
running build_py
running build_scripts
running install_lib
creating /usr/local/lib/python3.3/site-packages/ranger
copying build/lib/ranger/__init__.py -> /usr/local/lib/python3.3/site-packages/ranger
creating /usr/local/lib/python3.3/site-packages/ranger/config
copying build/lib/ranger/config/rc.conf -> /usr/local/lib/python3.3/site-packages/ranger/config
@c02y
c02y / gist:c7124fbd2ec102bcb9c76cb677e1b08b
Created March 26, 2018 08:37
set Emacs frame size according to resolution dynamically
(defun set-frame-size-according-to-resolution ()
(interactive)
(if window-system
(progn
(setq width-chars (/ (/ (x-display-pixel-width) (frame-char-width)) 2))
(setq height-lines (- (/ (x-display-pixel-height) (frame-char-height)) 3))
(setq default-frame-alist
`((top . 0) (left . 0)
(width . ,width-chars)
(height . ,height-lines)))
@c02y
c02y / bit
Last active May 10, 2018 08:01
bit operations of two numbers
#!/bin/bash
usage()
{
echo "bit operations of two numbers"
echo
echo "Usage: $(basename $0) NUM1 OPS NUM2 [d]"
echo "OPS: a(&, and), o(|, or), x(^, xor), l(<<, left), r(>>, right)"
echo "d means result will be dec, default is hex"
exit
@c02y
c02y / gfwlist.txt
Created May 12, 2018 10:50
gfwlist.txt
https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt
@c02y
c02y / README
Created June 30, 2018 13:21
emacs+cscope/gtags/etags
find the files containing the obsolete:
such as assoc:
find ~/.emacs.d/ -name "*.el" -exec grep -H "(require 'assoc)" {} \;
# for the differences of cscope ctags, etags, global(gtags, ggtags..)...:
# https://github.com/OpenGrok/OpenGrok/wiki/Comparison-with-Similar-Tools
# etags for small c;cscope for big project
@c02y
c02y / type.c
Created July 3, 2018 04:19
type.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h> /* for SIG_ERR */
#include <stddef.h> /* for offsetof */
#include <termios.h>
#include <math.h>
@c02y
c02y / regexp.png
Created July 6, 2018 07:20
regexp table
Source:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
png:
https://screenshotscdn.firefoxusercontent.com/images/5933b2a1-b14e-4bf9-9790-2259060f006f.png
Other source:
https://regexr.com/
@c02y
c02y / align.el
Last active July 14, 2018 04:11
align comments and macro pf multiple lines
;; align-regexp with space instead tab
(defadvice align-regexp (around align-regexp-with-spaces activate)
(let ((indent-tabs-mode nil))
ad-do-it))
(defalias 'ar #'align-regexp)
(defadvice align (around align-with-spaces activate)
(let ((indent-tabs-mode nil))
ad-do-it))
(defun align-c-comments (beginning end)
"Align instances of // or /* */ within marked region."
@c02y
c02y / config.fish
Created July 19, 2018 10:52
git command for multiple files copy/paste
function gitco -d 'git checkout -- for multiple files at once'
# when you copy/paste using mouse, the strings you pasted are not seprated by space ACTUALLY, using ','
set -l files (echo $argv | tr ',' '\n')
for i in $files
echo 'git checkout -- for file' $i
git checkout -- $i
end
end
function gita -d 'git add for multiple files at once'
set -l files (echo $argv | tr ',' '\n')