2014年02月

Question

How long are you required to hold on to files, such as survey reports, for customers? We are switching storage facilities and need to know how far back we need to keep.



Answer

A good rule of thumb is 6 years, but there may be a state statute in your state telling you how long to keep them. Statutes of Repose regarding claims against you may exist for engineers and architects and in Texas they are 15 years.





Numbering with CSS Counter for Headings

I'm trying to achieve a css counting for headers.
for ex.



<h1>first heading</h1>
<h2>second heading</h2>


will be converted



1. first heading
1.1 second heading


That works fine with the css counter. What doesn't work is when the h2 is a h3. The result will be that the h3 heading will add a "1.0.1" instead of a 1.1.1, because there is no h2 heading so the counter for h2 is 0.



<h1>first heading</h1>
<h3>third heading (should be 1.1.1)</h3>


will be converted



1. first heading
1.0.1 third heading (should be 1.1.1)


Any suggestion how to solve this (is it even possible)



ps. an example for the headings can be found here http://jsfiddle.net/6xpveu0t/



Answers

Please use headlines in semantically correct way.



In the earlier days, people rather misused different headline-tags to suit their design, rather than styling them correctly as it is done today (hopefully everywhere).



In terms of semantic usage of headlines, a headline 1 is always followed by a headline 2 followed by a headline 3. You may refer to w3c school about headline priority.



In printed books, you will never find a nested subchapter inside a skipped chapter. Therefore the CSS counter is correct.



Nevertheless you can include an empty <h2></h2>.





HttpResponseMessage parameters received after constructor is called

I have an API controller that when called from the client passes database credentials.



public class ForemanController : ApiController
{
static SqlConnectionStringBuilder connectionString = new SqlConnectionStringBuilder ();

public ForemanController()
{
//database calls with connection string
}

public void Get(string DataSource, string InitialCatalog, string UserID, string Password)
{
connectionString.DataSource = DataSource;
connectionString.InitialCatalog = InitialCatalog;
connectionString.UserID = UserID;
connectionString.Password = Password;
}
}


The get method is working fine and I can see the credentials being passed via the client code:



static HttpClient client = new HttpClient();
HttpResponseMessage resp = client.GetAsync("api/foreman?DataSource=dxdv&InitialCatalog=Q19410&UserID=tunld&Password=did").Result;


My problem is that the constructor in the ApiController runs before the get method so the database calls fail because of a null connection string.



How do I get the parameters to pass before the constructor?





rsync passing source from csv file

I am trying to use rsync to synchronise remote files with local server.
It works great but I want to do it on multiple remote servers to sync with on daily basis.



lanein2@FTP-Stager:/home/toor$ sshpass -p "xyz" rsync -avz lanein1@xx.xxx.xxx.xxx:BrandStIN/ /home/lanein2/BrandStIN/
lanein2@FTP-Stager:/home/toor$ sshpass -p "xyz" rsync -avz lanein1@yy.yyy.yyy.yyy:Brand1/ /home/lanein2/Brand1/
lanein2@FTP-Stager:/home/toor$ sshpass -p "xyz" rsync -avz lanein1@aa.aaa.aaa.aaa:Brand1/ /home/lanein2/Brand1/


I want to have all ip adresses with their password in a csv file and want to run rsync .
how can I pass a csv file data and do rsync in a cron job.



Answers

try with a bash script, like this one (not working as it is, just a starting point)



#!/bin/bash

# define password for each of the servers, maybe use arrays or something like that
# also, define paths for each server (if they change)

for i in 192.168.0.1 192.168.0.2; do
# here too, you can use an array for ip addresses
sshpass -p $PASSWORD_OF_SERVER_1 rsync -avz lanein1@$i:$SERVER1_PATH/ /home/lanein2/$SERVER1_PATH/
done


then reference it with cron (e.g. put it in a line of /etc/cron.daily)





How to use php inside of javascript?

I am using javascript to retrieve a bunch of values from the Riot API, however I want to store them in my own database using php. For example, I'm trying to store the gameID and this is what I'm trying right now.



      <?php
$insrt = "INSERT INTO game (gameId)
VALUES (".<script>b.gameId</script>.")";
mysqli_query($dbc, $insrt);
?>


I'm pretty sure that I'm not even close to correct but I'm not sure how to do this.



Answers

You need to take a different approach. You can make an ajax call to a php script to do this for you. But the initiator will be javascript from the client side. Using jQuery(let me know if you can't), you can do



$.ajax({url: "insert_game_id.php", data: {gameId :b.gameId} });


and your php script



<?php
$gameId = $_POST['gameId'];
$insrt = "INSERT INTO game (gameId)
VALUES ($gameId)";
mysqli_query($dbc, $insrt);
?>


See jQuery Ajax POST example with PHP





↑このページのトップヘ