Elian  Harber

Elian Harber

1664976900

Gfmrun: GitHub-Flavored Markdown Runner

gfmrun

A (GitHub-Flavored Markdown Runner). Runs stuff inside code gates (maybe!).

This project is not intended to fully replace the example code running capabilities of any given language's tooling, but instead to fill a gap. In the case of a Go repository, for example, it can be handy to have some verifiable code examples in the README.md and example functions in *_test.go files.

Explicitly Supported Languages

Bash

If a code example has a declared language of bash, then gfmrun will write the source to a temporary file and run it via whatever executable is first in line to respond to bash.

for i in {97..99} ; do
  echo "$i problems" >&2
done

echo "Begot by all the supernova (${0})"
exit 0

Go

If a code example has a declared language of go and the first line is package main, then gfmrun will write the source to a temporary file, build it, and run it. It is worth noting that go run is not used, as this executes a child process of its own, thus making process management and exit success detection all the more complex.

package main

import (
  "fmt"
  "os"

  "golang.org/x/example/stringutil"
)

func main() {
  fmt.Printf("---> %v\n", os.Args[0])
  fmt.Println("we could make an entire album out of this one sound")
  fmt.Println(stringutil.Reverse("[SQUEAK INTENSIFIES]"))
}
package main

import (
  "log"
)

func main() {
  log.Fatal("we can handle errors too")
}

Java

If a code example has a declared language of java and a line matching ^public class ([^ ]+), then gfmrun will write the source to a temporary file, build it, and run the class by name.

public class GalacticPerimeter {
  public static void main(String[] args) {
    System.out.println(System.getenv("FILE"));
    System.out.println("Awaken the hive");
  }
}

JavaScript (assumed node.js compatible)

If a code example has a declared language of javascript, then gfmrun will write the source to a temporary file and run it via whatever executable is first in line to respond to node.

var main = function() {
  console.log("they won't stop at dancin, no");
  console.log("they won't stop at dancin");
};

if (require.main == module) {
  main();
}

JSON

If a code example has a declared language of json, then gfmrun will write the source to a temporary file and "run" it via the node executable for validation.

{
  "no": "output",
  "levels": [
    8000,
    9000,
    9001
  ]
}

Python

If a code example has a declared language of python, then gfmrun will write the source to a temporary file and run it via whatever executable is first in line to respond to python.

from __future__ import print_function

import sys


def main():
    print('lipstick ringo dance all night {!r}!'.format(sys.argv))
    return 0


if __name__ == '__main__':
    sys.exit(main())

Ruby

If a code example has a declared language of ruby, then gfmrun will write the source to a temporary file and run it via whatever executable is first in line to respond to ruby.


def main
  puts $0
  puts "get out of the path of the king"
  return 0
end

if $0 == __FILE__
  exit main
end

Shell

If a code example has a declared language that can be mapped to the linguist definition of shell, then gfmrun will write the source to a temporary file and run it via whatever executable is first in line to respond to bash.

if [ 0 -eq 0 ] ; then
  echo "Just the way you like it, yes"
  echo "just the way you like it. (${0})"
fi
exit 0

Sh

If a code example has a declared language of sh, then gfmrun will write the source to a temporary file and run it via whatever executable is first in line to respond to sh.

if [ 5 -eq 3 ] ; then
  echo "YOU FOUND THE MARBLE IN THE OATMEAL"
else
  echo "Saddle up preacher, don't look back. (${0})"
fi
exit 0

Zsh

If a code example has a declared language of zsh, then gfmrun will write the source to a temporary file and run it via whatever executable is first in line to respond to zsh.

printf "Kiss me.\nJust kiss me.\n(${0})\n"

bye 0

Implicitly Supported Languages

If a code example's declared language can be matched to one of the explicitly supported languages listed above via the linguist languages definition, then the matched language's runner will be used.

This example declares node, but will be run via the javascript frob, which happens to use the node executable anyway:

if (1 / 1 == 1) {
  console.log("kiss me, Nefertiti");
}

Disabling automatic download of languages.yml

By default, the linguist languages definition is downloaded if not present. This behavior can be disabled by passing the --no-auto-pull / -N flag or setting a GFMRUN_NO_AUTO_PULL=true environment variable.

Tag annotation comments

gfmrun supports the use of JSON tags embedded in comments preceding code blocks, e.g. (just pretend ^ are backticks):

<!-- { "awesome": "maybe", "all on one line": "yep" } -->
^^^ go
package lolmain
// ... stuff
^^^
<!-- {
  "wow": "cool",
  "multiple": "lines"
} -->
^^^ go
package lolmain
// ... stuff
^^^
<!-- {
  "super": "advanced",
  "whitespace after the comment": "mindblown"
} -->


^^^ go
package lolmain
// ... stuff
^^^

"output" tag

Given a regular expression string value, asserts that the program output (stdout) matches.

"error" tag

Given a regular expression string value, asserts that the program error (stderr) matches.

"args" tag

Given a string array, run the program with the value as command line arguments.

"interrupt" tag

Given either a truthy or duration string value, interrupts the program via increasingly serious signals (INT, HUP, TERM, and finally KILL). If the value is truthy, then the default duration is used (3s). If the value is a string duration, then the parsed duration is used. This tag is intended for use with long-lived example programs such as HTTP servers.

"os" tag

Given either a string or array of strings, skips the program if the current OS does not match. When absent, no filter is applied.

Examples

No tag annotations, expected to be short-lived and exit successfully:

var _ = 1 / 1;

Annotated with an "output" JSON tag that informs gfmrun to verify the example program's output:

console.log("Ohai from the land of GitHub-Flavored Markdown :wave:");

Annotated with an "interrupt" JSON tag that informs gfmrun to interrupt the example program after a specified duration, which implies that the exit code is ignored (not Windows-compatible):

package main

import (
  "fmt"
  "net/http"
)

func main() {
  http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
    w.WriteHeader(http.StatusOK)
    fmt.Fprintf(w, "Why Hello From Your Friendly Server Example :bomb:\n")
  })
  http.ListenAndServe(":8990", nil)
}

Similar to the above example, but the "interrupt" tag is truthy rather than a specific interval, which will result in the default interrupt duration being used (3s). It is also annotated with an "output" tag that takes precedence over the "interrupt" tag's behavior of ignoring the exit code:

package main

import (
  "fmt"
  "net/http"
)

func main() {
  http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
    w.WriteHeader(http.StatusOK)
    fmt.Fprintf(w, "Hello Again From Your Friendly Server Example :bomb:\n")
  })
  fmt.Println(":bomb:")
  http.ListenAndServe(":8989", nil)
}

Download Details:

Author: urfave
Source Code: https://github.com/urfave/gfmrun 
License: MIT license

#go #golang #markdown #github 

What is GEEK

Buddha Community

Gfmrun: GitHub-Flavored Markdown Runner
Elian  Harber

Elian Harber

1664976900

Gfmrun: GitHub-Flavored Markdown Runner

gfmrun

A (GitHub-Flavored Markdown Runner). Runs stuff inside code gates (maybe!).

This project is not intended to fully replace the example code running capabilities of any given language's tooling, but instead to fill a gap. In the case of a Go repository, for example, it can be handy to have some verifiable code examples in the README.md and example functions in *_test.go files.

Explicitly Supported Languages

Bash

If a code example has a declared language of bash, then gfmrun will write the source to a temporary file and run it via whatever executable is first in line to respond to bash.

for i in {97..99} ; do
  echo "$i problems" >&2
done

echo "Begot by all the supernova (${0})"
exit 0

Go

If a code example has a declared language of go and the first line is package main, then gfmrun will write the source to a temporary file, build it, and run it. It is worth noting that go run is not used, as this executes a child process of its own, thus making process management and exit success detection all the more complex.

package main

import (
  "fmt"
  "os"

  "golang.org/x/example/stringutil"
)

func main() {
  fmt.Printf("---> %v\n", os.Args[0])
  fmt.Println("we could make an entire album out of this one sound")
  fmt.Println(stringutil.Reverse("[SQUEAK INTENSIFIES]"))
}
package main

import (
  "log"
)

func main() {
  log.Fatal("we can handle errors too")
}

Java

If a code example has a declared language of java and a line matching ^public class ([^ ]+), then gfmrun will write the source to a temporary file, build it, and run the class by name.

public class GalacticPerimeter {
  public static void main(String[] args) {
    System.out.println(System.getenv("FILE"));
    System.out.println("Awaken the hive");
  }
}

JavaScript (assumed node.js compatible)

If a code example has a declared language of javascript, then gfmrun will write the source to a temporary file and run it via whatever executable is first in line to respond to node.

var main = function() {
  console.log("they won't stop at dancin, no");
  console.log("they won't stop at dancin");
};

if (require.main == module) {
  main();
}

JSON

If a code example has a declared language of json, then gfmrun will write the source to a temporary file and "run" it via the node executable for validation.

{
  "no": "output",
  "levels": [
    8000,
    9000,
    9001
  ]
}

Python

If a code example has a declared language of python, then gfmrun will write the source to a temporary file and run it via whatever executable is first in line to respond to python.

from __future__ import print_function

import sys


def main():
    print('lipstick ringo dance all night {!r}!'.format(sys.argv))
    return 0


if __name__ == '__main__':
    sys.exit(main())

Ruby

If a code example has a declared language of ruby, then gfmrun will write the source to a temporary file and run it via whatever executable is first in line to respond to ruby.


def main
  puts $0
  puts "get out of the path of the king"
  return 0
end

if $0 == __FILE__
  exit main
end

Shell

If a code example has a declared language that can be mapped to the linguist definition of shell, then gfmrun will write the source to a temporary file and run it via whatever executable is first in line to respond to bash.

if [ 0 -eq 0 ] ; then
  echo "Just the way you like it, yes"
  echo "just the way you like it. (${0})"
fi
exit 0

Sh

If a code example has a declared language of sh, then gfmrun will write the source to a temporary file and run it via whatever executable is first in line to respond to sh.

if [ 5 -eq 3 ] ; then
  echo "YOU FOUND THE MARBLE IN THE OATMEAL"
else
  echo "Saddle up preacher, don't look back. (${0})"
fi
exit 0

Zsh

If a code example has a declared language of zsh, then gfmrun will write the source to a temporary file and run it via whatever executable is first in line to respond to zsh.

printf "Kiss me.\nJust kiss me.\n(${0})\n"

bye 0

Implicitly Supported Languages

If a code example's declared language can be matched to one of the explicitly supported languages listed above via the linguist languages definition, then the matched language's runner will be used.

This example declares node, but will be run via the javascript frob, which happens to use the node executable anyway:

if (1 / 1 == 1) {
  console.log("kiss me, Nefertiti");
}

Disabling automatic download of languages.yml

By default, the linguist languages definition is downloaded if not present. This behavior can be disabled by passing the --no-auto-pull / -N flag or setting a GFMRUN_NO_AUTO_PULL=true environment variable.

Tag annotation comments

gfmrun supports the use of JSON tags embedded in comments preceding code blocks, e.g. (just pretend ^ are backticks):

<!-- { "awesome": "maybe", "all on one line": "yep" } -->
^^^ go
package lolmain
// ... stuff
^^^
<!-- {
  "wow": "cool",
  "multiple": "lines"
} -->
^^^ go
package lolmain
// ... stuff
^^^
<!-- {
  "super": "advanced",
  "whitespace after the comment": "mindblown"
} -->


^^^ go
package lolmain
// ... stuff
^^^

"output" tag

Given a regular expression string value, asserts that the program output (stdout) matches.

"error" tag

Given a regular expression string value, asserts that the program error (stderr) matches.

"args" tag

Given a string array, run the program with the value as command line arguments.

"interrupt" tag

Given either a truthy or duration string value, interrupts the program via increasingly serious signals (INT, HUP, TERM, and finally KILL). If the value is truthy, then the default duration is used (3s). If the value is a string duration, then the parsed duration is used. This tag is intended for use with long-lived example programs such as HTTP servers.

"os" tag

Given either a string or array of strings, skips the program if the current OS does not match. When absent, no filter is applied.

Examples

No tag annotations, expected to be short-lived and exit successfully:

var _ = 1 / 1;

Annotated with an "output" JSON tag that informs gfmrun to verify the example program's output:

console.log("Ohai from the land of GitHub-Flavored Markdown :wave:");

Annotated with an "interrupt" JSON tag that informs gfmrun to interrupt the example program after a specified duration, which implies that the exit code is ignored (not Windows-compatible):

package main

import (
  "fmt"
  "net/http"
)

func main() {
  http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
    w.WriteHeader(http.StatusOK)
    fmt.Fprintf(w, "Why Hello From Your Friendly Server Example :bomb:\n")
  })
  http.ListenAndServe(":8990", nil)
}

Similar to the above example, but the "interrupt" tag is truthy rather than a specific interval, which will result in the default interrupt duration being used (3s). It is also annotated with an "output" tag that takes precedence over the "interrupt" tag's behavior of ignoring the exit code:

package main

import (
  "fmt"
  "net/http"
)

func main() {
  http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
    w.WriteHeader(http.StatusOK)
    fmt.Fprintf(w, "Hello Again From Your Friendly Server Example :bomb:\n")
  })
  fmt.Println(":bomb:")
  http.ListenAndServe(":8989", nil)
}

Download Details:

Author: urfave
Source Code: https://github.com/urfave/gfmrun 
License: MIT license

#go #golang #markdown #github 

Spring: A Static Web Site Generator Written By GitHub Issues

Spring

Spring is a blog engine written by GitHub Issues, or is a simple, static web site generator. No more server and database, you can setup it in free hosting with GitHub Pages as a repository, then post the blogs in the repository Issues.

You can add some labels in your repository Issues as the blog category, and create Issues for writing blog content through Markdown.

Spring has responsive templates, looking good on mobile, tablet, and desktop.Gracefully degrading in older browsers. Compatible with Internet Explorer 10+ and all modern browsers.

Get up and running in seconds.

中文介绍

Quick start guide

For the impatient, here's how to get a Spring blog site up and running.

First of all

  • Fork the Spring repository as yours.
  • Goto your repository settings page to rename Repository Name.
  • Hosted directly on GitHub Pages from your project repository, you can take it as User or organization site or Project site(create a gh-pages branch).
  • Also, you can set up a custom domain with Pages.

Secondly

  • Open the index.html file to edit the config variables with yours below.
$.extend(spring.config, {
  // my blog title
  title: 'Spring',
  // my blog description
  desc: "A blog engine written by github issues [Fork me on GitHub](https://github.com/zhaoda/spring)",
  // my github username
  owner: 'zhaoda',
  // creator's username
  creator: 'zhaoda',
  // the repository name on github for writting issues
  repo: 'spring',
  // custom page
  pages: [
  ]
})
  • Put your domain into the CNAME file if you have.
  • Commit your change and push it.

And then

  • Goto your repository settings page to turn on the Issues feature.
  • Browser this repository's issues page, like this https://github.com/your-username/your-repo-name/issues?state=open.
  • Click the New Issue button to just write some content as a new one blog.

Finally

  • Browser this repository's GitHub Pages url, like this http://your-username.github.io/your-repo-name, you will see your Spring blog, have a test.
  • And you're done!

Custom development

Installation

  • You will need a web server installed on your system, for example, Nginx, Apache etc.
  • Configure your spring project to your local web server directory.
  • Run and browser it, like http://localhost/spring/dev.html .
  • dev.html is used to develop, index.html is used to runtime.

Folder Structure

spring/
├── css/
|    ├── boot.less  #import other less files
|    ├── github.less  #github highlight style
|    ├── home.less  #home page style
|    ├── issuelist.less #issue list widget style
|    ├── issues.less #issues page style
|    ├── labels.less #labels page style
|    ├── main.less #commo style
|    ├── markdown.less #markdown format style
|    ├── menu.less #menu panel style
|    ├── normalize.less #normalize style
|    ├── pull2refresh.less #pull2refresh widget style
|    └── side.html  #side panel style
├── dist/
|    ├── main.min.css  #css for runtime
|    └── main.min.js  #js for runtime
├── img/  #some icon, startup images
├── js/
|    ├── lib/  #some js librarys need to use
|    ├── boot.js  #boot
|    ├── home.js  #home page
|    ├── issuelist.js #issue list widget
|    ├── issues.js #issues page
|    ├── labels.js #labels page
|    ├── menu.js #menu panel
|    ├── pull2refresh.less #pull2refresh widget
|    └── side.html  #side panel
├── css/
|    ├── boot.less  #import other less files
|    ├── github.less  #github highlight style
|    ├── home.less  #home page style
|    ├── issuelist.less #issue list widget style
|    ├── issues.less #issues page style
|    ├── labels.less #labels page style
|    ├── main.less #commo style
|    ├── markdown.less #markdown format style
|    ├── menu.less #menu panel style
|    ├── normalize.less #normalize style
|    ├── pull2refresh.less #pull2refresh widget style
|    └── side.html  #side panel style
├── dev.html #used to develop
├── favicon.ico #website icon
├── Gruntfile.js #Grunt task config
├── index.html #used to runtime
└── package.json  #nodejs install config

Customization

  • Browser http://localhost/spring/dev.html, enter the development mode.
  • Changes you want to modify the source code, like css, js etc.
  • Refresh dev.html view change.

Building

  • You will need Node.js installed on your system.
  • Installation package.
bash

$ npm install

*   Run grunt task.

    ```bash
$ grunt
  • Browser http://localhost/spring/index.html, enter the runtime mode.
  • If there is no problem, commit and push the code.
  • Don't forget to merge master branch into gh-pages branch if you have.
  • And you're done! Good luck!

Report a bug

Who used

If you are using, please tell me.

Download Details:
Author: zhaoda
Source Code: https://github.com/zhaoda/spring
License: MIT License

#spring #spring-framework #spring-boot #java 

Edison  Stark

Edison Stark

1603861600

How to Compare Multiple GitHub Projects with Our GitHub Stats tool

If you have project code hosted on GitHub, chances are you might be interested in checking some numbers and stats such as stars, commits and pull requests.

You might also want to compare some similar projects in terms of the above mentioned stats, for whatever reasons that interest you.

We have the right tool for you: the simple and easy-to-use little tool called GitHub Stats.

Let’s dive right in to what we can get out of it.

Getting started

This interactive tool is really easy to use. Follow the three steps below and you’ll get what you want in real-time:

1. Head to the GitHub repo of the tool

2. Enter as many projects as you need to check on

3. Hit the Update button beside each metric

In this article we are going to compare three most popular machine learning projects for you.

#github #tools #github-statistics-react #github-stats-tool #compare-github-projects #github-projects #software-development #programming

Macey  Kling

Macey Kling

1598603640

How to Use Github's README Feature to Track Your Stats in One Click

Github recently released profile README feature, which became a hit among developers. As it provides good place to showcase current projects and skills, many addons like

visitors-count,github-statshas been developed.I got tired of updating my github profile README again and again to get:

  • uniformity in dev/social icons
  • cool and minimal look
  • new features like visitors-count or github-stats

So I came up with an amazing tool to make this an easy experience. Github Profile README Generator tool provides a beautiful UI to create the same.

It lets you add the latest add-ons like visitors count, shields, dev icons, github stats, etc to your README in just one click.

Just fill the details like

Name,Tagline,Dev Platforms Username,Current Work,Portfolio, Blogetc using minimal UI.🚀 Try the tool: https://rahuldkjain.github.io/gh-profile-readme-generato

Click on

Generate READMEbutton after filling the form, to get your README in markdown. You can preview the README too.This project is developed using Gatsby and can be found on github

https://github.com/rahuldkjain/github-profile-readme-generator

Give it a try if it sounds interesting.

If you like the tool, show some love by leaving a star 🌟 on github repository at https://github.com/rahuldkjain/github-profile-readme-generator

#repositories-on-github #react #web-development #readme #markdown #github-hacks #github #latest-tech-stories

Jolie  Reichert

Jolie Reichert

1595668020

Stay Safe on GitHub: Security Practices to Follow

GitHub is undoubtedly the largest and most popular social development platform in the world. According to its 2019 State of the Octoverse Report, GitHub is home to over 40 million, and the community keeps expanding every day.

As developers in this deeply interconnected community use open source code to build software, Github security should be a top priority. This is because extensive code re-use increases the risk of distributing vulnerabilities from one dependency or repository to another. As such, every contributor should focus on creating a secure development environment.

Here are eight security practices that GitHub users can follow to stay safe and protect their code:

Strengthen Access Controls

Implementing proper access control is one of the best practices for enhancing security, not only on GitHub but in every other environment where code security is imperative.

GitHub offers several options that users can employ to reduce the risk of improper exposure. But to start with, it is important to employ the least privilege model where users are only granted necessary permissions.

Here are some basic access control guidelines that you should follow:

  • Restrict the creation of repositories to prevent users from exposing organization information in public repositories.
  • Enable branch protection and status checks to ensure users can merge commits or manipulate branches safely.
  • Allow or disallow forking private repositories to ensure users do not expose or share organizational code with unauthorized parties.
  • Revoke access for all inactive users who are no longer part of the contributors.

#tutorial #github #access control #software security #repository management #github issues #source code analysis #github apps #github enterprise #git best practices