Skip to content

Instantly share code, notes, and snippets.

@ryanohs
ryanohs / download.sh
Created September 9, 2023 21:40
Download AQI annual summary files from the EPA
#!/bin/bash
# Define the base URL for the zip files
base_url="https://aqs.epa.gov/aqsweb/airdata/annual_aqi_by_county_"
# Define the range of years (from 2000 to 2022 in this example)
start_year=2015
end_year=2022
# Define the directory where you want to store the downloaded zip files
public class DocxToJournalTransformer
{
private const int BLOCK_TEXT = -2;
public void Transform(string docxFilename, Stream outputStream)
{
var root = new Node();
using (var document = DocX.Load(docxFilename))
{
var lastNode = root;
@ryanohs
ryanohs / Parser.cs
Last active July 25, 2021 15:57
A bullet journal parser
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Xunit;
namespace Parser
{
public class Parser
public class DemoFormModel
{
[JsonSchemaExtensionData("label", "Label")]
[JsonSchemaExtensionData("required", true)]
[Description("The description appears below the input.")]
[MinLength(3)]
[MaxLength(50)]
public string TextProperty { get; set; }
public string StringProperty { get; set; }
@ryanohs
ryanohs / MethodBaseRocks.cs
Last active August 24, 2019 05:51 — forked from jbevain/MethodBaseRocks.cs
A reflection based disassembler
//
// MethodBaseRocks.cs
//
// Author:
// Jb Evain (jbevain@novell.com)
//
// WARNING: code now lives in http://github.com/jbevain/mono.reflection
//
// (C) 2009 Novell, Inc. (http://www.novell.com)
//
@ryanohs
ryanohs / EFHelpers.cs
Last active June 15, 2016 02:33
For updating database from disconnected entities.
public static class EFHelpers
{
/// <summary>
/// Helper function to update an EF model child collection from a view model posted from javascript.
/// </summary>
public static void MergeGraph<TModel, TUpdate, TId>(
ICollection<TModel> modelCollection,
ICollection<TUpdate> updateCollection,
DbSet<TModel> dbSet,
Func<TModel, TId> modelId,
public class WhereBuilder
{
private readonly IProvider _provider;
private TableDefinition _tableDef;
public WhereBuilder(IProvider provider)
{
_provider = provider;
}
public class WhereBuilder
{
private readonly IProvider _provider;
private TableDefinition _tableDef;
public WhereBuilder(IProvider provider)
{
_provider = provider;
}
@ryanohs
ryanohs / FastAccessor.cs
Created April 2, 2016 15:31
Playing with IL generation.
public class FastAccessor<T> where T : class
{
private static readonly Hashtable _cache = new Hashtable();
public static FastAccessor<T> For(T target)
{
if (_cache.ContainsKey(typeof(T)))
{
var dlg = (Action<T, string, object>)_cache[typeof(T)];
return new FastAccessor<T>(dlg, target);
using System;
using System.Collections.Generic;
using System.Linq;
using PagedList;
public class DataTablesSearch
{
public string Value { get; set; }
public bool Regex { get; set; }
}