Skip to content

Instantly share code, notes, and snippets.

@tfwio
tfwio / Sample2WindowFrame.cs
Created June 25, 2014 14:55
Sample to Frame resolution calculation; Desired result is simply the integer 'f' (frame-width, in samples). 1920x1080 maximum resolution, windowing path-data for X/Width (1920), so that we can create a cache of this data and more rapidly calculate path-data for rendering. Concept is based on NAuido's WPF player demo, only applied to an entire wa…
some_namespace {
class some_class {
static int FrameSize(int hours, int minutes, int seconds, int channels = 2, int bytes = 2, int rate = 44100, float round = 0f)
{
double samples = channels * bytes * rate * ( hours*60*60 + minutes*60 + seconds );
int frameCount = Convert.ToInt32(samples - samples % 1);
if ((samples % 1) > round) frameCount++;
return frameCount;
}
static void SampleProgram(int window, int hours, int minutes, int seconds, int channels = 2, int bytes = 2, int rate = 44100, float round = 0f)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tfwio
tfwio / LocalMuiSettings.cs
Last active August 29, 2015 14:02
windows csharp registry reader/writer snippit. How to implement would be to add a call to LocalMuiSettings.Assert() after the window's call to InitializeComponent().
using System;
using System.Linq;
using System.Windows.Media;
using FntSize = FirstFloor.ModernUI.Presentation.FontSize;
namespace genericwav
{
static class LocalMuiSettings
{
@tfwio
tfwio / AssemblyInfo-snippit.cs
Last active August 29, 2015 14:02
Get StrongKeyName and StrongKey from an assembly (windows batch command)
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// to be added to your AssemblyInfo.cs
// do not overwrite your assemblyinfo.cs file with this one!
[assembly: InternalsVisibleTo("[Your-AssemblyName],PublicKey=...")]
@tfwio
tfwio / Demo-AssemblyInfo.cs
Created June 10, 2014 06:03
SvnInfo MSBuild ingegration
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
@tfwio
tfwio / ReadingPage.md
Last active February 5, 2017 10:44
tfwxo/readme (wp-page-content)
  • Calibre allows you to organize your ebook messes of messes into tidy libraries (it did for me).
  • SumatraPDF for WINDOWS uses MuPDF, and can "read" DJVU, EPUB, MOBI, AZW/AZW3, PDF, and more.
  • DjVuLibre DjVu ebook reading software for WIN, MAC and GNU/LINUX is worth pointing out (if you don't have windows/SumatraPDF).
  • On-line sources for digital books predominantly in PDF format and other formats such as TeX, EPUB, MOBI (Kindle), Etc...
  • featured here: tfwxo.wordpress.com/readme, gist
  • This page is a continuous work in progress, started as a programming book library page for the programming section of this site.

TOC

----
@tfwio
tfwio / GitInfoProvider.cs
Last active December 28, 2015 00:19
Searches "%programfiles%/git/bin/" and "%programfiles (x86)%/git/bin/" for existing 'git.exe' (so you don't need git.exe in your environment path). Original source: http://versioning.codeplex.com/SourceControl/latest#MSBuildVersioning/GitInfoProvider.cs
using System;
namespace MSBuildVersioning
{
/// <summary>
/// Provides Mercurial information for a particular file path, by executing and scraping
/// information from the hg.exe command-line program.
/// </summary>
public class GitInfoProvider : SourceControlInfoProvider
{
@tfwio
tfwio / README.md
Last active December 26, 2015 15:49
Two helper snipits (not to forget) for reading from shoutcast streams in Microsoft.NET applications (app.config), of which one or the other may be used. See the readme for info on how to use and the source (forum post).

SetAllowUnsafeHeaderParsing Snippits

Brief

Either of the two provided snipts address the same issue.

  • the csharp file addresses the issue with a block of code you should call in your 'main' program-process.
  • the xml app.config may alternatively be used for brevity.

Why

@tfwio
tfwio / jquery.tfoxo-box.js
Last active December 25, 2015 12:29
semi-useless, undocumented crap especially because I cant remember where or why
(function($){
// TODO: adequate coding conventions
//¿useless!
$.fox = function()
{
var
a = { fun: function(name,action,mthd) { $(name).unbind(action,mthd); $(name).bind(action,mthd); } };
return false;
@tfwio
tfwio / fparams-dic.cs
Created September 27, 2013 10:19
A code explanation of the supported field-element-tags in a template-based cs-code-generator app; Granted there are extension methods at play here, but it still explains a good number of the tags, currently.
//
DICT <string,object> fparams = new DICT <string,object>();
//
fparams.Add("Date", string.Format("MM/dd/yyyy",DateTime.Now));
fparams.Add("Time", string.Format("hh:mm.ss tttt",DateTime.Now));
fparams.Add("DateTime", string.Format("MM/dd/yyyy hh:mm.ss tttt",DateTime.Now));
//
fparams.Add("DataName", DataName);
fparams.Add("dataname", DataName.ToLower());
fparams.Add("DataNameC", dataName.Capitolize());