Skip to content

Instantly share code, notes, and snippets.

@HereChen
HereChen / gist:11201279
Last active August 29, 2015 14:00
sublime: open cmd
import os, sublime_plugin
class CmdCommand(sublime_plugin.TextCommand):
def run(self, edit):
file_name=self.view.file_name()
path=file_name.split("\\")
current_driver=path[0]
path.pop()
current_directory="\\".join(path)
command= "cd "+current_directory+" & "+current_driver+" & start cmd"
os.system(command)
@HereChen
HereChen / Preferences.sublime-settings
Created April 23, 2014 03:05
sublime: save file auto
"save_on_focus_lost": true
@HereChen
HereChen / Preferences.sublime-settings
Created April 23, 2014 03:06
sublime: hightlight current line
"highlight_line": true,
@HereChen
HereChen / C.sublime-build
Created April 24, 2014 12:26
sublime: gcc
{
"cmd": ["gcc", "$file", "-o", "$file_base_name"],
"selector": "source.c",
"working_dir": "${file_path}",
"variants":
[
{
"name": "Run",
"cmd" : ["$file_path/${file_base_name}"],
},
@HereChen
HereChen / Lua.sublime-build
Created April 24, 2014 12:30
sublime: Lua
{
"cmd": ["lua", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.lua"
}
@HereChen
HereChen / gist:11254286
Last active August 29, 2015 14:00 — forked from romanz/gist:968198
matlab: git
function [status, result] = git(varargin)
cmd = '"c:\Program Files\Git\cmd\git.cmd"';
for i = 1:numel(varargin)
cmd = [cmd ' ' varargin{i}];
end
switch nargout
case 0, system(cmd);
case 1, [status] = system(cmd);
case 2, [status, result] = system(cmd);
@HereChen
HereChen / gist:8826fe0ba9afdbee6078
Last active August 29, 2015 14:01
matlab: get variable names from mat file
test = load('test.mat');
fn = fieldnames(test);
@HereChen
HereChen / gist:cd7843f001452c90dafa
Last active August 29, 2015 14:01
matlab: associate .m with matlab
% Run matlab as administrator
% solve the problem opening a new matlab after double click m-file.
cwd = pwd;
cd([matlabroot '\toolbox\matlab\winfun\private']);
fileassoc('add','.m') ;
cd(cwd);
disp('Changed Windows file association. M-files are now associated with MATLAB.');
@HereChen
HereChen / insert_date.py
Created June 9, 2014 15:03
sublime: insert time
import datetime, getpass
import sublime, sublime_plugin
class InsertDatetimeCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.run_command("insert_snippet", { "contents": "%s" % datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") } )
# self.view.run_command("insert_snippet", { "contents": "%s" % datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S %a") } )
@HereChen
HereChen / gist:0291738ad3d2846624c3
Created August 10, 2014 13:31
[Git] Change Git Home Path
# modify etc/profile
# normalize HOME to unix path
HOME="/e/GitRep"
HOME="$(cd "$HOME" ; pwd)"
cd
export PATH="$HOME/bin:$PATH"