Skip to content

Instantly share code, notes, and snippets.

View txdv's full-sized avatar

Andrius Bentkus txdv

View GitHub Profile
@txdv
txdv / Makefile
Last active March 23, 2016 01:27 — forked from mhanne/Makefile
libotr usage example
all: example
example: example.c
gcc example.c -lotr -o example
.PHONY: clean
clean:
rm -f example
@txdv
txdv / gist:5474093
Created April 27, 2013 18:30
orphan commit creation
var blob = repo.ObjectDatabase.CreateBlob("index.txt");
var treeDefinition = new TreeDefinition();
treeDefinition.Add("index.txt", blob, Mode.NonExecutableFile);
var tree = repo.ObjectDatabase.CreateTree(treeDefinition);
var commit = repo.ObjectDatabase.CreateCommit("Hello World",
new Signature("name", "mail", DateTimeOffset.Now),
new Signature("name", "mail", DateTimeOffset.Now),
tree, new Commit[0]);
@txdv
txdv / TimesExtensions.cs
Created November 13, 2012 13:50
Times extension for .net numbers
using System;
namespace System
{
public static class TimesExtensions
{
public static void Times(this byte times, Action cb)
{
times.Times((i) => { cb(); });
}

This is my awesome c code:

#include <stdio.h>

int main(void) {
   return 0;
}
@txdv
txdv / dynamic-delegates.cs
Created April 14, 2012 12:39
Dynamic delegates!
using System;
using System.Reflection;
using System.Linq;
namespace testing
{
class DynamicDelegate
{
public MethodInfo Method { get; protected set; }
public string Name { get; protected set; }
@txdv
txdv / test.c
Created January 26, 2012 00:50
Example of the code I want to get going.
#include <ncurses.h>
int main(int argc, char **argv)
{
int i;
char buffer[512];
initscr();
nonl();
cbreak();
@txdv
txdv / bot.cs
Created August 7, 2011 21:15
Example of custom bot for smartirc4net
using System;
using System.Collections.Generic;
using Manos.IO;
using Meebey.SmartIrc4net;
using SmartIrcBot4net;
namespace Test
{
public class AdminPlugin : IrcBotPlugin
@txdv
txdv / ByteBufferCollection.csproj
Created August 6, 2011 21:54
ByteBufferCollection
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{34F9CC9C-7FA8-4C7C-B21B-139A0C1B56FD}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ByteBufferCollection</RootNamespace>
@txdv
txdv / gist:1093861
Created July 19, 2011 22:08
Manos.MySql API proposals
public static void Proposal1(Context context)
{
// Old school C# style!
// Has the ability to actually remove those events afterwards!.
MySqlConnector.Connect(context, "test", "test", "password", (stream) => {
var cmd = stream.Query("SELECT name, surname FROM people where city = 'Aachen'");
cmd.OnRow += (row) => {
Console.WriteLine("{0} {1}", row.name, row[1]);
});
cmd.OnEnd += () => {
@txdv
txdv / gist:1086482
Created July 16, 2011 15:57
API example of my Manos BinaryStreamReader.
namespace NiceParsing
{
class MainClass
{
public static void Main(string[] args)
{
var packetWrapper = new {
Length = 3,
Number = typeof(byte)
};