Circle Ci 2.0 artifacts url - circleci

Circle Ci 2.0 artifacts can be accessed with the following url
https://{BUILD_NUMBER}-{UNKNOWN_NUMBER}-gh.circle-artifacts.com/0
What does the number after CI build number represent.

If, like me, you were looking for a way to programmatically reference CircleCI (2.0) artifacts, the following url structure works for me:
https://circleci.com/api/v1.1/project/:vcs-type/:username/:project/:build_num/artifacts/0/:path-to-artifact?circle-token=:token&branch=:branch
For example:
https://circleci.com/api/v1.1/project/github/circleci/circleci-docs/latest/artifacts/0/run-results/build-results.txt?branch=realitycheck&filter=successful
resolves to the build-results.txt artifact on the latest, successful build of the circleci-docs project's realitycheck branch.
Constructing the :path-to-artifact can be done by inspecting your CircleCI artifacts directory structure:
From the above, the :path-to-artifact is 0/run-results/build-results.txt.
Reference:
https://circleci.com/docs/api/v1-reference/#build-artifacts

The {UNKNOWN_NUMBER} represents the Github id of the repository.
If you run the snippet below you can get the id you want for any organisation and repository as provided by the github rest API
function query_gh(){
var org = document.getElementById("org").value;
var repo = document.getElementById("repo").value;
async function query(org, repo) {
const response = await fetch("https://api.github.com/orgs/"+org+"/repos");
const outJson = await response.json();
for (var i = 0; i < outJson.length; i++){
var repository = outJson[i];
if (repository.name == repo) {
id = repository.id;
output.innerHTML = org +"/"+ repo + " has ID: " + id;
return true;
}
}
}
query(org, repo);
return true;
}
<!DOCTYPE html>
<html>
<body>
<p>Enter names of the GH organisation and repository</p>
<form onsubmit="query_gh(); return false;">
<label for="org">Organisation</label>
<input type="text" id="org" required="">
<br>
<label for="repo">Repository</label>
<input type="text" id="repo" required="">
<br>
<button type="submit">Query</button>
</form>
<div id="output">
<span id="output_text">...</span>
</div>
</body>
</html>

Related

Testing Text To Speech (TTS) in browser

There is a really old blog entry from Twilio about testing the TTS in browser:
https://www.twilio.com/blog/2011/08/testing-twilios-text-to-speech-engine-using-twilio-client.html
Unfortunately it doesn't contain enough information to put a test together. It also contains a number of dead links and mentions a Github project that I can't find.
I'd really like for users to have the ability to hear what their announcement will sound like prior to firing off the form and starting the phone calls.
I use Lasso (which fires off CURL requests to the Twilio REST API), but any kind of tutorials or hints would be appreciated.
If you set up a demo account on Twilio and use Glitch online php tester (https://glitch.com/edit/#!/php-poc) or a local environment you can create a workable example like I did. You will need to fill in the empty strings to correspond to your app name. Search for TwiML in the website to get to the right section to set the right url of your server that TWilio will call upon request to read content (xml). In my case url was http://<server>/?incoming-call.php tested on Glitch.
You need to grab the Twilio PHP SDK and include the Services/Twilio/Capability.php from https://github.com/twilio/starter-php in your server code.
<?php
require __DIR__ . '/../vendor/autoload.php';
$url = [];
$url = explode('?', $_SERVER['REQUEST_URI']);
if (count($url) == 2 && $url[1] == 'incoming-call.php')
{
header('Content-type: text/xml');
$response = new Twilio\Twiml;
$dialogue = trim($_REQUEST['dialogue']);
$voice = (int) $_REQUEST['voice'];
if (strlen($dialogue) == 0)
{
$dialogue = 'Please enter some text to be spoken.';
}
if ($voice == 1)
{
$gender = 'man';
}
else
{
$gender = 'woman';
}
$response->say($dialogue);
echo $response;
exit;
}
require_once('Services/Twilio/Capability.php');
$accountsid = ''; // YOUR TWILIO ACCOUNT SID
$authtoken = ''; // YOUR TWILIO AUTH TOKEN
$fromNumber = ''; // PHONE NUMBER CALLS WILL COME FROM
$APP_SID = '';
$token = new Services_Twilio_Capability($accountsid, $authtoken);
$token->allowClientOutgoing($APP_SID);
?>
<html>
<head>
<title>Text-To-Speech</title>
<script type="text/javascript" src=
"https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript"
src="//media.twiliocdn.com/sdk/js/client/v1.5/twilio.js"></script>
<script type="text/javascript">
Twilio.Device.setup("<?php echo $token->generateToken();?>",{"debug":true});
$(document).ready(function() {
$("#submit").click(function() {
speak();
});
});
function speak() {
var dialogue = $("#dialogue").val();
var voice =
$('input:radio[name=voice]:checked').val();
Twilio.Device.connect({ 'dialogue' :
dialogue, 'voice' : voice });
}
</script>
</head>
<body>
<p>
<label for="dialogue">Text to be spoken</label>
<input type="text" id="dialogue" name="dialogue"
size="50">
</p>
<p>
<label for="voice-male">Male Voice</label>
<input type="radio" id="voice-male" name="voice"
value="1" checked="checked">
<label for="voice-female">Female Voice</label>
<input type="radio" id="voice-female" name="voice"
value="2">
</p>
<p>
<input type="button" id="submit" name="submit"
value="Speak to me">
</p>
</body>
</html>

DNN MVC Module not posting file back

I am building a small DNN MVC module whereby I need a user to upload file which will be processed server side.
When the form is posted back, the view model is posted back fine, but the file never is. Request.Files is always 0.
I even simplified it so all I had on the module was a simple file input and submit button but that failed as well.
I would hate to have to revert back to .ascx controls to get this to work.
I am testing this as an unregistered user, therefore there is no authentication checking in the controller.
See code below:
View
#inherits DotNetNuke.Web.Mvc.Framework.DnnWebViewPage<NM.Modules.FlexEventsCreate.Models.FlexEventViewModel>
#using DotNetNuke.Web.Mvc.Helpers
<input type="file" id="fileUp"/>
<input type="submit" id="btnSubmit" />
Controller
[DnnHandleError]
public class ItemController : DnnController
{
[HttpPost]
public ActionResult ShowForm(FlexEventViewModel flexEvent)
{
if (ModelState.IsValid)
{
var file = Request.Files;
if (file.Count != 0)
{
//do something
}
//return RedirectToDefaultRoute();
}
return View(flexEvent);
}
}
The rendered DNN HTML looks like this (I have simplified it)
<form method="post" action="/Test" id="Form" enctype="multipart/form-data">
<!-- Begin Content areas -->
<div>
<div class="row">
<div class="medium-9 columns">
<div id="dnn_LeftPane">
<div class="DnnModule DnnModule-DnnModule-747">
<a name="747"></a>
<div class="DnnF_Title_h1 SpacingBottom">
<h1><span id="dnn_ctr747_dnnTITLE_titleLabel" class="TitleH1"></span>
</h1>
<div id="dnn_ctr747_ContentPane">
<!-- Start_Module_747 -->
<div id="dnn_ctr747_ModuleContent">
<div id="dnn_ctr747_ShowForm_Prog" class="RadAjax RadAjax_Default" style="display:none;">
<div class="raDiv">
</div>
<div class="raColor raTransp">
</div>
</div>
<div class="RadAjaxPanel" id="dnn_ctr747_dnn_ctr747_ShowForm_UPPanel">
<div id="dnn_ctr747_ShowForm_UP">
<!-- 2013.2.717.40 -->
<div id="mvcContainer-747">
<input type="file" id="fileUp">
<input type="submit" id="btnSubmit">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
I did do an upload in an MVC module using the dropzone jquery component - which may help you. See my sample Restaurant Menu project on github.
First, include the dropzone script and css:
#using DotNetNuke.Web.Client.ClientResourceManagement
#{
ClientResourceManager.RegisterStyleSheet(Dnn.DnnPage, "~/DesktopModules/MVC/DotNetNuclear/RestaurantMenu/Resources/dropzone/css/dropzone.css");
ClientResourceManager.RegisterScript(Dnn.DnnPage, "~/DesktopModules/MVC/DotNetNuclear/RestaurantMenu/Resources/dropzone/js/dropzone.min.js", 100);
}
Then place a container div for the upload component:
<div id="dZUpload" class="uploadform dropzone no-margin dz-clickable">
<div class="dz-default dz-message"></div>
</div>
Initialize the component and tell it what type and how many files can be uploaded:
$("#dZUpload").dropzone({
acceptedFiles: "image/jpeg,image/png,image/gif",
url: '#Url.Action("Upload", "Menu")',
maxFiles: 1, // Number of files at a time
maxFilesize: 1, //in MB
addRemoveLinks: true,
maxfilesexceeded: function (file) {
alert('You have uploaded more than 1 Image. Only the first file will be uploaded!');
},
success: function (response) {
}
});
Change the acceptedFiles to the mimetypes you are restricting ("application/pdf", etc). Change the maxFiles to limit how many files they can upload at a time.
Write an MVC controller action to respond to the Dropzone file upload url. You can see it expects an action method "Upload" on the controller "Menu" (MenuController.Upload):
public JsonResult Upload()
{
string imageUrl = string.Empty;
string imgPath = Server.MapPath("~/Portals/0/Restaurant/");
if (!Directory.Exists(imgPath))
{
Directory.CreateDirectory(imgPath);
}
foreach (string s in Request.Files)
{
var file = Request.Files[s];
if (file.ContentLength > 0)
{
string fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(imgPath, fileName);
file.SaveAs(path);
imageUrl = string.Format("/Portals/0/Restaurant/{0}", fileName);
}
}
return Json(new { img = imageUrl, thumb = imageUrl });
}

How can I export data in pdf using MVC?

This is My Index method by which I am getting the list of data in webgird.How can I write a method for exporting this list of data when I click on button?
public ActionResult Index(string eMailId)
{
var refEntry = _moneyReport.GetAll().Where(a => a.EmailId == eMailId).ToList();
var credittotal = _moneyReport.GetAll().Where(a => a.EmailId == eMailId && a.PromoValue < 0).Sum(a => a.PromoValue);
decimal TotalCredit = Convert.ToDecimal(credittotal * -1);
var debittotal = _moneyReport.GetAll().Where(a => a.EmailId == eMailId && a.PromoValue >0).Sum(a => a.PromoValue);
decimal TotalDebit = Convert.ToDecimal(debittotal);
ViewBag.TotDebit = TotalDebit;
ViewBag.TotCredit = TotalCredit;
if(TotalCredit>TotalDebit)
{
decimal FinalTotal = TotalCredit - TotalDebit;
ViewBag.Total = FinalTotal;
}
else
{
decimal FinalTotal = TotalDebit - TotalCredit;
ViewBag.Total = FinalTotal;
}
return View(refEntry);
}
This is my View page where I am entering an emailid,load and Export button`enter code here.
#using (Html.BeginForm())
{
<div class="container-fluid form-row">
<div class="col-md-12 no-padding">
<div class="col-md-3 no-padding">
<input type="text" name="eMailId" id="eMailId" />
<span class="highlight"></span>
<span class="bar"></span>
<label class="no-left">Enter Email Id <sup class="star">*</sup></label>
</div>
<div class="col-md-3">
<input type="text" id="gName" name="gName" readonly="readonly" />
<span class="highlight"></span>
<span class="bar"></span>
<label>Name</label>
</div>
<div class="col-md-3">
<input type="submit" id="btnLoad" class="btn btn-md pm-create" value="Load" />
<input type="submit" id="btnLoad" class="btn btn-md" value="Export To PDF" />
</div>
<input type="hidden" id="HdnEmail" value='#TempData["MailID"]' />
</div>
</div>
}
<div id="report-grid">
#{Html.RenderPartial("ImportMoneyReport", Model);}
</div>
ImPortMoneyReport is my partial page where i ve the webgrid.
To export model data to PDF you will have to use one of third party pdf export libraries such as few below. You will find sample examples on respective sites or google them. You will need to implement code to export pdf in and add that file/stream into Response.OutputStream by setting respective content type in ImportMoneyReport action. Also you will have to invoke ImportMoneyReport method on post/event you can not use Html.RenderPartial to export; otherwise you can put export code in Index action only.
PDF Sharp
iTextSharp
It you want something that's working and very easy to use. Take a look at https://github.com/andyhutch77/MvcRazorToPdf
Just read the documentation.
For sample code. Take a look at this.
https://github.com/andyhutch77/MvcRazorToPdf/tree/master/MvcRazorToPdfExample
If you encounter some issues go to their github page and click the Issues tab, maybe some of your questions are already resolved there.
P.S.
Some of the PDF libraries like Rotativa will require an executable program to run that will not work when your app is deployed to Azure because Azure doesn't support exe files (I guess for security purposes) else you'll create a webjob just for the exe file.

KO binding not working in IIS 6

I have written small piece of code which is working fine when I am debugging it through VS 2010. ( i.e. Using 'Visual Studio Development Server.)
After that I changed project setting and clicked on 'Use Local IIS Web Server' ( automatically created virtual directory) when I run application I found that KO code is not at all getting executed. Could not see text box populated with default values.
Do we have to take any special care while deploying code to IIS?
Below is my piece of code.
#{
ViewBag.Title = "Home Page";
}
<div>
<div>
<div>
<label>
Name</label>
<input type="text" name="txtID" data-bind="value: ID" />
</div>
<div>
<label>
First Name</label>
<input type="text" name="txtFirstName" data-bind="value: FirstName" />
</div>
<div>
<label>
Last Name</label>
<input type="text" name="txtLastName" data-bind="value: LastName" />
</div>
<div>
<label>
Full Name</label>
<input type="text" name="txtFullName" data-bind="value: FullName" />
</div>
</div>
</div>
#section scripts{
<script src="../../Scripts/jquery-1.7.1.js" type="text/javascript"></script>
<script src="../../Scripts/knockout-2.1.0.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var ViewModel = function () {
var self = this;
self.FirstName = ko.observable("Initial Name");
self.LastName = ko.observable("Last Name");
self.ID = ko.observable(100);
self.FullName = ko.computed({
read: function () {
return self.FirstName() + " " + self.LastName();
},
write: function (value) {
var lastIndex = value.lastIndexOf(" ");
if (lastIndex > 0) {
self.FirstName(value.substring(0, lastIndex));
self.LastName(value.substring(lastIndex + 1));
}
}
});
}
var viewModel = new ViewModel();
ko.applyBindings(viewModel);
var t = function () {
alert(viewModel.FullName());
};
});
</script>
}
Your script references are probably broken because they are relative references and you are using now a virtual directory in IIS.
You need to use the Url.Content helper method where you can specify your root directory with ~ which will take care of the virtual directories and generates the correct urls for you:
<script src="#Url.Content("~/Scripts/jquery-1.7.1.js")" type="text/javascript">
</script>
<script src="#Url.Content("~/Scripts/knockout-2.1.0.js")" type="text/javascript">
</script>

Insertion into google fusion table

I want to insert data into my fusion table which is public . I looked out at https://developers.google.com/fusiontables/docs/sample_code for help specifically http://code.google.com/p/fusion-tables-client-php/source/browse/trunk/samples/form_example.php . I downloaded the necessary files for this script to run i.e. downloaded clienlogin.php , file.php , sql.php and constants.php. The script is running but rows are not getting inserted and I am not able to find the reason . I have pasted my code ( its a small code .. please have a look at it and let me know the error I am commiting). Essentially I want to insert data into my fusion table after collecting user info through user forms . I don't want to use google forms. Any kind of help / pointers in this direction would be helpful.
<html>
<?php
include('D:\xampp\htdocs\itpold\clientlogin.php');
include('D:\xampp\htdocs\itpold\sql.php');
include('D:\xampp\htdocs\itpold\file.php');
// Table id
$tableid = 3544282;
//Enter your username and password
$username = "ABCD#gmail.com";
$password = "XYZ";
$token = ClientLogin::getAuthToken($username, $password);
$ftclient = new FTClientLogin($token);
// If the request is a post, insert the data into the table
if($_SERVER['REQUEST_METHOD'] == 'POST') {
// Insert form data into table
$insertresults = $ftclient->query(SQLBuilder::insert($tableid,
array('Name'=> $_POST['Name'],
'Location' => $_POST['Location'])));
$insertresults = explode("\n", $insertresults);
$rowid1 = $insertresults[1];
echo $rowid1 ;
}
?>
<head>
<title>Simple Form Example</title>
<style>
body { font-family: Arial, sans-serif; }
</style>
<script type="text/javascript">
// Simple form checking.
function check_form() {
if(document.getElementById('Name').value == '' ||
document.getElementById('Location').value == '') {
alert('Name and location required.');
return false;
}
return true;
}
</script>
</head>
<body >
<h1>Simple Form Example</h1>
<h2>Insert data</h2>
<form method="post" action="forms.php" onsubmit="return check_form();">
Name: <input type="text" name="Name" id="Name" /><br />
Result: <input type="text" name="Location" id="Location" /><br />
<input type="submit" value="Submit" />
</form>
<h2>Table data</h2>
<p>
<?php
// Show the data from table
$table_data = $ftclient->query(SQLBuilder::select($tableid));
$table_data = explode("\n", $table_data);
for($i = 0; $i < count($table_data); $i++) {
echo $table_data[$i] . '<br />';
}
?>
</p>
</body>
</html>
Often, the server is not able to send requests to secure URLs. See the following StackOverflow post for some ideas on how to fix the problem:
Can't connect to HTTPS site using cURL. Returns 0 length content instead. What can I do?
I suspect that this is a permissions problem with your table. Have you made sure that the account your are logging in with is set up as an editor for this table? The easiest way to check this is to go into Fusion Tables as the owner for the table, and click the share link in the upper right hand corner.

Resources