This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function f_para = cmaes_parallelize(f_orig) | |
| f_para = @f; | |
| function scores = f(vs) | |
| n = size(vs, 2); | |
| scores = zeros(1, n); | |
| parfor i = 1:n | |
| scores(i) = f_orig(vs(:, i)); | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function reload_workspace | |
| % Call this function in `Init`, `PostLoadFcn`, and/or `PreSaveFcn` model | |
| % callbacks to ensure that model workspace init script is auto-reloaded. | |
| ws = get_param(bdroot, 'ModelWorkspace'); | |
| ws.reload; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function slrt_conf_init(conf, solver, Ts) | |
| % initialize configuration of current model with default, then override | |
| % with given solver and timestep setting | |
| % | |
| % conf: path to common configuration file | |
| % solver: 'FixedStepDiscrete', 'ode8', 'ode4', ... | |
| % Ts: fixed step time of solver | |
| % | |
| % NOTE: SLRT allows only fixed-step solvers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name renren-adblock-201511 | |
| // @namespace https://github.com/summivox | |
| // @version 0.1 | |
| // @description block some renren ads and fix some layout bugs | |
| // @author summivox | |
| // @match *://*.renren.com/* | |
| // @grant none | |
| // ==/UserScript== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CapsLock::#Space | |
| +CapsLock::+#Space |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| img = imread('in.png'); | |
| f = figure('visible', 'off'); | |
| imshow(img, 'Border', 'tight'); | |
| hold on; | |
| rectangle('Position', [100, 200, 300, 150], 'EdgeColor', 'y'); | |
| hold off; | |
| F = getframe(gcf); | |
| imwrite(F.cdata, 'out.png'); | |
| close(f); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function raw = read_file(filename) | |
| % reads back one SLRT file | |
| f = SimulinkRealTime.fileSystem; | |
| h = fopen(f, filename); | |
| raw = fread(f, h); | |
| f.fclose(h); | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| currentFolder = fileparts(mfilename('fullpath')); | |
| cd(currentFolder); | |
| addpath(genpath([currentFolder '/src'])); | |
| addpath(genpath([currentFolder '/include'])); | |
| set_param(0, 'CacheFolder', [currentFolder '/build']); | |
| set_param(0, 'CodeGenFolder', [currentFolder '/build']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function [result, r] = pdisk2(sizes, n, maxAttempt) | |
| % Generate $n$ evenly spread-out 2d points in given region using Poisson | |
| % disk method | |
| % | |
| % sizes: [xMax, yMax] | |
| % actual range: 0 <= x < xMax, 0 <= y < yMax | |
| % n: # of points | |
| % maxAttempt: # of candidates generated per iteration (optional) | |
| xMax = sizes(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v NoAutoRebootWithLoggedOnUsers /t REG_DWORD /d 1 /f | |
| :: source: http://answers.microsoft.com/en-us/windows/forum/windows_8-windows_update/disable-automatic-forced-restart-after-windows/8c66d21c-7423-4c2d-a2ef-f4d7685422b0?auth=1 |