Skip to content

Instantly share code, notes, and snippets.

@diffused
diffused / gist:5517341
Created May 4, 2013 12:24
Python peewee orm. How to do a "where in (1,2,3)" style query. It was kind of tricky to find the syntax in the docs/google
products = Product.select().where(
Product.id << [161,162,163,164,165]).where(
~(Product.brand_name >> None)
)
@diffused
diffused / Startup.cs
Created May 20, 2019 23:53
aspnet core typed config
public class MySettings
{
public string Value1 { get; set; }
public string Value2 { get; set; }
}
public class Startup
{
public void ConfigureService(IServiceCollection services)
{
@diffused
diffused / HipHopFlow.cs
Created February 1, 2018 22:53
Who has the best flow?
using System.Collections.Generic;
using System.Linq;
using Xunit;
using FluentAssertions;
using FakeItEasy;
namespace HipHopFlow
{
public class FlowService
@diffused
diffused / jsx
Created September 21, 2016 03:09
import React, {Component} from 'react';
import { connect } from 'react-redux';
import { fetchListing } from '../../actions/ListingActions';
@connect((store) => {
return {
listing: store.listing.listing,
};
})
@diffused
diffused / map_remote_port_to_local.sh
Created December 1, 2013 10:52
ssh map remote localhost:8080 to local localhost:18080
ssh -L 18080:localhost:8080 user@server
# ssh -L [localport]:localhost:[remoteport] user@server
@diffused
diffused / clearDbExceptEfMigrationHistory.cs
Created November 26, 2013 10:48
Delete all data from DB except the dbo._MigrationHistory table using Entity Framework.
using(var context = new PlayContext())
{
context.Database.ExecuteSqlCommand(@"
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL';
EXEC sp_MSForEachTable 'IF OBJECT_ID(''?'') NOT IN (OBJECT_ID(''[dbo].[__MigrationHistory]'')) DELETE FROM ?';
EXEC sp_MSForEachTable 'ALTER TABLE ? WITH CHECK CHECK CONSTRAINT ALL';
");
}
@diffused
diffused / Product.cs
Created November 20, 2013 14:12
Example Entity Framework 6 context using connection string in app.config
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
}
@diffused
diffused / Preferences.sublime-settings
Created October 11, 2013 19:40
Sublime Text user settings to disable atomic saves so gaurd can see filesystem changes
{
"atomic_save": false,
}
@diffused
diffused / turn_off_event_tracker.reg
Created September 27, 2013 10:44
Turn off windows server 2008 shutdown event tracker prompt
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Reliability]
"ShutdownReasonOn"=dword:00000000
@diffused
diffused / cygwin symlinks for virtualbox
Last active December 19, 2015 16:28
Create symlinks so Vagrant via cygwin places VirtualBox VMs in the normal windows user home. Run these from Administrator cmd