Skip to content

Instantly share code, notes, and snippets.

View AndriiTsok's full-sized avatar
💡
Creating

Andrii Tsok AndriiTsok

💡
Creating
View GitHub Profile
@AndriiTsok
AndriiTsok / sanfrancisco-font.css
Created October 19, 2015 19:57 — forked from bivainis/sanfrancisco-font.css
San Francisco Web Font
/**
* http://applemusic.tumblr.com/
*/
/** Ultra Light */
@font-face {
font-family: "San Francisco";
font-weight: 100;
src: url("https://applesocial.s3.amazonaws.com/assets/styles/fonts/sanfrancisco/sanfranciscodisplay-ultralight-webfont.woff2");
}
@AndriiTsok
AndriiTsok / global.json
Last active October 30, 2015 10:17
The global.json file is used to configure the solution as a whole. It includes just two sections, projects and sdk by default.
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-beta8"
}
}
@AndriiTsok
AndriiTsok / ASP.NET 5 Routing
Last active October 31, 2015 13:36
cookbook part
todo
@AndriiTsok
AndriiTsok / ASP.NET 5 CORS settings
Created October 31, 2015 13:36
Everything that can help to configure Cross Origin Resource Sharing
todo
@AndriiTsok
AndriiTsok / ASP.NET 5 .travis.yml
Last active November 1, 2015 09:29
Travis-CI build configuration for asp.net 5 project
language: CSharp
mono:
- latest
install:
- curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh
- dnvm upgrade
- dnu restore
script:
- dnx -p ./test/[testProjectName]/project.json test -parallel none
@AndriiTsok
AndriiTsok / JWT example
Created November 3, 2015 12:17
JWT generate and verify
// don't use this code as-is in production scince ValidateSignature is false
app.Use(async (context, next) =>
{
var authType = IdentityOptions.ApplicationCookieAuthenticationType;
var authScheme = IdentityOptions.ApplicationCookieAuthenticationScheme;
if (context.Request.Path.ToString().ToLower() == "/token")
{
// Generate Token
if (!context.Request.HasFormContentType || !context.Request.Form.ContainsKey("username") || !context.Request.Form.ContainsKey("password"))
{
@AndriiTsok
AndriiTsok / AuthServiceConfig.config
Created November 3, 2015 12:56
ASP.NET 5 Identity configuration file.
{
"DefaultAdminUsername": "Administrator",
"DefaultAdminPassword": "12345",
"Data": {
"IdentityConnection": {
"Connectionstring": "Server=(localdb)\\mssqllocaldb;Database=IdentityMvc-2-20-15-3;Trusted_Connection=True;MultipleActiveResultSets=true"
}
},
"Identity": {
"Password": {
@AndriiTsok
AndriiTsok / EF migrations
Created November 3, 2015 15:02
EF migrations
Now that you have a model, you can use migrations to create a database for you.
Open a command prompt (Windows Key + R, type cmd, click OK)
Use the cd command to navigate to the project directory
Run dnvm use 1.0.0-beta8
Run dnx ef migrations add MyFirstMigration to scaffold a migration to create the initial set of tables for your model.
Run dnx ef database update to apply the new migration to the database. Because your database doesn’t exist yet, it will be created for you before the migration is applied.
@AndriiTsok
AndriiTsok / BindableProperty.cs
Last active November 6, 2015 10:13
Implementation of bindable properties in Xamarin.Forms
///<summary>
///Provides a property that we can bind view model properties to. Notice that the name of the property
///follows the pattern of the using the instance property name followed by the word Property.
//</summary>
public static BindableProperty LeftTitleProperty =
BindableProperty.Create<CustomHeaderBox, string>(ctrl => ctrl.LeftTitle,
defaultValue: string.Empty,
defaultBindingMode: BindingMode.TwoWay,
propertyChanging: (bindable, oldValue, newValue) => {
var ctrl = (CustomHeaderBox)bindable;
@AndriiTsok
AndriiTsok / TypeSwitch.cs
Created November 8, 2015 08:01
Switch by type
static class TypeSwitch {
public class CaseInfo {
public bool IsDefault { get; set; }
public Type Target { get; set; }
public Action<object> Action { get; set; }
}
public static void Do(object source, params CaseInfo[] cases) {
var type = source.GetType();
foreach (var entry in cases) {