This file contains hidden or 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
private T GetContext<T>() where T : DbContext | |
{ | |
var options = new DbContextOptionsBuilder<T>().UseNpgsql(connection).Options; | |
return (T) typeof(T).GetConstructor(new Type[] { typeof(DbContextOptions<T>) }).Invoke(new object[] { options }); | |
} |
This file contains hidden or 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
/// <summary> | |
/// Copy every matching property from source -> target | |
/// </summary> | |
/// <param name="target"></param> | |
/// <param name="source"></param> | |
public static void Slurp(this object target, object source) | |
{ | |
target.GetType() | |
.GetProperties() | |
.Where(p => p.SetMethod != null) |
This file contains hidden or 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
const int RETRIES = 3; | |
void Retry(Action f) | |
{ | |
for (int i = 0; i < RETRIES; i++) | |
{ | |
try | |
{ | |
f(); | |
} |
This file contains hidden or 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
#!/usr/bin/perl | |
# enable query log for mysql | |
open(F, "tail -f ~/query.log|"); | |
while(<F>){ | |
chomp; | |
if (/\d+\s+Execute\s+(select.*)$/igsm) { | |
print "\n\nQuery: $1 : \n"; | |
$qry = $1; | |
$qry =~ s/\`/\\\`/isgm; |
This file contains hidden or 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 Avalonia.Controls; | |
using Avalonia.Markup.Xaml; | |
using System.Collections.Generic; | |
using System.Linq; | |
using Avalonia.Data; | |
using Avalonia.Controls.Templates; | |
using Avalonia.Controls.Primitives; | |
using System; | |
namespace Playground |
This file contains hidden or 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 Avalonia.Controls; | |
using Avalonia.Markup.Xaml; | |
using System.Collections.Generic; | |
using System.Linq; | |
using Avalonia.Data; | |
using Avalonia.Controls.Templates; | |
namespace Playground | |
{ | |
public class ListItem |
This file contains hidden or 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
public static string PrintStructure(this VisualElement obj, string indent = "") | |
{ | |
if (obj == null) return ""; | |
var ot = obj.GetType().GetTypeInfo(); | |
var s = indent + ot.Name + " ["; | |
if (obj.StyleId != null && obj.StyleId.Length > 0) | |
{ |
This file contains hidden or 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
#!/bin/bash | |
export PATH=/usr/local/wp-cli/bin:$PATH | |
[[ $@ =~ ^\/home\/(.*?)\/www ]]; | |
cp updatewp_user.sh $@ | |
cd $@ | |
echo $@ | |
chown -R ${BASH_REMATCH[1]}.${BASH_REMATCH[1]} . |
This file contains hidden or 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
iptables -I INPUT -p tcp ! -s x.x.x.x --dport 8545 -j DROP |
This file contains hidden or 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
foreach (var a in AppDomain.CurrentDomain.GetAssemblies()) | |
{ | |
foreach(var _t in a.GetTypes()) | |
{ | |
if (_t.Name == t) | |
{ | |
return _t; | |
} | |
} | |
} |