Skip to content

Instantly share code, notes, and snippets.

View jglozano's full-sized avatar

Javier Lozano jglozano

View GitHub Profile
@jglozano
jglozano / camera_import.xml
Last active August 29, 2015 13:55
Camera Import XML
<?xml version="1.0" encoding="ASCII"?>
<Exif>
<APP1>
<Exif_IFD>
<DateTimeOriginal>2014:01:29 09:51:37</DateTimeOriginal>
</Exif_IFD>
<GPS_IFD>
<GPSLatitudeRef>N</GPSLatitudeRef>
<GPSLatitude>00:00:00</GPSLatitude>
<GPSLongitudeRef>E</GPSLongitudeRef>
@jglozano
jglozano / InternalReadAllBytes.cs
Created May 13, 2014 19:16
Reflector inferred impl of InternalReadAllBytes
[SecurityCritical]
private static byte[] InternalReadAllBytes(string path, bool checkHost)
{
byte[] buffer;
using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 0x1000, FileOptions.None, Path.GetFileName(path), false, false, checkHost))
{
int offset = 0;
long length = stream.Length;
if (length > 0x7fffffffL)
{
@jglozano
jglozano / large_file.txt
Created July 11, 2014 14:53
Create large file on Windows
fsutil file createnew <filename> <length>
@jglozano
jglozano / https_http_redirect.txt
Created July 15, 2014 21:56
HTTPS to HTTP Redirect
<rewrite>
<rules>
<rule name="HTTPS to HTTP redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^ON$" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="http://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
@jglozano
jglozano / fizzbuzz_tasks.txt
Last active August 29, 2015 14:04
FizzBuzz Tasks
From 1 to 100
Entry
----------
if num divisible by 3, Fizz
if num divisible by 5, Buzz
if num divisible by 3&5, FizzBuzz
Mid
----------
@jglozano
jglozano / speaker_bio.txt
Created August 13, 2014 20:46
Speaker Bio
Javier is principal for lozanotek, a .NET focused software development boutique based in Des Moines, IA. His specializations are in ASP.NET, Azure, system design, and developer mentoring. Javier is also an ASP.NET Insider, Azure Insider, and ASP.NET MVP for all of his contributions to products and community. For fun, Javier runs and manages the popular dotnetConf and aspConf virtual conferences. He’s is an avid supporter of the community and likes to give back by speaking at user groups, local/regional/national .NET events. In his spare time, Javier loves spending time with his family and enjoys writing about himself in the third person.
@jglozano
jglozano / Computer.cs
Created August 21, 2014 16:18
Lock workstation
public static class Computer {
[DllImport("user32.dll")]
public static extern void LockWorkStation();
}
@jglozano
jglozano / Display.cs
Created August 21, 2014 16:22
Turn off displays
public static class Display {
private const uint WmSyscommand = 0x0112;
private const int ScMonitorpower = 0xF170;
private const int HwndBroadcast = 0xFFFF;
private const int ShutOffDisplay = 2;
[DllImport("user32.dll", SetLastError = true)]
private static extern bool PostMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
public static void TurnOff() {
@jglozano
jglozano / PredicateExtensions.cs
Created September 3, 2014 16:55
Predicate Extensions LINQ
//Source from this great article on Pipe & Filter
// Article - https://www.simple-talk.com/dotnet/.net-framework/giving-clarity-to-linq-queries-by-extending-expressions/
// NuGet Pkg - https://www.nuget.org/packages/PredicateExtensions/
public static class PredicateExtensions
{
/// <summary>
/// Begin an expression chain
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="value">Default return value if the chanin is ended early</param>
@jglozano
jglozano / chunk.cs
Created September 8, 2014 12:42
IEnumerable Chunk
public static IEnumerable<IEnumerable<T>> Chunk<T>(this IEnumerable<T> source, int chunksize)
{
while (source.Any())
{
yield return source.Take(chunksize);
source = source.Skip(chunksize);
}
}