Skip to content

Instantly share code, notes, and snippets.

@caiorss
caiorss / XmlNamespaceStripper.cs
Created January 7, 2017 10:37 — forked from BlueReZZ/XmlNamespaceStripper.cs
Strip all namespaces from XML Document in C#
public class XmlStripper
{
public XmlNode RemoveAllNamespaces(XmlNode documentElement)
{
var xmlnsPattern = "\\s+xmlns\\s*(:\\w)?\\s*=\\s*\\\"(?<url>[^\\\"]*)\\\"";
var outerXml = documentElement.OuterXml;
var matchCol = Regex.Matches(outerXml, xmlnsPattern);
foreach (var match in matchCol)
outerXml = outerXml.Replace(match.ToString(), "");
@caiorss
caiorss / dictionary-app.el
Created January 5, 2017 13:37 — forked from daimatz/dictionary-app.el
Emacs Lisp Tips
;; Mac の Dictionary.app を、 Emacs の popwin.el から使う
;; dict.py is from http://sakito.jp/mac/dictionary.html
(defun dictionary ()
"dictionary.app"
(interactive)
(let ((word (if (and transient-mark-mode mark-active)
(buffer-substring-no-properties (region-beginning) (region-end))
(read-string "Dictionary: ")))
(cur-buffer (current-buffer))
(tmpbuf " * dict-process *"))
@caiorss
caiorss / ReflectionUtilities.cs
Created January 2, 2017 00:56 — forked from riyadparvez/ReflectionUtilities.cs
Reflection utilities for C#. Get all fields, constructors, methods and properties
/// <summary>
/// Utilties for reflection
/// </summary>
public static class ReflectionUtils
{
/// <summary>
/// Get all the fields of a class
/// </summary>
/// <param name="type">Type object of that class</param>
/// <returns></returns>
@caiorss
caiorss / extractedLinks.csv
Created December 25, 2016 22:39 — forked from bskaggs/extractedLinks.csv
Here are links to Wikipedia articles from Stack Overflow's tag wiki pages extracted from the May 2014 dump. Each link has been name normalized and has had redirects followed, and only valid articles are listed. The format is a CSV file, with triples representing tag name, the wikipedia link found on the tag wiki page, and the fully resovled link…
@caiorss
caiorss / .m
Created December 25, 2016 22:37 — forked from GiovanniBalestrieri/.m
Snippet - Basic Matlab Code
% Filters the signal using coefficients obtained by the butter filter
% design
x_filtered = filter(b,a,y);
% Plots the filtered signal
figure(4)
plot(t,x_filtered,'r')
hold on
plot(t,y0,'k','LineWidth',2)
hold on
@caiorss
caiorss / .m
Created December 25, 2016 22:37 — forked from GiovanniBalestrieri/.m
Snippet - Basic Matlab Filter
%% Filter Design
% Designs a second order filter using a butterworth design guidelines
[b a] = butter(2,0.2,'high');
% Plot the frequency response (normalized frequency)
figure(3)
H = freqz(b,a,floor(num_bins/2));
plot(0:1/(num_bins/2 -1):1, abs(H), 'r');
hold on
@caiorss
caiorss / stupid_tricks.matlab
Created December 25, 2016 22:37 — forked from adambard/stupid_tricks.matlab
Stupid MATLAB Tricks.
function stupid_tricks
% I made some functional tools for MATLAB.
assert(reduce_(@(x, y) x + y, [1, 2, 3, 4]) == 10)
% They got a little out of hand.
join = @(sep, args) ...
if_(ischar(sep), @() ... % Input check
reduce_(@(x, y) [x sep y], ... % Reduce to string
map_(@num2str, args))); % Convert args to string.
@caiorss
caiorss / gist:99798ba0b4ce9caceb3c46aec057c9d6
Created December 25, 2016 22:37 — forked from moorepants/gist:1007366
Basic Matlab Animation
t = 0:0.001:1000;
x = cos(t);
y = sin(t);
fig = figure();
ax = axes();
hold on
dot1 = plot(x(1), y(1));
dot2 = plot(1.5 * x(1), 1.5 * y(2));
hold off
@caiorss
caiorss / fourier.m
Created December 25, 2016 21:28 — forked from StephenKing/fourier.m
Matlab Fourier
%% Matlab-Skript zur Vorlesung Informationsuebertragung am 14.11.2014
% Autor: Valentin Burger, Michael Seufert, Steffen Gebert
clear all; %set(0, 'defaultlinelinewidth', 1);
figure(1);clf;box on;
A=5; % Amplitude
w=4; % Frequenz
phi=pi/2; % Phasenverschiebung
x=(0:0.001:2)*pi;
y=A*sin(x*w+phi);
@caiorss
caiorss / lda.m
Created December 25, 2016 21:28 — forked from gregoryely/lda.m
SOME MATLAB
%Function lda takes in a list of Words and documents and generates the
%probability matrices for LDA
% INPUTS:
% W -list of words
% D -list of documents assigned to each word
% nTopics - number of topics to use for LDA
% maxIter - maximum iterations to run LDA
% nVocab - (optional) number of unique words
%
% Outputs: