Skip to content

Instantly share code, notes, and snippets.

void gotoxy(int x, int y){
HANDLE hConsole = GetStdHandle( STD_OUTPUT_HANDLE );
COORD coord={x, y};
SetConsoleCursorPosition(hConsole, coord);
}
void setcolor(const char *fore, const char *back){
WORD type=0;
while(*fore!='\0'){
switch(*fore){
#include <cstdio> // printf
#include <cstdlib> // NULL
#include <algorithm> // fill
#include <vector>
#include <queue>
using namespace std;
//use constant instead of macro
const int MAXV = 1000; // maximum value of vertex
This is a very coarse chatroom written by php. I made it in a speech just for chatting with 2 friends.
WARNING: This one is very dangerous, which would be attacked by command injecttion, please BE CAREFUL using it.
" filetypes
filetype plugin on
filetype indent on
" ~/.vimrc ends here
set laststatus=2
set statusline=%4*%<\ %1*[%F]
set statusline+=%4*\ %5*[%{&fileencoding}, " encoding
set statusline+=%{&fileformat}%{\"\".((exists(\"+bomb\")\ &&\ &bomb)?\",BOM\":\"\").\"\"}]%m
set statusline+=%4*%=\ %6*%y%4*\ %3*%l%4*,\ %3*%c%4*\ \<\ %2*%P%4*\ \>
@CrBoy
CrBoy / Makefile
Created November 28, 2010 17:28
For the first problem by pcyu
all: p1 p2
p1: p1.cpp
g++ -o p1 p1.cpp
p2: p2.cpp
g++ -o p2 p2.cpp
clean:
rm -f p1 p2
encoding_utf8: encoding_utf8.c
gcc -o encoding_utf8 encoding_utf8.c
# I forget how to use variables....orz
#enc-$.c: encoding_utf8 $.c
# ./encoding_utf8 <$.c >enc-$.c
#
#$: enc-$.c
# gcc -o $ enc-$.c
@CrBoy
CrBoy / README
Created March 8, 2011 06:41
An example showing why to use fgets() instead of gets() to prevent buffer overflow
http://www.ithome.com.tw/itadm/article.php?c=66229
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
function _ps1_git(){
local ref cnt branch clean
ref=$(git symbolic-ref HEAD 2> /dev/null)
cnt=$(git branch 2> /dev/null|grep -c -E '*')
branch=$(echo "${ref#refs/heads/}")
if [[ "${branch}" == "" ]]
then
return
fi
@CrBoy
CrBoy / dec2bin.cpp
Created April 16, 2011 17:58
convert decimal to binary
#include <iostream>
#include <bitset>
using namespace std;
int main ()
{
int x;
cout<<"Please input one number: ";
cin>>x;
cout << bitset<32>(x) << endl;