Skip to content

Instantly share code, notes, and snippets.

View nathanchere's full-sized avatar
💭
I've moved to https://gitlab.com/nathanchere - these repos no longer maintained

Nathan Chere nathanchere

💭
I've moved to https://gitlab.com/nathanchere - these repos no longer maintained
View GitHub Profile
@nathanchere
nathanchere / ResourceFontLoader.cs
Last active January 4, 2016 03:08
Resource font loader
/*
Makes it easier to distribute and use fonts by embedding them in your application as a resource.
Example:
var fontLoader = new ResourceFont(Properties.Resources.font_ComicSerif);
textBox1.Font = fontLoader.GetFont(16);
*/
public class ResourceFont
{
@nathanchere
nathanchere / .gitignore
Last active August 29, 2015 13:57
.Net / Mono .gitignore
# Build and binary folders
[Bb]in/
[Oo]bj/
[Dd]ebug/
[Rr]elease/
# Visual Studio cruft
*.[Cc]ache
*.sln.cache
*.sln.docstates
@nathanchere
nathanchere / pygamesetup.sh
Last active August 29, 2015 14:13
Pygame development environment setup script
#######################################
# Pygame development environment setup
#######################################
#
# Intended for use on a clean Xubuntu 14.10 install
# Will probably work in other environments but YMMV
#
#######################################
# Install Mercurial
@nathanchere
nathanchere / FileAssociationManager.cs
Created January 23, 2015 10:25
File association helper
using Microsoft.Win32;
namespace FerretLib.Windows
{
public static class FileAssociationManager
{
/// <summary>
/// Create or update a file association in Windows
/// </summary>
/// <param name="fileExtension">The file extension
@nathanchere
nathanchere / timedinput.ps1
Last active February 26, 2020 15:22
Powershell: timed input example
Function TimedPrompt($prompt,$secondsToWait){
Write-Host -NoNewline $prompt
$secondsCounter = 0
$subCounter = 0
While ( (!$host.ui.rawui.KeyAvailable) -and ($count -lt $secondsToWait) ){
start-sleep -m 10
$subCounter = $subCounter + 10
if($subCounter -eq 1000)
{
$secondsCounter++
@nathanchere
nathanchere / compizaddplugindemo
Created June 18, 2015 00:14
Enabling compiz plugins from the command line
backupCompizConfig() {
gconftool-2 --get /apps/compizconfig-1/profiles/Default/general/screen0/options/active_plugins > ~/.backup/compizplugins.txt
}
addToCompizConf() {
TEMPVAR=$(gconftool-2 --get /apps/compizconfig-1/profiles/Default/general/screen0/options/active_plugins)
TEMPVAR=",${TEMPVAR:1:-1},"
if [ -z $(echo $TEMPVAR | grep ",$1,") ]; then
echo "'$1' not found; adding to Compiz conf..."
gconftool-2 --set --type=list --list-type=string /apps/compizconfig-1/profiles/Default/general/screen0/options/active_plugins "[${TEMPVAR:1}$1]"
@nathanchere
nathanchere / gist:fb4bedef0b0195094c7a
Created July 7, 2015 09:16
.gitignore for VS2015 / ASP.Net 5
# Build and binary folders
[Bb]in/
[Oo]bj/
[Dd]ebug/
[Rr]elease/
artifacts/
bower_components/
node_modules/
!node_modules/.bin
@nathanchere
nathanchere / greedy.c
Last active August 29, 2015 14:26 — forked from JamesCalleja/greedy.c
#include <stdio.h>
#include <float.h>
// declare global variables
float qrt;
float dim;
float nik;
float pen;
float chg;
@nathanchere
nathanchere / mp3_info.ex
Created May 10, 2016 12:23 — forked from kommen/mp3_info.ex
Compute MP3 variable bitrate file duration with Elixir
defmodule Mp3Info do
def duration(data) do
compute_duration(data, 0, 0)
end
defp compute_duration(data, offset, duration) when byte_size(data) > offset do
case decode_header_at_offset(offset, data) do
{:ok, length, {samplerate, samples}} ->
compute_duration(data, offset + length, duration + (samples / samplerate))
public static Stream AsStream(this string input)
{
var result = new MemoryStream();
using (var writer = new StreamWriter(result)) {
writer.Write(input);
}
result.Position = 0;
return result;
}