Search Results

Search found 787 results on 32 pages for 'steven chan'.

Page 11/32 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Checking deployed port in ruby on rails application

    - by john chan
    Is there an elegant way to check which port you deployed a ruby on rails application using mongrel? I could not find a directive (i.e. such as #{RAILS_ROOT} which contains the root directory of the application) that I can use to perform a check. I need this to do a check since I am deploying the same application on different ports and I need the app to do different things according to the port that is being accessed. Any help would be appreciated, Thanks

    Read the article

  • How to optimize dynamic programming?

    - by Chan
    Problem A number is called lucky if the sum of its digits, as well as the sum of the squares of its digits is a prime number. How many numbers between A and B are lucky? Input: The first line contains the number of test cases T. Each of the next T lines contains two integers, A and B. Output: Output T lines, one for each case containing the required answer for the corresponding case. Constraints: 1 <= T <= 10000 1 <= A <= B <= 10^18 Sample Input: 2 1 20 120 130 Sample Output: 4 1 Explanation: For the first case, the lucky numbers are 11, 12, 14, 16. For the second case, the only lucky number is 120. The problem is quite simple if we use brute force, however the running time is so critical that my program failed most test cases. My current idea is to use dynamic programming by storing the previous sum in a temporary array, so for example: sum_digits(10) = 1 -> sum_digits(11) = sum_digits(10) + 1 The same idea is applied for sum square but with counter equals to odd numbers. Unfortunately, it still failed 9 of 10 test cases which makes me think there must be a better way to solve it. Any idea would be greatly appreciated. #include <iostream> #include <vector> #include <string> #include <algorithm> #include <unordered_map> #include <unordered_set> #include <cmath> #include <cassert> #include <bitset> using namespace std; bool prime_table[1540] = { 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 }; unsigned num_digits(long long i) { return i > 0 ? (long) log10 ((double) i) + 1 : 1; } void get_sum_and_sum_square_digits(long long n, int& sum, int& sum_square) { sum = 0; sum_square = 0; int digit; while (n) { digit = n % 10; sum += digit; sum_square += digit * digit; n /= 10; } } void init_digits(long long n, long long previous_sum[], const int size = 18) { int current_no_digits = num_digits(n); int digit; for (int i = 0; i < current_no_digits; ++i) { digit = n % 10; previous_sum[i] = digit; n /= 10; } for (int i = current_no_digits; i <= size; ++i) { previous_sum[i] = 0; } } void display_previous(long long previous[]) { for (int i = 0; i < 18; ++i) { cout << previous[i] << ","; } } int count_lucky_number(long long A, long long B) { long long n = A; long long end = B; int sum = 0; int sum_square = 0; int lucky_counter = 0; get_sum_and_sum_square_digits(n, sum, sum_square); long long sum_counter = sum; long long sum_square_counter = sum_square; if (prime_table[sum_counter] && prime_table[sum_square_counter]) { lucky_counter++; } long long previous_sum[19] = {1}; init_digits(n, previous_sum); while (n < end) { n++; if (n % 100000000000000000 == 0) { previous_sum[17]++; sum_counter = previous_sum[17] + previous_sum[18]; sum_square_counter = previous_sum[17] * previous_sum[17] + previous_sum[18] * previous_sum[18]; previous_sum[16] = 0; previous_sum[15] = 0; previous_sum[14] = 0; previous_sum[13] = 0; previous_sum[12] = 0; previous_sum[11] = 0; previous_sum[10] = 0; previous_sum[9] = 0; previous_sum[8] = 0; previous_sum[7] = 0; previous_sum[6] = 0; previous_sum[5] = 0; previous_sum[4] = 0; previous_sum[3] = 0; previous_sum[2] = 0; previous_sum[1] = 0; previous_sum[0] = 0; } else if (n % 10000000000000000 == 0) { previous_sum[16]++; sum_counter = previous_sum[16] + previous_sum[17] + previous_sum[18]; sum_square_counter = previous_sum[16] * previous_sum[16] + previous_sum[17] * previous_sum[17] + previous_sum[18] * previous_sum[18]; previous_sum[15] = 0; previous_sum[14] = 0; previous_sum[13] = 0; previous_sum[12] = 0; previous_sum[11] = 0; previous_sum[10] = 0; previous_sum[9] = 0; previous_sum[8] = 0; previous_sum[7] = 0; previous_sum[6] = 0; previous_sum[5] = 0; previous_sum[4] = 0; previous_sum[3] = 0; previous_sum[2] = 0; previous_sum[1] = 0; previous_sum[0] = 0; } else if (n % 1000000000000000 == 0) { previous_sum[15]++; sum_counter = previous_sum[15] + previous_sum[16] + previous_sum[17] + previous_sum[18]; sum_square_counter = previous_sum[15] * previous_sum[15] + previous_sum[16] * previous_sum[16] + previous_sum[17] * previous_sum[17] + previous_sum[18] * previous_sum[18]; previous_sum[14] = 0; previous_sum[13] = 0; previous_sum[12] = 0; previous_sum[11] = 0; previous_sum[10] = 0; previous_sum[9] = 0; previous_sum[8] = 0; previous_sum[7] = 0; previous_sum[6] = 0; previous_sum[5] = 0; previous_sum[4] = 0; previous_sum[3] = 0; previous_sum[2] = 0; previous_sum[1] = 0; previous_sum[0] = 0; } else if (n % 100000000000000 == 0) { previous_sum[14]++; sum_counter = previous_sum[14] + previous_sum[15] + previous_sum[16] + previous_sum[17] + previous_sum[18]; sum_square_counter = previous_sum[14] * previous_sum[14] + previous_sum[15] * previous_sum[15] + previous_sum[16] * previous_sum[16] + previous_sum[17] * previous_sum[17] + previous_sum[18] * previous_sum[18]; previous_sum[13] = 0; previous_sum[12] = 0; previous_sum[11] = 0; previous_sum[10] = 0; previous_sum[9] = 0; previous_sum[8] = 0; previous_sum[7] = 0; previous_sum[6] = 0; previous_sum[5] = 0; previous_sum[4] = 0; previous_sum[3] = 0; previous_sum[2] = 0; previous_sum[1] = 0; previous_sum[0] = 0; } else if (n % 10000000000000 == 0) { previous_sum[13]++; sum_counter = previous_sum[13] + previous_sum[14] + previous_sum[15] + previous_sum[16] + previous_sum[17] + previous_sum[18]; sum_square_counter = previous_sum[13] * previous_sum[13] + previous_sum[14] * previous_sum[14] + previous_sum[15] * previous_sum[15] + previous_sum[16] * previous_sum[16] + previous_sum[17] * previous_sum[17] + previous_sum[18] * previous_sum[18]; previous_sum[12] = 0; previous_sum[11] = 0; previous_sum[10] = 0; previous_sum[9] = 0; previous_sum[8] = 0; previous_sum[7] = 0; previous_sum[6] = 0; previous_sum[5] = 0; previous_sum[4] = 0; previous_sum[3] = 0; previous_sum[2] = 0; previous_sum[1] = 0; previous_sum[0] = 0; } else if (n % 1000000000000 == 0) { previous_sum[12]++; sum_counter = previous_sum[12] + previous_sum[13] + previous_sum[14] + previous_sum[15] + previous_sum[16] + previous_sum[17] + previous_sum[18]; sum_square_counter = previous_sum[12] * previous_sum[12] + previous_sum[13] * previous_sum[13] + previous_sum[14] * previous_sum[14] + previous_sum[15] * previous_sum[15] + previous_sum[16] * previous_sum[16] + previous_sum[17] * previous_sum[17] + previous_sum[18] * previous_sum[18]; previous_sum[11] = 0; previous_sum[10] = 0; previous_sum[9] = 0; previous_sum[8] = 0; previous_sum[7] = 0; previous_sum[6] = 0; previous_sum[5] = 0; previous_sum[4] = 0; previous_sum[3] = 0; previous_sum[2] = 0; previous_sum[1] = 0; previous_sum[0] = 0; } else if (n % 100000000000 == 0) { previous_sum[11]++; sum_counter = previous_sum[11] + previous_sum[12] + previous_sum[13] + previous_sum[14] + previous_sum[15] + previous_sum[16] + previous_sum[17] + previous_sum[18]; sum_square_counter = previous_sum[11] * previous_sum[11] + previous_sum[12] * previous_sum[12] + previous_sum[13] * previous_sum[13] + previous_sum[14] * previous_sum[14] + previous_sum[15] * previous_sum[15] + previous_sum[16] * previous_sum[16] + previous_sum[17] * previous_sum[17] + previous_sum[18] * previous_sum[18]; previous_sum[10] = 0; previous_sum[9] = 0; previous_sum[8] = 0; previous_sum[7] = 0; previous_sum[6] = 0; previous_sum[5] = 0; previous_sum[4] = 0; previous_sum[3] = 0; previous_sum[2] = 0; previous_sum[1] = 0; previous_sum[0] = 0; } else if (n % 10000000000 == 0) { previous_sum[10]++; sum_counter = previous_sum[10] + previous_sum[11] + previous_sum[12] + previous_sum[13] + previous_sum[14] + previous_sum[15] + previous_sum[16] + previous_sum[17] + previous_sum[18]; sum_square_counter = previous_sum[10] * previous_sum[10] + previous_sum[11] * previous_sum[11] + previous_sum[12] * previous_sum[12] + previous_sum[13] * previous_sum[13] + previous_sum[14] * previous_sum[14] + previous_sum[15] * previous_sum[15] + previous_sum[16] * previous_sum[16] + previous_sum[17] * previous_sum[17] + previous_sum[18] * previous_sum[18]; previous_sum[9] = 0; previous_sum[8] = 0; previous_sum[7] = 0; previous_sum[6] = 0; previous_sum[5] = 0; previous_sum[4] = 0; previous_sum[3] = 0; previous_sum[2] = 0; previous_sum[1] = 0; previous_sum[0] = 0; } else if (n % 1000000000 == 0) { previous_sum[9]++; sum_counter = previous_sum[9] + previous_sum[10] + previous_sum[11] + previous_sum[12] + previous_sum[13] + previous_sum[14] + previous_sum[15] + previous_sum[16] + previous_sum[17] + previous_sum[18]; sum_square_counter = previous_sum[9] * previous_sum[9] + previous_sum[10] * previous_sum[10] + previous_sum[11] * previous_sum[11] + previous_sum[12] * previous_sum[12] + previous_sum[13] * previous_sum[13] + previous_sum[14] * previous_sum[14] + previous_sum[15] * previous_sum[15] + previous_sum[16] * previous_sum[16] + previous_sum[17] * previous_sum[17] + previous_sum[18] * previous_sum[18]; previous_sum[8] = 0; previous_sum[7] = 0; previous_sum[6] = 0; previous_sum[5] = 0; previous_sum[4] = 0; previous_sum[3] = 0; previous_sum[2] = 0; previous_sum[1] = 0; previous_sum[0] = 0; } else if (n % 100000000 == 0) { previous_sum[8]++; sum_counter = previous_sum[8] + previous_sum[9] + previous_sum[10] + previous_sum[11] + previous_sum[12] + previous_sum[13] + previous_sum[14] + previous_sum[15] + previous_sum[16] + previous_sum[17] + previous_sum[18]; sum_square_counter = previous_sum[8] * previous_sum[8] + previous_sum[9] * previous_sum[9] + previous_sum[10] * previous_sum[10] + previous_sum[11] * previous_sum[11] + previous_sum[12] * previous_sum[12] + previous_sum[13] * previous_sum[13] + previous_sum[14] * previous_sum[14] + previous_sum[15] * previous_sum[15] + previous_sum[16] * previous_sum[16] + previous_sum[17] * previous_sum[17] + previous_sum[18] * previous_sum[18]; previous_sum[7] = 0; previous_sum[6] = 0; previous_sum[5] = 0; previous_sum[4] = 0; previous_sum[3] = 0; previous_sum[2] = 0; previous_sum[1] = 0; previous_sum[0] = 0; } else if (n % 10000000 == 0) { previous_sum[7]++; sum_counter = previous_sum[7] + previous_sum[8] + previous_sum[9] + previous_sum[10] + previous_sum[11] + previous_sum[12] + previous_sum[13] + previous_sum[14] + previous_sum[15] + previous_sum[16] + previous_sum[17] + previous_sum[18]; sum_square_counter = previous_sum[7] * previous_sum[7] + previous_sum[8] * previous_sum[8] + previous_sum[9] * previous_sum[9] + previous_sum[10] * previous_sum[10] + previous_sum[11] * previous_sum[11] + previous_sum[12] * previous_sum[12] + previous_sum[13] * previous_sum[13] + previous_sum[14] * previous_sum[14] + previous_sum[15] * previous_sum[15] + previous_sum[16] * previous_sum[16] + previous_sum[17] * previous_sum[17] + previous_sum[18] * previous_sum[18]; previous_sum[6] = 0; previous_sum[5] = 0; previous_sum[4] = 0; previous_sum[3] = 0; previous_sum[2] = 0; previous_sum[1] = 0; previous_sum[0] = 0; } else if (n % 1000000 == 0) { previous_sum[6]++; sum_counter = previous_sum[6] + previous_sum[7] + previous_sum[8] + previous_sum[9] + previous_sum[10] + previous_sum[11] + previous_sum[12] + previous_sum[13] + previous_sum[14] + previous_sum[15] + previous_sum[16] + previous_sum[17] + previous_sum[18]; sum_square_counter = previous_sum[6] * previous_sum[6] + previous_sum[7] * previous_sum[7] + previous_sum[8] * previous_sum[8] + previous_sum[9] * previous_sum[9] + previous_sum[10] * previous_sum[10] + previous_sum[11] * previous_sum[11] + previous_sum[12] * previous_sum[12] + previous_sum[13] * previous_sum[13] + previous_sum[14] * previous_sum[14] + previous_sum[15] * previous_sum[15] + previous_sum[16] * previous_sum[16] + previous_sum[17] * previous_sum[17] + previous_sum[18] * previous_sum[18]; previous_sum[5] = 0; previous_sum[4] = 0; previous_sum[3] = 0; previous_sum[2] = 0; previous_sum[1] = 0; previous_sum[0] = 0; } else if (n % 100000 == 0) { previous_sum[5]++; sum_counter = previous_sum[5] + previous_sum[6] + previous_sum[7] + previous_sum[8] + previous_sum[9] + previous_sum[10] + previous_sum[11] + previous_sum[12] + previous_sum[13] + previous_sum[14] + previous_sum[15] + previous_sum[16] + previous_sum[17] + previous_sum[18]; sum_square_counter = previous_sum[5] * previous_sum[5] + previous_sum[6] * previous_sum[6] + previous_sum[7] * previous_sum[7] + previous_sum[8] * previous_sum[8] + previous_sum[9] * previous_sum[9] + previous_sum[10] * previous_sum[10] + previous_sum[11] * previous_sum[11] + previous_sum[12] * previous_sum[12] + previous_sum[13] * previous_sum[13] + previous_sum[14] * previous_sum[14] + previous_sum[15] * previous_sum[15] + previous_sum[16] * previous_sum[16] + previous_sum[17] * previous_sum[17] + previous_sum[18] * previous_sum[18]; previous_sum[4] = 0; previous_sum[3] = 0; previous_sum[2] = 0; previous_sum[1] = 0; previous_sum[0] = 0; } else if (n % 10000 == 0) { previous_sum[4]++; sum_counter = previous_sum[4] + previous_sum[5] + previous_sum[6] + previous_sum[7] + previous_sum[8] + previous_sum[9] + previous_sum[10] + previous_sum[11] + previous_sum[12] + previous_sum[13] + previous_sum[14] + previous_sum[15] + previous_sum[16] + previous_sum[17] + previous_sum[18]; sum_square_counter = previous_sum[4] * previous_sum[4] + previous_sum[5] * previous_sum[5] + previous_sum[6] * previous_sum[6] + previous_sum[7] * previous_sum[7] + previous_sum[8] * previous_sum[8] + previous_sum[9] * previous_sum[9] + previous_sum[12] * previous_sum[12] + previous_sum[13] * previous_sum[13] + previous_sum[14] * previous_sum[14] + previous_sum[15] * previous_sum[15] + previous_sum[16] * previous_sum[16] + previous_sum[17] * previous_sum[17] + previous_sum[18] * previous_sum[18]; previous_sum[3] = 0; previous_sum[2] = 0; previous_sum[1] = 0; previous_sum[0] = 0; } else if (n % 1000 == 0) { previous_sum[3]++; sum_counter = previous_sum[3] + previous_sum[4] + previous_sum[5] + previous_sum[6] + previous_sum[7] + previous_sum[8] + previous_sum[9] + previous_sum[10] + previous_sum[11] + previous_sum[12] + previous_sum[13] + previous_sum[14] + previous_sum[15] + previous_sum[16] + previous_sum[17] + previous_sum[18]; sum_square_counter = previous_sum[3] * previous_sum[3] + previous_sum[4] * previous_sum[4] + previous_sum[5] * previous_sum[5] + previous_sum[6] * previous_sum[6] + previous_sum[7] * previous_sum[7] + previous_sum[8] * previous_sum[8] + previous_sum[9] * previous_sum[9] + previous_sum[10] * previous_sum[10] + previous_sum[11] * previous_sum[11] + previous_sum[12] * previous_sum[12] + previous_sum[13] * previous_sum[13] + previous_sum[14] * previous_sum[14] + previous_sum[15] * previous_sum[15] + previous_sum[16] * previous_sum[16] + previous_sum[17] * previous_sum[17] + previous_sum[18] * previous_sum[18]; previous_sum[2] = 0; previous_sum[1] = 0; previous_sum[0] = 0; } else if (n % 100 == 0) { previous_sum[2]++; sum_counter = previous_sum[2] + previous_sum[3] + previous_sum[4] + previous_sum[5] + previous_sum[6] + previous_sum[7] + previous_sum[8] + previous_sum[9] + previous_sum[10] + previous_sum[11] + previous_sum[12] + previous_sum[13] + previous_sum[14] + previous_sum[15] + previous_sum[16] + previous_sum[17] + previous_sum[18]; sum_square_counter = previous_sum[2] * previous_sum[2] + previous_sum[3] * previous_sum[3] + previous_sum[4] * previous_sum[4] + previous_sum[5] * previous_sum[5] + previous_sum[6] * previous_sum[6] + previous_sum[7] * previous_sum[7] + previous_sum[8] * previous_sum[8] + previous_sum[9] * previous_sum[9] + previous_sum[10] * previous_sum[10] + previous_sum[11] * previous_sum[11] + previous_sum[12] * previous_sum[12] + previous_sum[13] * previous_sum[13] + previous_sum[14] * previous_sum[14] + previous_sum[15] * previous_sum[15] + previous_sum[16] * previous_sum[16] + previous_sum[17] * previous_sum[17] + previous_sum[18] * previous_sum[18]; previous_sum[1] = 0; previous_sum[0] = 0; } else if (n % 10 == 0) { previous_sum[1]++; sum_counter = previous_sum[1] + previous_sum[2] + previous_sum[3] + previous_sum[4] + previous_sum[5] + previous_sum[6] + previous_sum[7] + previous_sum[8] + previous_sum[9] + previous_sum[10] + previous_sum[11] + previous_sum[12] + previous_sum[13] + previous_sum[14] + previous_sum[15] + previous_sum[16] + previous_sum[17] + previous_sum[18]; sum_square_counter = previous_sum[1] * previous_sum[1] + previous_sum[2] * previous_sum[2] + previous_sum[3] * previous_sum[3] + previous_sum[4] * previous_sum[4] + previous_sum[5] * previous_sum[5] + previous_sum[6] * previous_sum[6] + previous_sum[7] * previous_sum[7] + previous_sum[8] * previous_sum[8] + previous_sum[9] * previous_sum[9] + previous_sum[10] * previous_sum[10] + previous_sum[11] * previous_sum[11] + previous_sum[12] * previous_sum[12] + previous_sum[13] * previous_sum[13] + previous_sum[14] * previous_sum[14] + previous_sum[15] * previous_sum[15] + previous_sum[16] * previous_sum[16] + previous_sum[17] * previous_sum[17] + previous_sum[18] * previous_sum[18]; previous_sum[0] = 0; } else { sum_counter++; sum_square_counter += ((n - 1) % 10) * 2 + 1; } // get_sum_and_sum_square_digits(n, sum, sum_square); // assert(sum == sum_counter && sum_square == sum_square_counter); if (prime_table[sum_counter] && prime_table[sum_square_counter]) { lucky_counter++; } } return lucky_counter; } void inout_lucky_numbers() { int n; cin >> n; long long a; long long b; while (n--) { cin >> a >> b; cout << count_lucky_number(a, b) << endl; } } int main() { inout_lucky_numbers(); return 0; }

    Read the article

  • How to implement tokenizer.rbegin() and rend() for boost::tokenizer ?

    - by Chan
    Hello everyone, I'm playing around with boost::tokenizer however I realize that it does not support rbegin() and rend(). I would like to ask how can I add these two functions to the existing class? This is from the boost site: #include <iostream> #include <string> #include <boost/tokenizer.hpp> using namespace std; using namespace boost; int main() { string str( "12/12/1986" ); typedef boost::tokenizer<boost::char_separator<char>> tokenizer; boost::char_separator<char> sep( "/" ); tokenizer tokens( str, sep ); cout << *tokens.begin() << endl; // cout << *tokens.rbegin() << endl; How could I implement this? return 0; }

    Read the article

  • Securing an ASP.NET MVC 2 Application

    - by rajbk
    This post attempts to look at some of the methods that can be used to secure an ASP.NET MVC 2 Application called Northwind Traders Human Resources.  The sample code for the project is attached at the bottom of this post. We are going to use a slightly modified Northwind database. The screen capture from SQL server management studio shows the change. I added a new column called Salary, inserted some random salaries for the employees and then turned off AllowNulls.   The reporting relationship for Northwind Employees is shown below.   The requirements for our application are as follows: Employees can see their LastName, FirstName, Title, Address and Salary Employees are allowed to edit only their Address information Employees can see the LastName, FirstName, Title, Address and Salary of their immediate reports Employees cannot see records of non immediate reports.  Employees are allowed to edit only the Salary and Title information of their immediate reports. Employees are not allowed to edit the Address of an immediate report Employees should be authenticated into the system. Employees by default get the “Employee” role. If a user has direct reports, they will also get assigned a “Manager” role. We use a very basic empId/pwd scheme of EmployeeID (1-9) and password test$1. You should never do this in an actual application. The application should protect from Cross Site Request Forgery (CSRF). For example, Michael could trick Steven, who is already logged on to the HR website, to load a page which contains a malicious request. where without Steven’s knowledge, a form on the site posts information back to the Northwind HR website using Steven’s credentials. Michael could use this technique to give himself a raise :-) UI Notes The layout of our app looks like so: When Nancy (EmpID 1) signs on, she sees the default page with her details and is allowed to edit her address. If Nancy attempts to view the record of employee Andrew who has an employeeID of 2 (Employees/Edit/2), she will get a “Not Authorized” error page. When Andrew (EmpID 2) signs on, he can edit the address field of his record and change the title and salary of employees that directly report to him. Implementation Notes All controllers inherit from a BaseController. The BaseController currently only has error handling code. When a user signs on, we check to see if they are in a Manager role. We then create a FormsAuthenticationTicket, encrypt it (including the roles that the employee belongs to) and add it to a cookie. private void SetAuthenticationCookie(int employeeID, List<string> roles) { HttpCookiesSection cookieSection = (HttpCookiesSection) ConfigurationManager.GetSection("system.web/httpCookies"); AuthenticationSection authenticationSection = (AuthenticationSection) ConfigurationManager.GetSection("system.web/authentication"); FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket( 1, employeeID.ToString(), DateTime.Now, DateTime.Now.AddMinutes(authenticationSection.Forms.Timeout.TotalMinutes), false, string.Join("|", roles.ToArray())); String encryptedTicket = FormsAuthentication.Encrypt(authTicket); HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); if (cookieSection.RequireSSL || authenticationSection.Forms.RequireSSL) { authCookie.Secure = true; } HttpContext.Current.Response.Cookies.Add(authCookie); } We read this cookie back in Global.asax and set the Context.User to be a new GenericPrincipal with the roles we assigned earlier. protected void Application_AuthenticateRequest(Object sender, EventArgs e){ if (Context.User != null) { string cookieName = FormsAuthentication.FormsCookieName; HttpCookie authCookie = Context.Request.Cookies[cookieName]; if (authCookie == null) return; FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value); string[] roles = authTicket.UserData.Split(new char[] { '|' }); FormsIdentity fi = (FormsIdentity)(Context.User.Identity); Context.User = new System.Security.Principal.GenericPrincipal(fi, roles); }} We ensure that a user has permissions to view a record by creating a custom attribute AuthorizeToViewID that inherits from ActionFilterAttribute. public class AuthorizeToViewIDAttribute : ActionFilterAttribute{ IEmployeeRepository employeeRepository = new EmployeeRepository(); public override void OnActionExecuting(ActionExecutingContext filterContext) { if (filterContext.ActionParameters.ContainsKey("id") && filterContext.ActionParameters["id"] != null) { if (employeeRepository.IsAuthorizedToView((int)filterContext.ActionParameters["id"])) { return; } } throw new UnauthorizedAccessException("The record does not exist or you do not have permission to access it"); }} We add the AuthorizeToView attribute to any Action method that requires authorization. [HttpPost][Authorize(Order = 1)]//To prevent CSRF[ValidateAntiForgeryToken(Salt = Globals.EditSalt, Order = 2)]//See AuthorizeToViewIDAttribute class[AuthorizeToViewID(Order = 3)] [ActionName("Edit")]public ActionResult Update(int id){ var employeeToEdit = employeeRepository.GetEmployee(id); if (employeeToEdit != null) { //Employees can edit only their address //A manager can edit the title and salary of their subordinate string[] whiteList = (employeeToEdit.IsSubordinate) ? new string[] { "Title", "Salary" } : new string[] { "Address" }; if (TryUpdateModel(employeeToEdit, whiteList)) { employeeRepository.Save(employeeToEdit); return RedirectToAction("Details", new { id = id }); } else { ModelState.AddModelError("", "Please correct the following errors."); } } return View(employeeToEdit);} The Authorize attribute is added to ensure that only authorized users can execute that Action. We use the TryUpdateModel with a white list to ensure that (a) an employee is able to edit only their Address and (b) that a manager is able to edit only the Title and Salary of a subordinate. This works in conjunction with the AuthorizeToViewIDAttribute. The ValidateAntiForgeryToken attribute is added (with a salt) to avoid CSRF. The Order on the attributes specify the order in which the attributes are executed. The Edit View uses the AntiForgeryToken helper to render the hidden token: ......<% using (Html.BeginForm()) {%><%=Html.AntiForgeryToken(NorthwindHR.Models.Globals.EditSalt)%><%= Html.ValidationSummary(true, "Please correct the errors and try again.") %><div class="editor-label"> <%= Html.LabelFor(model => model.LastName) %></div><div class="editor-field">...... The application uses View specific models for ease of model binding. public class EmployeeViewModel{ public int EmployeeID; [Required] [DisplayName("Last Name")] public string LastName { get; set; } [Required] [DisplayName("First Name")] public string FirstName { get; set; } [Required] [DisplayName("Title")] public string Title { get; set; } [Required] [DisplayName("Address")] public string Address { get; set; } [Required] [DisplayName("Salary")] [Range(500, double.MaxValue)] public decimal Salary { get; set; } public bool IsSubordinate { get; set; }} To help with displaying readonly/editable fields, we use a helper method. //Simple extension method to display a TextboxFor or DisplayFor based on the isEditable variablepublic static MvcHtmlString TextBoxOrLabelFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, bool isEditable){ if (isEditable) { return htmlHelper.TextBoxFor(expression); } else { return htmlHelper.DisplayFor(expression); }} The helper method is used in the view like so: <%=Html.TextBoxOrLabelFor(model => model.Title, Model.IsSubordinate)%> As mentioned in this post, there is a much easier way to update properties on an object. Download Demo Project VS 2008, ASP.NET MVC 2 RTM Remember to change the connectionString to point to your Northwind DB NorthwindHR.zip Feedback and bugs are always welcome :-)

    Read the article

  • Domain name rewriting and URL rewriting in the meantime in .htaccess

    - by Steven
    Ugly URLs: www.domainname.com/en/piece/piece.php?piece_id=1 www.domainname.com/en/piece/piece.php?piece_id=2 www.domainname.com/en/piece/piece.php?piece_id=3 ... Friendly URLs: piece.domainname.com/en/1 piece.domainname.com/en/2 piece.domainname.com/en/3 ... I want to present website users only friendly URLs. When I apply RewriteEngine On RewriteRule ^en/([^/]*)$ /en/piece/piece.php?piece_id=$1 [L] only the URL is rewrote.Besides the CSS file can not be found in web page of the friendly URL. How to rewrite the domain name and the URL in the meantime? Do I have to use RedirectMatch, if so, how to do it?

    Read the article

  • Domain name rewriting and URL rewriting in the meantime in .htaccess

    - by Steven
    Ugly URLs: www.domainname.com/en/piece/piece.php?piece_id=1 www.domainname.com/en/piece/piece.php?piece_id=2 www.domainname.com/en/piece/piece.php?piece_id=3 ... Friendly URLs: piece.domainname.com/en/1 piece.domainname.com/en/2 piece.domainname.com/en/3 ... When I apply RewriteEngine On RewriteRule ^en/([^/]*)$ /en/piece/piece.php?piece_id=$1 [L] only the URL is rewrote.Besides the CSS file can not be found in web page of the friendly URL. How to rewrite the domain name and the URL in the meantime? Do I have to use RedirectMatch, if so, how to do it?

    Read the article

  • ERROR [01000] [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect())

    - by Steven Morrison
    Our company had resently upgraded to a domain functionality from workgroup and now we get this error message shown below on the clients laptops. The software on the server is working as it was opening the SECWARE application and a successful login to the database is possible.But from our workstations we cannot access the database to get the login screen. error in DB_OpenDS: ERROR [08001] [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. ERROR [01000] [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). OpenFolder Error :ERROR [08001] [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. ERROR [01000] [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). exiting with error Cannot find table 0. exiting with error We have a network share that we used to get the login file from and that is accessible.

    Read the article

  • How to create a virtual audio device and stream audio input with it

    - by Steven Rosato
    Is it possible to create another audio device and redirect only wanted input streams to it? Here's my concrete problem: I am broadcasting a game via XFire and it uses the Windows audio device to capture any audio I receive. As I am broadcasting, other users who watch the video stream are communicating with me over Skype, and they hear themselves back within the video stream and it is entirely logical since I am broadcasting the audio I hear. What I want to do is create another audio device within Windows and redirect (pipe) ONLY the audio input from that game and not the input reveived from Skype. I would then tell XFire to use that newly created "virtual" audio device to broadcast and therefore my partners won't hear themselves back. Is there any software that can do that or can it be achieved natively with Windows? (I am under Windows 7).

    Read the article

  • Coldfusion on VPS, how much JVM heap memory?

    - by Steven Filipowicz
    Recently I got a VPS server and I'm running Coldfusion, the website was running fine until it got more and more traffic and I started to encounter 'OutOfMemory' exceptions. I thought simply to rise the memory of the VPS server, but this didn't help. After doing some Google searches I found a setting in de CF Admin settings to set the JVM Heap memory. It was on the standard: Max Heap size 512MB and Min Heap size was empty. After playing around a bit I have now set it to Min 50MB and Max 200MB, good things is that I'm not getting the 'OutOfMemory' exceptions anymore. So far so good! But with about 50 active visitors on the website, the website starts to get slow. The CPU usage is only about 8% (Windows Taskmanager), also the taskmanager show only about 30% of the 3GB RAM in use. So I'm thinking that my values could be tweaked to use more of the RAM. Honestly I don't understand these JVM Memory heap settings, so I have no clue what is a good setting for me. I found a CF script that displays the memory usage, the details are: Heap Memory Usage - Committed 194 MB Heap Memory Usage - Initial 50.0 MB Heap Memory Usage - Max 194 MB Heap Memory Usage - Used 163 MB JVM - Free Memory 31.2 MB JVM - Max Memory 194 MB JVM - Total Memory 194 MB JVM - Used Memory 163 MB Memory Pool - Code Cache - Used 13.0 MB Memory Pool - PS Eden Space - Used 6.75 MB Memory Pool - PS Old Gen - Used 155 MB Memory Pool - PS Perm Gen - Used 64.2 MB Memory Pool - PS Survivor Space - Used 1.07 MB Non-Heap Memory Usage - Committed 77.4 MB Non-Heap Memory Usage - Initial 18.3 MB Non-Heap Memory Usage - Max 240 MB Non-Heap Memory Usage - Used 77.2 MB Free Allocated Memory: 30mb Total Memory Allocated: 194mb Max Memory Available to JVM: 194mb % of Free Allocated Memory: 16% % of Available Memory Allocated: 100% My JVM arguments are: -server -Dsun.io.useCanonCaches=false -XX:MaxPermSize=192m -XX:+UseParallelGC - Dcoldfusion.rootDir={application.home}/../ -Dcoldfusion.libPath={application.home}/../lib Can I give the JVM more memory? If so, what settings should I use? Thanks very much!!

    Read the article

  • URL rewriting in .htaccess

    - by Steven
    Ugly URLs: www.domainname.com/en/piece/piece.php?piece_id=1 www.domainname.com/en/piece/piece.php?piece_id=2 www.domainname.com/en/piece/piece.php?piece_id=3 ... Friendly URLs: piece.domainname.com/en/1 piece.domainname.com/en/2 piece.domainname.com/en/3 ... I want to present website users only friendly URLs. How to do it? Do I have to use RedirectMatch, if so, how to do it?

    Read the article

  • SQLAuthority Book Review – Professional SQL Server 2008 Internals and Troubleshooting

    - by pinaldave
    Professional SQL Server 2008 Internals and Troubleshooting by Christian Bolton, Justin Langford, Brent Ozar, James Rowland-Jones, Steven Wort Link to Amazon (Worldwide) Link to Flipkart (India) Brief Review: Having a book on internal and associating that with real life is “almost” an impossible task. The reason for using the word “almost” is because this book has accomplished this [...]

    Read the article

  • Site-to-site VPN using MD5 instead of SHA and getting regular disconnection

    - by Steven
    We are experiencing some strange behavior with a site-to-site IPsec VPN that goes down about every week for 30 minutes (Iam told 30 minutes exactly). I don't have access to the logs, so it's difficult to troubleshoot. What is also strange is that the two VPN devices are set to use SHA hash algorithm but apparently end up agreeing to use MD5. Does anybody have a clue? or is this just insufficient information?

    Read the article

  • 7 Habits of Highly Effective Media Queries - by Brad Frost

    - by ihaynes
    Originally posted on: http://geekswithblogs.net/ihaynes/archive/2013/10/11/7-habits-of-highly-effective-media-queries---by-brad.aspxBrad Frost, one of the original proponents of responsive design, has written a great article on the "7 Habits of Highly Effective Media Queries".Let content determine breakpointsTreat layout as an enhancementUse major and minor breakpointsUse relative unitsGo beyond widthUse media queries for conditional loadingDon't go overboardGot you wondering? Read Brad's full article.Oh, and if you haven't read Steven Covey's original "7 Habits of Highly Effective People" book, it's a valuable read too, and might just change the way you relate to others and the world around you.

    Read the article

  • Customize Firefox Status Bar?

    - by Steven Penny
    For web browsing I use Pale Moon. Pale Moon has a Status Bar, similar to what is now known as the Add-on Bar in Firefox. With Pale Moon when I hover over a link URL is shown in the status bar URL is shown instantly Entire width of status bar is allowed for URL, if necessary With Firefox when I hover over a link URL is shown in a tooltip in lower left corner URL is shown after intentional delay Only half the browser window width is allowed for URL Is there a way to make Firefox behave more like Pale Moon? No Status-4-Evar answers I realize Status-4-Evar might be the best solution here but I wish to see what, if any other options are out there. I will also accept well thought out and referenced answers as to why the Firefox way is "better".

    Read the article

  • SQLAuthority Book Review Professional SQL Server 2008 Internals and Troubleshooting

    Professional SQL Server 2008 Internals and Troubleshooting by Christian Bolton, Justin Langford, Brent Ozar, James Rowland-Jones, Steven WortLink to Amazon (Worldwide)Link to Flipkart (India)Brief Review: Having a book on internal and associating that with real life is almost an impossible task. The reason for using the word almost is because this book has accomplished this [...]...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Windows 2008 R2 SMB / CIFS Logging to diagnose Brother MFC Network Scanning

    - by Steven Potter
    I am attempting to setup network scanning on a brother MFC-9970CDW printer. According to the Brother documentation, the printer is setup to connect to any CIFS network share. I applied all of the appropriate setting in the printer however I get a "sending error" when I try to scan a document. When I look at the logs of the 2008 R2 server that I am attempting to connect to; I can see in the security log where the printer successfully authenticates, however nothing else is logged. I would assume that immediately after the authentication, the printer is making a CIFS request and some sort of error is occurring, however I can't seem to find any way to log this information to find out what is going on. Is it possible to get Windows 2008 to log SMB/CIFS traffic? Followup: I installed Microsoft netmon and captured the packets associated with the transaction: 510 3:04:28 PM 7/9/2012 34.4277743 System 192.168.1.134 192.168.1.10 SMB SMB:C; Negotiate, Dialect = NT LM 0.12 {SMBOverTCP:30, TCP:29, IPv4:22} 511 3:04:28 PM 7/9/2012 34.4281246 System 192.168.1.10 192.168.1.134 SMB SMB:R; Negotiate, Dialect is NT LM 0.12 (#0), SpnegoToken (1.3.6.1.5.5.2) {SMBOverTCP:30, TCP:29, IPv4:22} 519 3:04:29 PM 7/9/2012 34.8986214 System 192.168.1.134 192.168.1.10 SMB SMB:C; Session Setup Andx, NTLM NEGOTIATE MESSAGE {SMBOverTCP:30, TCP:29, IPv4:22} 520 3:04:29 PM 7/9/2012 34.8989310 System 192.168.1.10 192.168.1.134 SMB SMB:R; Session Setup Andx, NTLM CHALLENGE MESSAGE - NT Status: System - Error, Code = (22) STATUS_MORE_PROCESSING_REQUIRED {SMBOverTCP:30, TCP:29, IPv4:22} 522 3:04:29 PM 7/9/2012 34.9022870 System 192.168.1.134 192.168.1.10 SMB SMB:C; Session Setup Andx, NTLM AUTHENTICATE MESSAGEVersion:v2, Domain: CORP, User: PRINTSUPOFF, Workstation: BRN001BA9AD1FE6 {SMBOverTCP:30, TCP:29, IPv4:22} 523 3:04:29 PM 7/9/2012 34.9032421 System 192.168.1.10 192.168.1.134 SMB SMB:R; Session Setup Andx {SMBOverTCP:30, TCP:29, IPv4:22} 525 3:04:29 PM 7/9/2012 34.9051855 System 192.168.1.134 192.168.1.10 SMB SMB:C; Tree Connect Andx, Path = \\192.168.1.10\IPC$, Service = ????? {SMBOverTCP:30, TCP:29, IPv4:22} 526 3:04:29 PM 7/9/2012 34.9053083 System 192.168.1.10 192.168.1.134 SMB SMB:R; Tree Connect Andx, Service = IPC {SMBOverTCP:30, TCP:29, IPv4:22} 528 3:04:29 PM 7/9/2012 34.9073573 System 192.168.1.134 192.168.1.10 DFSC DFSC:Get DFS Referral Request, FileName: \\192.168.1.10\NSCFILES, MaxReferralLevel: 3 {SMB:33, SMBOverTCP:30, TCP:29, IPv4:22} 529 3:04:29 PM 7/9/2012 34.9152042 System 192.168.1.10 192.168.1.134 SMB SMB:R; Transact2, Get Dfs Referral - NT Status: System - Error, Code = (549) STATUS_NOT_FOUND {SMB:33, SMBOverTCP:30, TCP:29, IPv4:22} 531 3:04:29 PM 7/9/2012 34.9169738 System 192.168.1.134 192.168.1.10 SMB SMB:C; Tree Disconnect {SMBOverTCP:30, TCP:29, IPv4:22} 532 3:04:29 PM 7/9/2012 34.9170688 System 192.168.1.10 192.168.1.134 SMB SMB:R; Tree Disconnect {SMBOverTCP:30, TCP:29, IPv4:22} As you can see, the DFS referral fails and the transaction is shut down. I can't see any reason for the DFS referral to fail. The only reference I can find online is: https://bugzilla.samba.org/show_bug.cgi?id=8003 Anyone have any ideas for a solution?

    Read the article

  • How do I access the web server on my desktop from my laptop?

    - by Steven
    I'm running Apache on my stationary and I would like to access a website through my laptop. This is some of the Apache config: NameVirtualHost 127.0.0.1:80 <VirtualHost 127.0.0.1:80> ServerName mysite.com DocumentRoot I:/wamp/www/mysite/ </VirtualHost> ServerName localhost:80 <Directory /> Options FollowSymLinks AllowOverride all Order deny,allow Deny from all </Directory> On my laptop I've added the following to the HOSTS file: 10.0.0.3 mysite.com But accessing the page through mysite.com is not very successfull. If I enter the IP address directly, I only get a Forbidden message. What do I need to do in order to get this to work? Update I'm runing WAMPSERVER 2.1 (Apache 2.2.17) Apache is up and running I can ping 10.0.0.3 from laptop I'm not able to ping http://mysite.com from laptop IE gives me a 403 Forbidden - The website declined to show this webpage The only log that get's entries when trying to access the website from my laptop, is access.log. access.log 10.0.0.4 - - [13/Jun/2011:10:14:04 +0200] "GET / HTTP/1.1" 403 202 apache_error.log [Mon Jun 13 10:08:16 2011] [error] VirtualHost localhost:0 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results UPDATE 2 My apache config has the following entry: AllowOverride all Order Deny,Allow Deny from all Allow from 127.0.0.1 Could it be that this Allow from is stopping other computers accessing the page?

    Read the article

  • VPN Device behind router/firewall

    - by David Steven
    ROUTER A: Peplink 310 serving as the gateway/router/firewall at one location. ROUTER B: Linksys RV082 serving as the gateway/router/firewall at another location. I want to VPN these two locations together. The Peplink has a PPTP server and has proprietary site-to-site vpn if you had another peplink device. The Linksys has an IPsec vpn server. VPN A: I also have another spare linksys rv082. I'm trying to setup the other rv082 (VPN A) behind the peplink (ROUTER A) and get VPN A to talk to ROUTER B. I setup VPN A with a lan ip address and plugged one of it's LAN ports into the LAN. I was able to get to it's web interface fine. On ROUTER A I one-to-one nat mapped one of our public ip's to the LAN IP for VPN A. I opened TCP 50-51 and UDP 500 to VPN A. I configured the VPN settings on VPN A to connect to ROUTER B. I did the opposite for ROUTER B. But the vpn doesn't connect. Then I tried pluging VPN A's wan port into the lan, and gave it another LAN IP. I thought perpahs VPN A didn't want to send VPN traffic out over the LAN and wanted do send it over it's WAN. The vpn still doesn't connect. It what I'm trying to do even possible?

    Read the article

  • Some thoughts on the Virtualization Feedback in the SSWUG Newsletters

    - by Jonathan Kehayias
    Last Thursday, March 25, 2010, the topic of Virtualization of SQL Server came up in the SSWUG Newsletter , with Steven Wynkoop asking if peoples perceptions and experiences have changed since the last time he covered virtualizing SQL Server.  I unfortunately missed the last coverage of this topic, but it appears from the newsletter that there was a general consensus that “low-traffic solution could be fine, but if you had a heavy hitting application, the net advise was to avoid a virtual environment...(read more)

    Read the article

  • Some thoughts on the Virtualization Feedback in the SSWUG Newsletters

    - by Jonathan Kehayias
    Last Thursday, March 25, 2010, the topic of Virtualization of SQL Server came up in the SSWUG Newsletter , with Steven Wynkoop asking if peoples perceptions and experiences have changed since the last time he covered virtualizing SQL Server.  I unfortunately missed the last coverage of this topic, but it appears from the newsletter that there was a general consensus that “low-traffic solution could be fine, but if you had a heavy hitting application, the net advise was to avoid a virtual environment...(read more)

    Read the article

  • Using watch to run a shell script - but the script goes defunct

    - by PHP-Steven
    So I want to keep an eye on my network connectivity so I can make a report for my ISP. (seems like the modem goes out for about 30-60 seconds about once a day) So I copied this handy little script http://www.cyberciti.biz/tips/simple-linux-and-unix-system-monitoring-with-ping-command-and-scripts.html And an running it with watch -n 15 ./ping-test.sh I have been testing it by pulling the plug on my modem. The first time watch runs the script after the network goes out it runs fine (sends some email) and then goes defunct. Once networking is restored the script "finishes" and then watch runs it again. So I'm getting mail for when the network goes down, but not how long it was down for. If I run the script straight from the command line it runs (emails) and then exits. Any ideas why? How can I get the script to keep running once the network is down?

    Read the article

  • Wi-Fi performance in Windows 8 RP on a MacBook Air (mid 2011)

    - by Steven Lu
    I was able to install the Boot Camp Windows software using the executable that it provided, and there are no unrecognized or unknown devices in Device Manager. Wi-Fi works but it seems to be limited to an extremely slow 1.5Mbits. Network Center reports an 802.11n connection (at 65Mbps usually) but transfers never reach above about 200kB/s. Being limited to 1/20th of the connection speed of my internet service is quite frustrating. Does anybody experience the same issue? I have been trying to identify the Broadcom Wi-Fi chipset and a driver that I could try to upgrade to but I have made very little progress on Google on this front.

    Read the article

  • cygwin ssh connection to server port 22 connection refused on localhost

    - by Steven Wexler
    I set up a ssh server through ssh-host-config. Then I started the server. net start sshd The CYGWIN sshd service is starting. The CYGWIN sshd service was started successfully. When I try to connect I get: ssh myusername@localhost ssh: connect to host localhost port 22: Connection refused I tried to allow port 22 in Windows Firewall, but that didn't change anything. And because I'm trying to ssh locally I don't think Windows Firewall is the culprit. I'm using Windows 7 and What should I look for to fix this problem?

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >