Skip to content

Instantly share code, notes, and snippets.

View sp9usb's full-sized avatar

Kamil Myśliwiec sp9usb

View GitHub Profile
@sp9usb
sp9usb / gist:6cf2ebe31ab6a6630da4
Created November 26, 2014 10:48
Create list of unnamed type
void foobar(Type t)
{
var listType = typeof(List<>);
var constructedListType = listType.MakeGenericType(t);
var instance = Activator.CreateInstance(constructedListType);
}
@sp9usb
sp9usb / gist:e19856ea108a0d1e138c
Created November 18, 2014 12:25
MSBuild Project Transformate
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="AfterCompile" Condition="exists('app.$(Configuration).config')">
<!-- Generate transformed app config in the intermediate directory -->
<TransformXml Source="app.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="app.$(Configuration).config" />
<!-- Force build process to use the transformed configuration file from now on. -->
<ItemGroup>
<AppConfigWithTargetPath Remove="app.config" />
<AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config">
<TargetPath>$(TargetFileName).config</TargetPath>
</AppConfigWithTargetPath>
@sp9usb
sp9usb / Cascade drop all tables.sql
Last active September 21, 2016 06:58
PostgreSQL block code
DO $$
DECLARE
all_tables CURSOR FOR SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';
BEGIN
FOR table_record IN all_tables LOOP
EXECUTE 'DROP TABLE ' || table_record.table_name || ' CASCADE';
END LOOP;
END $$;