Skip to content

Instantly share code, notes, and snippets.

View co89757's full-sized avatar

gueuz co89757

  • United States
View GitHub Profile
@co89757
co89757 / Makefile
Created December 2, 2019 07:56 — forked from isaacs/Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
global !p
def complete(t, opts):
if t:
opts = [o[len(t):] for o in opts if o.startswith(t)]
if len(opts) == 1:
return opts[0]
return "(" + "|".join(opts) + ")"
endglobal
# snippt option b means only enable at begin of line
@co89757
co89757 / tmux-cheatsheet.markdown
Created March 12, 2019 06:30 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@co89757
co89757 / UrlBuilder.cs
Created January 26, 2019 13:09
generate url link from route template and routedictionaryvalues in .net core
using Microsoft.AspNetCore.Routing.Template;
using Microsoft.AspNetCore.Routing;
using System.Text.Encodings.Web;
using Microsoft.Extensions.ObjectPool;
using Microsoft.AspNetCore.Routing.Internal;
namespace chat
{
public class UrlBuilder
{
public static string BuildUri(string routeTemplate, RouteValueDictionary values ){
@co89757
co89757 / ProducerConsumer.cs
Last active November 27, 2018 07:58
a simple abstract class for P-C model processing
namespace DEMon
{
/// <summary>
/// Abstract class to faciliate the construction of processors that follow producer-consumer pattern.
/// Example: typical invokation sequence
/// ProducerConsumer.Init()
/// ProducerConsumer.Add(work_item)
/// ProducerConsumer.CompleteAndWait();
/// </summary>
/// <typeparam name="T">type of the work item</typeparam>
@co89757
co89757 / vim_cheatsheet.md
Created February 13, 2018 08:02 — forked from awidegreen/vim_cheatsheet.md
Vim shortcuts

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
@co89757
co89757 / tutorial.cmd
Last active November 19, 2017 00:30
batch scripting
@ECHO OFF
REM turn this on to enable loop-scope variable expansion (at exec time, rather than parse-time)
SETLOCAL ENABLEDELAYEDEXPANSION
SET me=%~n0
SET parent=%~dp0
::======= HEADER END =====
REM gotcha: to set variables whose value contain spaces
SET 'V=I HAVE SPACE'
ECHO %V%
@co89757
co89757 / ProgressBar.cs
Last active September 26, 2020 19:36
ProgressBar in Console C#
using System;
using System.Text;
using System.Threading;
/// <summary>
/// An ASCII progress bar
/// </summary>
public class ProgressBar : IDisposable, IProgress<double> {
private const int blockCount = 10;
private readonly TimeSpan animationInterval = TimeSpan.FromSeconds(1.0 / 8);
@co89757
co89757 / PeriodicAction.cs
Created October 24, 2017 17:38
C# periodic action
using System;
using System.Threading;
using Utility;
/// <summary>
/// Encapsulates a mechanism for executing an action continuously with a specified interval.
/// </summary>
/// <remarks>
/// Large portions copied from a class of the same name made by Markus.
/// </remarks>
@co89757
co89757 / learn_awk.md
Created July 19, 2017 19:23
awk tutorial

Conditional Filter Rules in awk

the general form is

pattern {_action }

Filter based on regex

/<regex>/ {
	#actions