This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace Mvvm | |
{ | |
public class Ioc | |
{ | |
private static Dictionary<Type, object> classes = new Dictionary<Type, object>(); | |
public static void Register<T>(params object[] parameters) where T : class | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"net/http" | |
"os" | |
"os/signal" | |
"time" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
go func() { | |
reader := bufio.NewReader(os.Stdin) | |
for { | |
input, _, err := reader.ReadLine() | |
if err != nil { | |
fmt.Printf("could not process input %v\n", input) | |
} | |
switch string(input) { | |
case "hello": | |
fmt.Println("hello world") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// place into ~/.config/systemd/user/your-service-file.service | |
// more info: https://www.unixsysadmin.com/systemd-user-services/ | |
[Unit] | |
Description=Run dummy service as user X | |
DefaultDependencies=no | |
After=network.target | |
[Service] | |
Type=simple |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
var ( | |
env string | |
) | |
func main() { | |
flag.StringVar(&env, "e", "dev", "The environment to run at (prod, test, dev)") | |
flag.Parse() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type myStruct struct { | |
id int | |
messages []Message | |
} | |
type Message struct { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func populateTemplates(fm template.FuncMap) map[string]*template.Template { | |
result := make(map[string]*template.Template) | |
const basePath = "templates" | |
layout := template.Must(template.ParseFiles(basePath + "/_layout.html")).Funcs(fm) | |
dir, err := os.Open(basePath + "/content") | |
if err != nil { | |
panic("failed to open template base directory: " + err.Error()) | |
} | |
defer dir.Close() | |
fis, err := dir.Readdir(-1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// inspired by https://gist.github.com/samuel/8b500ddd3f6118d052b5e6bc16bc4c09 | |
func generateSelfSignedCert(certPath string, keyPath string) { | |
// priv, err := rsa.GenerateKey(rand.Reader, *rsaBits) | |
priv, err := ecdsa.GenerateKey(elliptic.P521(), rand.Reader) | |
if err != nil { | |
log.Fatal(err) | |
} | |
template := x509.Certificate{ | |
SerialNumber: big.NewInt(time.Now().UnixNano()), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Linq.Expressions; | |
namespace Core.Repositories | |
{ | |
public abstract class GenericRepository<T> : IRepository<T> where T : class | |
{ | |
protected MyDbContext context; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace ConcurrencyTests | |
{ | |
public class ConcurrentList<T> | |
{ | |
private List<T> internalList = new List<T>(); | |
private object listLock = new object(); |