Skip to content

Instantly share code, notes, and snippets.

View dangkhoasdc's full-sized avatar
😎

Le Tan Dang Khoa dangkhoasdc

😎
View GitHub Profile
jQuery('.question-rankings').each(function(){ var choices = $(this).find('input');
var index = Math.floor(Math.random() * 3 + 1) + 1;
choices.get(index).checked = true;
});
jQuery('.question-answers').each(function(){
var choices = $(this).find('input');
var index = Math.floor(Math.random() * 2 + 2);
choices.get(index).checked = true;
});
Remove osxfuse if installed via homebrew:
> brew uninstall osxfuse
Install osxfuse binary and choose to install the MacFUSE compatibility layer:
http://sourceforge.net/projects/osxfuse/files/latest/download?source=files
Reboot (optional but recommended by osxfuse)
Install ntfs-3g via homebrew:
> brew update && brew install ntfs-3g
@dangkhoasdc
dangkhoasdc / read_entire_file.pl
Created February 23, 2015 13:53
Read an entire file into string
open my $fh, '<', 'text_document.txt' or die "Can't open file $!";
my $text_file = do { local $/; <$fh> };
### INSTALLATION NOTES ###
# 1. Install Homebrew (https://github.com/mxcl/homebrew)
# 2. brew install zsh
# 3. Install OhMyZsh (https://github.com/robbyrussell/oh-my-zsh)
# 4. brew install reattach-to-user-namespace --wrap-pbcopy-pbpaste && brew link reattach-to-user-namespace
# 5. Install iTerm2
# 6. In iTerm2 preferences for your profile set:
# Character Encoding: Unicode (UTF-8)
# Report Terminal Type: xterm-256color
# 7. Put itunesartist and itunestrack into PATH
@dangkhoasdc
dangkhoasdc / .vimrc
Created March 28, 2013 16:28
My favorite config's vim
" vim: fdm=marker:
" Recommended for vim >= 7; no guarantee of compatibility with earlier versions
" Lucas Oman <me@lucasoman.com>
" --enable-rubyinterp --prefix=/usr --enable-ruby
" Get latest from: http://github.com/lucasoman/Conf/raw/master/.vimrc
" load pathogen
call pathogen#runtime_append_all_bundles()
filetype off
syntax on
#define MAX_BUFERROR 255
#define COMMAND_ERROR printf
#define NEWEXCEPTION(mess, code) { \
char err[MAX_BUFERROR]; \
sprintf(err,mess". CODE: %d.\n", code);\
COMMAND_ERROR (err);\
fflush(NULL);\
}
@dangkhoasdc
dangkhoasdc / perf.h
Last active December 16, 2015 17:00
#ifndef __MEASURINGTIME__
#define __MEASURINGTIME__
#ifdef MEASURE_TIME
#include <stdio.h>
#include <ctime>
static clock_t __begin;
static clock_t __end;
static double __secs;
#endif
@dangkhoasdc
dangkhoasdc / translate_modified.cc
Created May 3, 2013 16:23
Phương thức được thêm vào trong lớp Machine của đồ án Nachos. Công dụng: Chuyển đổi vùng nhớ từ User mode sang kernel mode và ngược lại.
char* Machine::User2System(int virtAddr, int limit)
{
int i;
int ch;
char* kernelBuf = NULL;
kernelBuf = new char[limit+1];
if (kernelBuf == NULL)
{
return kernelBuf;
}
@dangkhoasdc
dangkhoasdc / template_header.h
Created June 19, 2013 13:59
Template header file. The order is just my experience. It is useful for small and medium projects.
/* * * * * * * * * * * * * * * * * * * *
* System and Standard Library header file
* Author: DangKhoaSDC.
* * * * * * * * * * * * * * * * * * * * /
#ifndef _STANDARDLIBS
#define _STANDARDLIBS
#ifndef __cplusplus
#error "Must use C++ compiler!!"