Skip to content

Instantly share code, notes, and snippets.

View nirlanka's full-sized avatar

Nir Lanka nirlanka

  • SGX
  • Singapore
View GitHub Profile
@nirlanka
nirlanka / simple-csharp-parser.py
Last active December 9, 2019 13:42
A quick & simple high-level parser for C# code (C# code that's standard-formatted)
lines = '''
using Abc.Def;
namespace Abc.Hijk
{
public class Haha: ILaugh
{
public Haha()
{
// Constructor
@nirlanka
nirlanka / TestOne.cs
Last active April 10, 2022 21:35
A simple set of macros for C# codebases
using Abc;
public class One
{
public void Foo()
{
// macro: set ClassName // Changes the assigned default or any value in the line below
string className = default;
Console.WriteLine(className + " Foo");
@nirlanka
nirlanka / csharp-code-replace-eg.py
Created December 5, 2019 07:24
An example script for replacing code in a C# project
## // e.g.
## MBOverlay mbOverlay = UIUtil.GetBusyOverlay(AppStrings.LoadRevision);
## --> VML.LoaderViewModel.Add($"DoorSideBar-{AppStrings.LoadRevision}", Models.ActivityType.API, message: AppStrings.LoadRevision, activitySeverity: Models.ActivitySeverity.High);
## mbOverlay.Hide();
## --> VML.LoaderViewModel.Remove($"DoorSideBar-{AppStrings.LoadRevision}");
## // AppStrings.LoadRevision, Properties..., "", messages: List<string>
import os, re
# files = [f for f in os.listdir('.') if os.path.isfile(f)]
@nirlanka
nirlanka / git-clearHistory.sh
Last active November 20, 2019 18:42 — forked from stephenhardy/git-clearHistory
Steps to clear out the history of a git/github repository
# Remove the history from
rm -rf .git
# recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
# push to the github remote repos ensuring you overwrite history
git remote add origin [email protected]:<account>/<repo>.git
@nirlanka
nirlanka / flags.cs
Created November 19, 2019 04:14
Answers to some simple C# questions I got for an interview
// Each account on a website has a set of access flags that represent a user's access.
//
// Update and extend the enum so that it contains three new access flags:
//
// [Flags]
// public enum Access
// {
// Delete = 1,
// Publish = 2,
// Submit = 3,
@nirlanka
nirlanka / minimal-test.cs
Last active November 16, 2019 19:17
SublimeText3 CSharp runner and builder for Linux and OS X using installed Mono development environment
using System;
class Test
{
static void Main()
{
Console.WriteLine("Hello Sublime");
}
}
@nirlanka
nirlanka / html-structure.html
Created October 17, 2019 08:46
Add this style to any web page's header through dev-tools to see the structure of the layout.
<style>body * { background-color: rgba(0,0,100, .2) !important; outline: rgba(0,100,0, .2) !important; }</style>
@nirlanka
nirlanka / lisp-like.js
Last active September 14, 2019 14:13
A simple lisp-like language/interpreter written in pure javascript, using javascript arrays, without any dependencies. UPDATE: I'll be continuing work on this repository: https://github.com/nirlanka/ao
(function () {
const __inp = `
((defun foo (a b)
(* a b))
(print (foo 2 3))
(defun bar (a b c) (foo
(foo a b)
c))
(print (bar 4 5 6))
@nirlanka
nirlanka / password-cracker.py
Created August 7, 2019 16:30
Answer to Hackerrank challenge "Password Cracker", which is correct, but not the expected answer in some test cases ¯\_(ツ)_/¯ (https://www.hackerrank.com/challenges/password-cracker/forum)
#!/bin/python3
DEBUG = False
import math
import os
import random
import re
import sys
#!/bin/python3
DEBUG = False
import os
import sys
def trie_find(node, path):
if not node.get(path[0]):
return 0