Skip to content

Instantly share code, notes, and snippets.

@KyleGobel
KyleGobel / zip_upload_logs.ps1
Created January 29, 2015 22:07
Zip and upload logs to S3 - Powershell
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
$logFile = Join-Path "C:\inetpub\logs\LogFiles\W3SVC2" "upload_logs.logFile"
Try
{
$files = Get-ChildItem -Filter *.log | where-object {$_.lastwritetime -lt (Get-Date).AddHours(-1)}
$processedDir = Join-Path $scriptPath "uploaded_to_s3"
if ($files.count -gt 0) {
Write-Output "Starting Uploads to S3" | Out-File $logFile -Append
using System.Text;
var RegFieldEncoding = new Dictionary<(int reg, int w), string>()
{
{ (0b000, 0), "al" },
{ (0b000, 1), "ax" },
{ (0b001, 0), "cl" },
{ (0b001, 1), "cx" },
@KyleGobel
KyleGobel / settings.json
Last active September 27, 2020 14:48
Windows Terminal
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"alwaysShowTabs": true,
"copyOnSelect": false,
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"disabledProfileSources": [
"Windows.Terminal.Azure"
],
"initialCols": 120,
"initialRows": 30,
@KyleGobel
KyleGobel / stackedit_vim.js
Created August 15, 2014 00:30
VI StackEdit.io plugin
userCustom.onReady = function() {
var ace = {}
ace.require = require
ace.define = define
ace.require(["ace/lib/net"], function(acenet) {
acenet.loadScript("//cdnjs.cloudflare.com/ajax/libs/ace/1.1.01/keybinding-vim.js", function() {
e = document.querySelector(".ace_editor").env.editor
ace.require(["ace/keyboard/vim"], function(acevim) {
e.setKeyboardHandler(acevim.handler);
});
@KyleGobel
KyleGobel / upsert.sql
Last active June 27, 2016 16:37
Insert/Update Upsert Trigger in Postgres
CREATE OR REPLACE FUNCTION upsert_user()
RETURNS trigger AS
$upsert_user$
declare
existing record;
begin
if (select EXISTS(select 1 from users where user_id = NEW.user_id)) then
select user_name, user_class, user_age into strict existing from users where user_id = new.user_id;
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
if (_testRenderTarget)
{
_spriteBatch.Begin(SpriteSortMode.Immediate);
GraphicsDevice.SetRenderTarget(_renderTarget);
_spriteBatch.Draw(_guiTexture, new Rectangle(0, 0, 64, 64), new Rectangle(0, 0, 64, 64), Color.White);
_spriteBatch.End();
public class Game1 : Game
{
private GraphicsDeviceManager _graphics;
SpriteBatch _spriteBatch;
private bool _testRenderTarget = false;
private Texture2D _guiTexture;
private RenderTarget2D _renderTarget;
public Game1()
// _guiTexture is a texture of a bunch of gui images (buttons, scrollbars panels ect)
// srcRectangle in this case is the source rectange of a 64x64 button
// create render target
// if I set this to the same size of the backbuffer it draws how i expect it, but for some reason
// changing the width/height of this is changing the look when drawn to the screen...
// this doesn't make sense to me because i'm only using 64x64 pixels of this big area...changing it's size
// shouldn't have any effect in my mind
Canvas = new RenderTarget2D(Graphics, 800, 600)
using Xunit;
public class MyTests
{
[Fact] //This means this is a test
public void TestMyGetMethodWorks()
{
var journalService = new JournalService(/* not sure what kinda constructor you have */);
@KyleGobel
KyleGobel / Watermark.cs
Created December 6, 2013 16:47
Watermark For Textbox
/// <summary>
/// Class that provides the Watermark attached property
/// </summary>
public static class WatermarkService
{
/// <summary>
/// Watermark Attached Dependency Property
/// </summary>
public static readonly DependencyProperty WatermarkProperty = DependencyProperty.RegisterAttached(
"Watermark",