GitHub Releases Download URL Redirect Doesn't Seem to Work - github

I've checked out this here on Stack Overflow, but following what's outlined there, I'm still getting "not found" on pages that I know have releases.
For example, if I want to download the latest URL for something like https://github.com/storybookjs/storybook/releases, for a number of repositories dynamically, why do I get a 404 when I use https://github.com/storybookjs/storybook/releases/latest/download/package.zip
What am I missing here?
Thanks in advance!

It might be easier to use GitHub's API for that, as documented for releases. The URL format is
https://api.github.com/repos/{owner}/{repo}/releases
For example, https://api.github.com/repos/symfony/symfony/releases lists all releases for a PHP package. The JSON node zipball_url contains a link to a ZIP package for each release.

Related

How to get rid of the hash symbol (`#`) in the URL in UI5-routing?

Starting the 1.83.x/1.84.x OpenUI5 versions there is a possibility to omit the hash symbol (#) from the browser routing URL.
The new URL-format vs. the old-one:
https://openui5.hana.ondemand.com/topic/1b6dcd39a6a74f528b27ddb22f15af0d
https://sapui5.hana.ondemand.com/#/topic/1b6dcd39a6a74f528b27ddb22f15af0d
I've checked the OpenUI5 documentation but could not find how to get rid of this # in the URL.
Is it somewhere in manifest.json?
The OpenUI5 Demo Kit is using a custom Router in order to improve its SEO. See commit 4614eb0.
Routing without # is not officially supported yet. There is an enhancement request though: https://github.com/SAP/openui5/issues/2993

TeamCity REST Api supported requests and names of parameters

I was trying to use the REST API of TeamCity but i can't find a list of all supported requests and the names of parameters. I wanted to look it up in their official documentation (https://confluence.jetbrains.com/display/TCD10/REST+API)
where a link to exactly this list is provided
(http://teamcity:8111/app/rest/application.wadl)
but i just can't connect to it. Seems like the page is down.
I have googled all kinds of stuff in the hope to find this list somewhere else but i couldn't find anything smart.
Does anyone know where to find such a list or can provide one? That would be fantastic.
Thanks
You can find available API on the public teamcity:
https://teamcity.jetbrains.com/app/rest/swagger.json
You can navigate through the response inside the paths and look at supported methods, and required parameters for each API.
You can also access to the .wadl on the public teamcity server:
https://teamcity.jetbrains.com/app/rest/application.wadl
When you are inside the documentation of teamcity, they use teamcity:8111 as your own teamcity, installed on your server.
The URL examples on this page assume that your TeamCity server web UI is accessible via the http://teamcity:8111 URL.
If you download a copy of teamcity, start a copy of the server, and then connect to /app/rest/application.wadl, you will probably get a copy of representation.

Get number of github downloads

I'm trying to figure out how to use the Github API to get the number of downloads of a release. I have a test repo called polymer-reptation under my username benlindsay with one tag, 1.0. A Github Developer page here says that to get the information on a single release I can use the command GET /repos/:owner/:repo/releases/:id. I can't figure out how to use that command though. I tried things like curl --user "benlindsay" https://api.github.com/repos/:benlindsay/:polymer-reptation/releases/:1.0 on the command line, the same thing without the colons, and typing similar things into hurl.it. They all just give me
{
"message": "Not Found",
"documentation_url": "https://developer.github.com/v3"
}
at best. Can someone show me to how to use this feature of the API? (an easier way to track downloads would be helpful as well if one exists)
You should use it without the colons, they are there to indicate stuff you should replace.
However, Listing all releases at https://api.github.com/repos/benlindsay/polymer-reptation/releases Returns an empty array... No releases My guess is the API hasn't caught up yet. If this doesn't resolve itself shortly, contact GitHub.

Collecting GitHub project issues statistics programmatically?

I'm collecting GitHub issue statistics over time on our project: total number of issues, number of issues with a particular label, number of issues in a given state (open/closed). Right now, I have a Python script to parse the project webpage with the desired labeling/state for the info I want, e.g., http://github.com/<projectname>/issues?label=<label_of_interest>&state=<state_of_interest>
However, parsing the HTML is fragile since if the GitHub API changes, more often than not, my code fails.
Does someone describe how to use the GitHub API (or barring that, know of some other way, preferably in Python) to collect these statistics without relying on the underlying HTML?
May I be so forward as to suggest that you use my wrapper around the GitHub API for this? With github3.py, you can do the following:
import github3
github = github3.login("braymp", "braymp's super secret password")
repo = github.repository("owner", "reponame")
open_issues = [i for i in repo.iter_issues()]
closed_issues = [i for i in repo.iter_issues(state='closed')]
A call to refresh may be necessary because I don't honestly recall if GitHub sends all of the issue information upon the iteration like that (e.g., replace i.refresh() for i in <generator> as the body of the list comprehensions above).
With those, you can iterate over the two lists and you will be able to use the labels attribute on each issue to figure out which labels are on an issue. If you decide to merge the two lists, you can always check the status of the issue with the is_closed method.
I suspect the actual statistics you can do yourself. :)
The documentation for github3.py can be found on ReadTheDocs and you'll be particularly interested in Issue and Repository objects.
You can also ask further questions about github3.py by adding the tag for it in your StackOverflow question.
Cheers!
I'd take a look at Octokit. Which doesn't support Python currently, but does provide a supported interface to the GitHub API for Ruby.
https://github.com/blog/1517-introducing-octokit
Although this doesn't fully meet your specifications (the "preferably Python" part), Octokit is a fantastic (and official - it's developed by GitHub) way of interacting with the GitHub API. You wrote you'd like to get Issues data. It's as easy as installing, requiring the library, and getting the data (no need for authentication if the project is public).
Install:
gem install octokit
Add this to your Ruby file to require the Octokit library:
require 'octokit'
Although there are a lot of things you can get from Octokit::Client::Issues, you may want to get a paginated list of all the issues in a repository:
Octokit.list_issues('octokit/octokit.rb')
# => [Array<Sawyer::Resource>] A list of issues for a repository.
If you're really keen on using Python, you might want to have a look at the GitHub API docs for Issues. Really, it's as easy as getting a URL like: https://api.github.com/repos/octokit/octokit.rb/issues and get the JSON data (although I'm not familiar with Python, I'm sure these some JSON parsing library); no need for authentication for public repos.

Reference GitHub file in jsFiddle

Is there a possibility to misuse grab files from a github repo as external resources in jsFiddle?
TLDR; Visit rawgit.com which will pop your files on a CDN straight from GitHub so you can use them.
Unfortunately none of the answers here worked for me. The rawgithub URL didn't seem to work as the connection gets refused. So here's a full solution that did work. Firstly in GitHub you need to click the Raw button to get the original JavaScript.
Then copy the URL from the page it takes you too. You'll notice if you try and use this directly you'll get a warning from JSFiddle.
More to the point is the browser will give you an error, e.g.:
Refused to execute script from https://raw.githubusercontent.com/nnnick/Chart.js/master/Chart.min.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
Take that URL and visit rawgit.com. This will give you a URL of the format https://rawgit.com/nnnick/Chart.js/master/Chart.min.js which you can then use.
I've tried and tested this and it seems to work fine without issue
This is an updated answer, since the url's have changed slightly for Github... I ran into this issue and figured it out for present day. Hopefully this helps people out finding this post recently. Example for Bootstrap Slate theme from Bootswatch:
Raw file url: https://raw2.github.com/thomaspark/bootswatch/gh-pages/slate/bootstrap.css
Remove the 2. after raw: https://rawgithub.com/thomaspark/bootswatch/gh-pages/slate/bootstrap.css
That's it! :D
Nowadays JSDelivr seems to be the best option.
UPDATE
How to use or misuse github as kind of a CDN is not a thought that only benign "fiddlers" have; criminals have that thought also. Unfortunately, github, being as free and as anonymous as it is, is prone to be misused. As far as I can tell, the fact that some of the above solutions are things which are now broken, has to do with that.
Here is how I do it. It works now (Nov 2019), but it's admittedly not very convenient.
Get a github account yourself, if you don't already have one. Create a repository the name of which is identical to your github user name. That repo (and only that repo), - I'll call it the "home repo" - you can use as your web hosting service. https : // yourGithubUserName .github.io will show your home repo "raw/as it is" to the public. (Folder contents is not shown, and you HAVE TO have an index.html)
Now, if you want to use someone else's github repo in a fiddle, just copy over the complete repo to your home repo, and then just reference your copy of that repo with the src attribute of a script tag in the HTML part of the fiddle. Like this:
<head>
<script src="https://mathheadinclouds.github.io/thirdparty/esprima.js"></script>
<script src="https://mathheadinclouds.github.io/thirdparty/estraverse.browser.js"></script>
<script src="https://mathheadinclouds.github.io/thirdparty/escope.browser.js"></script>
</head>
<body></body>
Above snippet shows the HTML part of a working fiddle which is using the node modules esprima, estraverse, and escope, which is to say, the github repos of the same name. thirdparty is there because that's the name of the subfolder (in my home repo) where I put the copies.
As I said, not very convenient (lot's of copy and paste to set it all up), but that's what works for me.
And I should mention, just copy/paste might not be enough, you might have to do browserify or webpack on the referenced repo (if it was made for node, that is.)
here is the fiddle I was talking about.
OLD ANSWER
(works, but is kind of slow)
You can use requirify. It's made to enable you to require (as it is in node) on the browser command line; but it works in fiddles too, I tested it. I have no clue if it's "the best", compared to the other methods above (since I didn't go through them all and tested them), but it works.
Here is an example fiddle loading esprima (javascript parser), then escodegen (reverse javascript parser depending on esprima), then parsing and regenerating some simple javascript code.
what
require('lorem', 'ipsum')
does is, it loads the ipsum node module from npm, and puts the result into global variable named lorem. So this is only for npm modules not general github files which aren't also node modules. Shouldn't be much restriction since you can always turn it into a node module if it's your own project.
here it is
second example using same technique.
(((it's actually even simpler as shown in the fiddle. You can just put the 2 require statements right one after the other, you don't need a callback function in between (just one callback function to wait until both are loaded))))
Another possibility is to add the Git library to the cdnJS Script Repository (they write that any library that is resonably popular on GitHub will be accepted) and then use it as external resource.
Just found out: there are lots of Javascript libraries at http://jsdb.io/ and it's very easy to add new ones there--i's just a matter of entering the URL of a Github repository.
If there is a git repo in following folder structure
fiddletest/test1 (fiddletest is the repo name and test1 is a folder)
then the corresponding jsfiddle link will be
http://jsfiddle.net/gh/get/<library name>/<version>/<github user name>/fiddletest/tree/master/test1/
The folder and file structure must be like this
fiddletest(the repo name)
|____ test1
|____ demo.html
|____ demo.js
|____ demo.css
|____ demo.details
except these three files others will be ignored.
the details file should hold the fiddle details and link of external resources(if any) as follows
---
name: test fiddle repo
description: this is a test repo
resources:
- http://abc.xyz.com/abc.js
- http://abc.xyz.com/abc2.js
...
May be you have noticed the and in the fiddle link. If a fiddle is with pure js the the library name should be "library" and the version should be "pure"
In a nutshell the fiddle link to reffer to github should be in following format
http://jsfiddle.net/gh/get/<library name>/<version>/<github user name>/<repo name>/tree/<branchname>/<folder name>/
2021
Just go to github file and click "Download" button and copy URL - it will works with fetch - working example here (it not works in SO snippet - I don't know why) - example url from this file:
https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/VC/glTF-Embedded/VC.gltf