Skip to content

Instantly share code, notes, and snippets.

@shaybensasson
shaybensasson / matrix|array|vector manipulation.matlab
Created March 4, 2015 09:06
matrix|array|vector manipulation
%acessing and slicing
a=[1 2;3 4]
%{
a =
1 2
3 4
%}
a='123';b='456123';
s1=[a ',' b '.']
n=num2str(15.5)
s2=['I am ' n ' years old.']
b = strcmpi('s', 'S'); %1
@shaybensasson
shaybensasson / Permutate an array.cs
Created March 4, 2015 09:07
Permutate an array
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assignment2
{
public static class PermutationExtensions
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public static class LinqExtensions
{
public static string AggregateToString<T>(this IEnumerable<T> input, string seperator)
{
using System;
using System.Collections;
using System.IO;
using System.Reflection;
using System.Text;
using IDictionary=System.Collections.IDictionary;
#region Class: ObjectDumper
/// <summary>
@shaybensasson
shaybensasson / SpikeRateUsingGaussian.matlab
Created March 7, 2015 16:24
create firing rate from spike train using Gaussian kernel
%https://www.mathworks.com/matlabcentral/newsreader/view_thread/243177
clear all
clc
figure(1);clf
%y=[ 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1]; % spike train
SPIKE_TRAIN_LENGTH = 100;
y=double(logical(rand(SPIKE_TRAIN_LENGTH,1)<0.5));
plot(y)
hold on
@shaybensasson
shaybensasson / PlotTransparentLine.matlab
Created March 7, 2015 16:25
line plot transparency(alpha)
xlim([1,5]);
hold('on');
h1a = plot(1:5, 11:15, '.-', 'LineWidth',10, 'DisplayName',' 0.5');
h1b = plot(1.5:5.5, 11:15, '.-', 'LineWidth',10, 'DisplayName',' 1.0', 'Color',h1a.Color); % 100% opaque
h1a.Color(4) = 0.5; % 50% transparent
h2a = plot(3:7, 15:-1:11, '.-r', 'LineWidth',8, 'DisplayName',' 0.3'); h2a.Color(4)=0.3; % 70% transparent
h2b = plot(2:6, 15:-1:11, '.-r', 'LineWidth',8, 'DisplayName',' 0.7'); h2b.Color(4)=0.7; % 30% transparent
h2c = plot(1:5, 15:-1:11, '.-r', 'LineWidth',8, 'DisplayName',' 1.0'); % 100% opaque = 0% transparent
legend('show','Location','west')
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
@shaybensasson
shaybensasson / PathValidation.cs
Created May 29, 2015 06:18
Validates and cleans invalid path and filenames
using System;
using System.IO;
using System.Text.RegularExpressions;
namespace WallpaperFromRSS
{
public static class PathValidation
{
private static readonly string pathValidatorExpression = "^[^" + string.Join("", Array.ConvertAll(Path.GetInvalidPathChars(), x => Regex.Escape(x.ToString()))) + "]+$";
private static readonly Regex pathValidator = new Regex(pathValidatorExpression, RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.CultureInvariant);
SEED = intmax;
rng('default');
rng(SEED);
randn(3,3)
rng(SEED);
randn(3,3)