Skip to content

Instantly share code, notes, and snippets.

tluyben

Block or report user

Report or block tluyben

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Printstructure.cs
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)
{
@tluyben
tluyben / backup.sh
Created Mar 10, 2019
automatically update wp
View backup.sh
#!/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]} .
@tluyben
tluyben / FindType.cs
Created Sep 9, 2018
Type.GetType(string t) without having the full name
View FindType.cs
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
{
foreach(var _t in a.GetTypes())
{
if (_t.Name == t)
{
return _t;
}
}
}
@tluyben
tluyben / Forth1.cs
Last active Aug 24, 2019
A minimal Forth implementation in C#
View Forth1.cs
/*
* Minimal .NET Forth implementation. Just an experiment. Do not use for anything serious.
* by Tycho Luyben (https://github.com/tluyben)
*
* The only 'primitive' (built-in) is an foreign function interface word which allows you to define
* whatever is needed, for example:
*
* hello System.String System.Console.WriteLine ffi
*
* will print hello.
@tluyben
tluyben / cli.go
Created May 5, 2018
Calculate WIF from a private key
View cli.go
package main
import (
"fmt"
"os"
"encoding/hex"
"github.com/mr-tron/base58/base58"
)
func main() {
@tluyben
tluyben / background.cs
Last active Nov 30, 2017
Hangfire actions without all the serialization issues (won't survive server restart or multiple servers, but easier to make that work as well)
View background.cs
Random r = new Random();
static ConcurrentDictionary<int, Action> actions = new ConcurrentDictionary<int, Action>();
public static void ExecuteAction(int i)
{
Action a;
actions.Remove(i, out a);
a();
}
@tluyben
tluyben / Placeholder.cs
Created Jun 5, 2017
Placeholder Winforms
View Placeholder.cs
class InternalTextBox : MaskedTextBox
{
bool _PlaceholderHandled = false;
void DoPlaceholder()
{
if (Placeholder.Length > 0 && this.Text == string.Empty && this.Text != this.Placeholder)
{
@tluyben
tluyben / frmFlowChart.cs
Created Apr 28, 2017
Short how to use OpenDiagram Flowchart
View frmFlowChart.cs
Model model = diagram1.Model;
diagram1.Model.SetSize(new Size(1000, 1000));
Shape shape = new Shape();
shape.Location = new PointF(10, 20);
//model.Shapes.Add("a1", shape);
Flowchart f = (Flowchart)diagram1;
shape = f.AddFlowShape(shape.Location, FlowchartStencilType.Terminator);
shape.Label = new Label("kaas");
@tluyben
tluyben / XMLExtensions.cs
Created Apr 7, 2017
Handy XML extensions
View XMLExtensions.cs
using System;
using System.Xml;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
namespace test1
{
public static class XMLExtensions
{
You can’t perform that action at this time.