Skip to content

Instantly share code, notes, and snippets.

View ohlawdie's full-sized avatar
😟

Ohlawdie ohlawdie

😟
  • Michigan
View GitHub Profile
@ohlawdie
ohlawdie / DuffsDevice.cs
Last active February 11, 2020 22:51
Loop unrolling
static void DuffsDevice(uint count, int[] A, int[] B)
{
uint i = 0;
uint n = (count + 7) / 8;
switch (count % 8) {
case 0: A[i] = B[i++]; goto case 7;
case 7: A[i] = B[i++]; goto case 6;
case 6: A[i] = B[i++]; goto case 5;
case 5: A[i] = B[i++]; goto case 4;
case 4: A[i] = B[i++]; goto case 3;
@ohlawdie
ohlawdie / EnumerableCollection.cs
Last active February 11, 2020 22:51
CollectAndEnumerate
class Team<T> : IEnumerable<T> // enumerable collection
{
private T[] workers;
private const byte DEFAULTSIZE = 5;
public Team() {
this.workers = new T[DEFAULTSIZE];
}
private int i = 0;
public void Add(T param)
@ohlawdie
ohlawdie / Xml.cs
Last active February 11, 2020 22:51
GetXMLValue
private static string GetXmlValue(string id, string getData, XDocument xdoc)
{
return xdoc.Root.Descendants("girl").Elements().
Where(node => node.Name == "id" && node.Value == id).
Single<XElement>().NodesAfterSelf().
Where(values => ((XElement)values).Name == getData).
Cast<XElement>().Single<XElement>().Value;
}
$dir = dir *.zip
#go through each zip file in the directory variable
foreach($item in $dir)
{
Expand-Archive -Path $item -DestinationPath ($item -replace '.zip','') -Force
}
/* unzip all files in a directory and then do some work!! */