Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@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,
};
})
#!/usr/bin/ruby
require 'date'
class Girl
def initialize(name, date_of_birth, weight_in_kg)
@name = name
@date_of_birth = date_of_birth
@weight_in_kg = weight_in_kg
end
@diffused
diffused / wipedb
Created April 1, 2015 11:46
EF + Sql Server wipe data in all tables listed in __MigrationHistory
context.Database.ExecuteSqlCommand("sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'");
context.Database.ExecuteSqlCommand("sp_MSForEachTable 'IF OBJECT_ID(''?'') NOT IN (ISNULL(OBJECT_ID(''[dbo].[__MigrationHistory]''),0)) DELETE FROM ?'");
context.Database.ExecuteSqlCommand("EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL'");
@diffused
diffused / gulpfile.js
Created March 25, 2015 23:54
Gulpfile to transpile ES6 using babel and browserify
// npm install --save-dev gulp gulp-babel babelify through2 gulp-rename gulp-load-plugins
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var browserify = require('browserify');
var through2 = require('through2');
var babelify = require('babelify');
var srcApp = './src/app.js';
var srcWatchPath = './src/**/*.js'
Remove osxfuse if installed via homebrew:
> brew uninstall osxfuse
Install osxfuse binary and choose to install the MacFUSE compatibility layer:
http://sourceforge.net/projects/osxfuse/files/latest/download?source=files
Reboot (optional but recommended by osxfuse)
Install ntfs-3g via homebrew:
> brew update && brew install ntfs-3g
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
gulp.task('default', ['watchJs', 'watchTests']);
// make sure you do not start a path with ./
// there's some bug in gaze that causes globs with ./ to not fire
var unitTestPaths = [
'tests/**/*_tests.js'
];
@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';
");
}