Skip to content

Instantly share code, notes, and snippets.

View trashvin's full-sized avatar
🤘
human knowledge belongs to the world

Marvin Trilles trashvin

🤘
human knowledge belongs to the world
View GitHub Profile
@trashvin
trashvin / Startup.cs
Last active June 1, 2017 03:51
Enabling CORS in ASPNet Core
using Microsoft.AspNetCore.Cors; //add reference to the needed library
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
//Add CORS service beloe
services.AddCors( options => options.AddPolicy("AllowCors",
builder => {
@trashvin
trashvin / index.html
Last active June 2, 2017 12:51
Logging in Using Google Account and Getting User Data (option 1 Angular 2)
<!--Add this on the head tag -->
<script src="https://apis.google.com/js/platform.js" async defer></script>
@trashvin
trashvin / sample.cs
Last active June 2, 2017 13:20
Multiple assignment inside ForEach (LINQ)
//use curly brace to group assignment statements
_localDb.Where( i => i.id == id).ToList().ForEach( i => {
i.name = task.name;
i.completed = task.completed;
i.priority = task.priority;
});
@trashvin
trashvin / flexbox-align-issues.markdown
Last active December 14, 2017 11:56
flexbox-align-issues
@trashvin
trashvin / component.html
Created January 8, 2018 06:19
Using Simple Reactive Form in Angular5
<form [formGroup]="detail_form" (ngSubmit)="onSubmit()">
<fieldset>
<div class="row form-group">
<input class="form-control" id="title" placeholder="Enter Title" formControlName = "title" required>
<small *ngIf="detail_form.controls.title.invalid && detail_form.controls.title.touched" class="error">Title is empty.</small>
</div>
<div class="row form-group">
<textarea class="form-control" rows="10" id="poem" formControlName ="poem" required></textarea>
<small *ngIf="detail_form.controls.poem.invalid && detail_form.controls.poem.touched" class="error">Poem is empty.</small>
</div>
@trashvin
trashvin / IsJREMet.ps1
Last active May 9, 2018 02:00
Powershell : Check if JRE version is met
$version = &"java.exe" -version 2>&1
$version = $version[0].tostring()
$start = $version.IndexOf('"')
$version = $version.Remove(0,$start-1).Replace('"','').Trim()
$required = "1.8.0_114"
$result = $version.CompareTo($required)
if($result -eq 0) {
@trashvin
trashvin / BackoutSQLObject.ps1
Last active May 9, 2018 02:01
Powershell : Backup SQL SP,View, Function read from text file
# types : vw-views, sp-stored procs, fn - function, tg - triggerparam($serverName, $fileName, $type, $location)[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | out-null $dbName = "GlobalSTORE"$srv = new-object Microsoft.SqlServer.Management.Smo.Server($serverName) $db = $srv.Databases.Item($dbName) $folderLocation = $location$type = $type.ToString().ToUpper()
function Alert {   
param($m1,$m2,$m3,$m4,$m5)   
Write-Host $m1 $m2 $m3 $m4 $m5
}
function GetBackupLocation {   
if ($type -eq "VW") {
$folderLocation = $location + "\Views\";   
} elseif ($type -eq "SP") {
$folderLocation = $location + "\StoredProcedures\";   
@echo off
ECHO **********************************************************
ECHO NOTE :
ECHO Code Analysis is enabled by default and for a good reason
ECHO Use this script at your own risk
ECHO **********************************************************
ECHO .
ECHO Starting Visual Studio 2013 with Code Analysis OFF
set DevDivCodeAnalysisRunType=Disabled
devenv
@trashvin
trashvin / downtime.py
Created May 30, 2019 09:47 — forked from waleedahmad/downtime.py
Python script to monitor your internet down time
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
import csv
import sys
import time
import socket
import datetime
@trashvin
trashvin / Module1.vb
Last active November 10, 2019 16:08
List processing example VB.NET
Imports System.IO
Imports System.Collections.Generic
Imports System.Xml
Module Module1
Sub Main()
' Read the sample file and populate list
Dim taxes As List(Of Tax) = GetData("xDataSample.txt")