Skip to content

Instantly share code, notes, and snippets.

View yehudamakarov's full-sized avatar
🎯
Focusing

Yehuda Makarov yehudamakarov

🎯
Focusing
View GitHub Profile
@yehudamakarov
yehudamakarov / iis.ps1
Created February 15, 2022 23:31
IIS Stuff
net stop /y was
net start w3svc
@yehudamakarov
yehudamakarov / roles.sql
Created April 26, 2021 20:46
user permissions in sql
DECLARE @login NVARCHAR(256), @user NVARCHAR(256);
SELECT @login = login_name FROM sys.dm_exec_sessions WHERE session_id = @@SPID;
SELECT @user = d.name
FROM sys.database_principals AS d
INNER JOIN sys.server_principals AS s
ON d.sid = s.sid
WHERE s.name = @login;
package main
import "fmt"
func main() {
slc := []int{1,2}
adjustSlice(slc)
fmt.Println(slc)
map1 := make(map[int]int)
adjustMap(map1)
@yehudamakarov
yehudamakarov / encrypt-decrypt.sh
Created June 24, 2019 22:18
[gcloud] gcloud commands
gcloud kms encrypt --location global \
--keyring test --key quickstart \
--plaintext-file mysecret.txt \
--ciphertext-file mysecret.txt.encrypted
gcloud kms decrypt --location global \
--keyring test --key quickstart \
--ciphertext-file mysecret.txt.encrypted \
--plaintext-file mysecret.txt.decrypted
@yehudamakarov
yehudamakarov / GetAllInstances.cs
Last active June 24, 2019 22:16
[GetAllInstances] Gets a list of the specified type's values from an object.
public static List<T> GetAllInstances<T>(object value) where T : class
{
var exploredObjects = new HashSet<object>();
var found = new List<T>();
FindAllInstances(value, exploredObjects, found);
return found;
}
@yehudamakarov
yehudamakarov / System Design.md
Created May 14, 2019 01:07 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@yehudamakarov
yehudamakarov / BL.cs
Last active May 3, 2019 02:16
[JWT in .Net Core] basic JWT implementation with roles
public class AuthenticationBL : IAuthenticationBL
{
private readonly IAuthenticationRepository _authenticationRepository;
private readonly IConfiguration _configuration;
public AuthenticationBL(IAuthenticationRepository authenticationRepository, IConfiguration configuration)
{
_authenticationRepository = authenticationRepository;
_configuration = configuration;
@yehudamakarov
yehudamakarov / my-connected-component.tsx
Last active May 3, 2019 01:59 — forked from aheitzmann/my-connected-component.tsx
[Typed Connected Components] A best practice pattern for defining and using typescript types for a redux-react connected component
import * as React from 'react'
import * as Redux from 'redux'
import { MyReduxState } from './my-root-reducer.ts'
export interface OwnProps {
propFromParent: number
}
interface StateProps {
@yehudamakarov
yehudamakarov / symlink.md
Created January 16, 2019 15:43
[CMD] cmd commands for windows

The problem is that it's risky, because your local changes are seen by git as diffs relative to the current branch tip, but those diffs may not be applicable to the other branch. For instance if you added a line after an existing line, and that line doesn't exist on the other branch, git won't know what to do From the command line you can do git checkout -m branch which attempts a "merge" algorithm, which may work, or else give you a mess of merge conflict markers Otherwise you can stash your changes, and pop them back later git stash (...later...) git stash pop (git stash pop can result in merge conflicts if you aren't in the same state your were when you stashed it. If so you get the merge conflicts to resolve, and the stash remains on the stack too.) The third option is to erase your changes. You can do that from the command line with git checkout. git checkout -p will prompt you before reverting each change, so you can be sure you're not throwing away anything important.

I think (not sure) `g