Skip to content

Instantly share code, notes, and snippets.

View zaverden's full-sized avatar
💭
Do IT

Denis Zavershinskiy zaverden

💭
Do IT
View GitHub Profile
$key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced'
Set-ItemProperty $key LaunchTo 1 # Open File Explorer to "This PC" (not "Quick access")
Set-ItemProperty $key Hidden 1 # Hidden files and folders set to "Show hidden files, folder and drives"
Set-ItemProperty $key HideFileExt 0 # Unckeck Hide extensions for known file types
Set-ItemProperty $key ShowSuperHidden 1 # Unckeck Hide protected operting system files
Set-ItemProperty $key TaskbarGlomLevel 1 # Combine taskbar buttons when taskbar is full
Stop-Process -processname explorer # restart Explorer to apply changes
namespace MyProject.Models
{
public class MyModel // class: PascalCase
{
private readonly string _myField; // private field: _camelCaseWithPrefix
public MyModel(string defaultFieldValue) // param: camelCase
{
_myField = defaultFieldValue;
}
public string MyProperty => _myField; // property: PascalCase
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
namespace SomeProject
{
public static class IQueryableExtensions
{
public static IOrderedQueryable<T> OrderBy<T>(this IQueryable<T> source, string ordering, bool desc = false)
using System;
using System.Collections.Generic;
using System.Linq;
namespace SomeProject
{
public class ListOptions
{
public ListOptions() : this(PageSizeValue.Default) { }
public ListOptions(PageSizeValue pageSize) : this(pageSize.AsInt32()) { }
@zaverden
zaverden / AuthenticationBuilderExtensions.cs
Created December 7, 2017 09:02
ASP.NET Core 2 AddGithub OAuth extension
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Claims;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.OAuth;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json.Linq;
@zaverden
zaverden / git-recheckout.sh
Last active March 26, 2018 10:24
remove a local copy of a remote branch and checkout the latest version
#!/bin/sh
#source "$(git --exec-path)/git-sh-setup"
targetBranch="$1"
# get current branch to return to it
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
# if current branch is target
if [ "$branch" = "$targetBranch" ]; then
if [ "--force" != "$2" ]; then
echo "Error: you try to recheckout current branch. Use --force"
exit 1
node -e "require('http').createServer((req, res)=>res.write('Hello World',()=>res.end())).listen(3000);"
CERTS_PATH="/path/to/certs"
HOST="my.example.com"
EMAIL="email@example.com"
DOCKER_SOCK="/var/run/docker.sock"
docker run \
--name nginx-proxy \
--detach=true \
--publish 80:80 \
--publish 443:443 \
const moo = require('moo');
const Time = require('./time');
const parser = moo.compile({
VAR: {
match: /{[a-zA-Z_]\w*}/,
keywords: { PREDEF: ['{today}'] } // predefined keywords
},
OP: ['and', 'or', '+', 'at'],
DAY: {
// nodejs v8.9.4
// yarn add evernote@2.0.5
const Evernote = require('evernote');
const client = new Evernote.Client({ token: 'put-your-token-here', sandbox: false });
const store = client.getNoteStore();
process.on('uncaughtException', (err) => {
console.log({ source: 'uncaughtException', err });
process.exit(1);
});