Skip to content

Instantly share code, notes, and snippets.

View shalithasuranga's full-sized avatar

Shalitha Suranga shalithasuranga

View GitHub Profile
const tree = JSON.parse(`...`); // Add JSON here.
function dfs(node) {
if(!node)
return;
console.log(node.v);
dfs(node.a);
dfs(node.b);
}
{
"v": 21,
"a": {
"v": 15,
"a": {
"v": 200,
"a": {
"v": 12
},
"b": {
@shalithasuranga
shalithasuranga / cli.zig
Last active July 26, 2023 08:05
A simple CLI written in Zig using only std
const std = @import("std");
const stdout = std.io.getStdOut().writer();
fn print_help() !void {
try stdout.print("{s}\n" , .{"-" ** 25});
try stdout.print("0: Exit\n", .{});
try stdout.print("1: Show help\n", .{});
try stdout.print("2: Print Node.js version\n", .{});
try stdout.print("{s}\n" , .{"-" ** 25});
}
Widget _renderSteps(List<Step> steps) {
return ExpansionPanelList.radio(
children: steps.map<ExpansionPanelRadio>((Step step) {
return ExpansionPanelRadio(
headerBuilder: (BuildContext context, bool isExpanded) {
return ListTile(
title: Text(step.title),
);
},
body: ListTile(
jobs:
build-linux-arm64:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run
uses: uraimo/run-on-arch-action@v2
id: build-package
with:
def get_short_name(full_name):
names = full_name.split(' ')
short_name = ''
for i in range(len(names)):
if i < len(names) - 1:
short_name += names[i][0] + '. '
else:
short_name += names[i]
return short_name;
function get_short_name() {
short_name=''
for i in ${!fullname[@]}; do
if ((i < ${#fullname[@]} - 1)); then
short_name+="${fullname[i]::1}. "
else
short_name+=${fullname[i]}
fi
done
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
import { useState } from 'react';
import InputMask from 'react-input-mask';
function TimeInput(props) {
let mask = 'dD-mM-YYYY';
let formatChars = {
'Y': '[0-9]',
'd': '[0-3]',
'D': '[0-9]',
'm': '[0-1]',