Search Results

Search found 29841 results on 1194 pages for 'random number generator'.

Page 14/1194 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Insert lecture number and page number of lecture in footline

    - by Liam
    I am dividing a semester's worth of lectures via the \lecture command. I'd like to have in the footline (among other things) the lecture number, date, and page number of the current lecture. I would also like to use the default style footline, with the black box on the left and the blue on the right. So I define a lecture with e.g. \lecture{January 28, 2010}{lecture01} with \title[Lecture \insertlecturenumber{}(\insertlecture)\quad{}Page \insertframenumber]{Course Title} in the preamble, I get an error; it will not accept \insertlecture there. If I remove \insertlecture, it does what I want, except that the page number is counted from the start of the semester, not the lecture. Is there any way to do this? Thank you. Liam

    Read the article

  • Rounding a positive number to a power of another number

    - by Sagekilla
    I'm trying to round a number to the next smallest power of another number. The number I'm trying to round is always positive. I'm not particular on which direction it rounds, but I prefer downwards if possible. I would like to be able to round towards arbitrary bases, but the ones I'm most concerned with at the moment is base 2 and fractional powers of 2 like 2^(1/2), 2^(1/4), and so forth. Here's my current algorithm for base 2. The log2 I multiply by is actually the inverse of log2: double roundBaseTwo(double x) { return 1.0 / (1 << (int)((log(x) * log2)) } Any help would be appreciated!

    Read the article

  • convert javascript number to css value -- maximum number of trailing decimals

    - by philipp
    I am about to have some fun with the css transform matrix and javascript. At the moment everything is cool, except when a number becomes something like 0.000034e3344 after the to string conversion. Than the transform does not work. So I know that there is the Number.toFixed() method which actually solves the problem, but i ask myself how many trailing decimals make sense. So what is the highest value i can pass to the toFixed() method to get the most precise results? EDIT::: the exact number output was: 9.685539407532573e-20

    Read the article

  • Static site generator with web-based file manager?

    - by user234
    I'm checking around options of static web site generators which led me to lots of articles about them! However, no word is spoken on how to edit files through a browser; it's always assumed you have either DropBox or some FTPish or terminal access. The only generator I could find that includes a browser based admin screen is Kirby (getkirby.com, mentioned at modernstatic.com) Besides the application above, what setup would you recommend to have both static HTML generation and web-based file management? Thanks!

    Read the article

  • Basic procedural generated content works, but how could I do the same in reverse?

    - by andrew
    My 2D world is made up of blocks. At the moment, I create a block and assign it a number between 1 and 4. The number assigned to the nth block is always the same (i.e if the player walks backwards or restarts the game.) and is generated in the function below. As shown here by this animation, the colours represent the number. function generate_data(n) math.randomseed(n) -- resets the random so that the 'random' number for n is always the same math.random() -- fixes lua random bug local no = math.random(4) --print(no, n) return no end Now I want to limit the next block's number - a block of 1 will always have a block 2 after it, while block 2 will either have a block 1,2 or 3 after it, etc. Before, all the blocks data was randomly generated, initially, and then saved. This data was then loaded and used instead of being randomly called. While working this way, I could specify what the next block would be easily and it would be saved for consistency. I have now removed this saving/loading in favour of procedural generation as I realised that save whiles would get very big after travelling. Back to the present. While travelling forward (to the right), it is easy to limit what the next blocks number will be. I can generate it at the same time as the other data. The problem is when travelling backwards (to the left) I can not think of a way to load the previous block so that it is always the same. Does anyone have any ideas on how I could sort this out?

    Read the article

  • Fast and Free; SQL Scripts Manager's Script Generator

    When William produced his second article on the free tool 'SQL Scripts Manager', revealing that it worked just as well with PowerShell and Python scripts as it does with TSQL, he thought that would be the end of the series. Oh no; in response to feedback, comes a small add-in called 'Script Generator' that makes a big difference to the speed of developing and producing new scripts. The Future of SQL Server MonitoringMonitor wherever, whenever with Red Gate's SQL Monitor. See it live in action now.

    Read the article

  • form a number using consecutive numbers

    - by Mahesh
    Hi, I was puzzled with one of the question in Microsoft interview which is as given below: A function should accept a range( 3 - 21 ) and it should print all the consecutive numbers combination's to form each number as given below: 3=1+2 5=2+3 6=1+2+3 7=3+4 9=4+5 10=1+2+3+4 11=5+6 13=6+7 15=1+2+3+4+5 17=7+8 19=8+9 21=10+11 21=1+2+3+4+5+6 could you please help me in forming this sequence in C#? Thanks, Mahesh

    Read the article

  • stripping random number with substr problem

    - by Jim
    Using a random number to be included with another character. Then I want to strip out the random number and just leave the other character. I have this code that generates the random number (8 characters long) consistently. If you hit your refresh button multiple times, the “ID” field disappears even though the “Random Number” plus “ID” are still there. Not sure what is happening to the random number on refresh in the substr function. This is the code: // Begin Create Random ID Code ///////////////////////////////////////// function gRanStr1() { $length1 = 8; $characters = “0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ”; for ($p = 0; $p < $length1; $p++) { $lcrs1 .= $characters[mt_rand(0, strlen($characters)-1)]; } $lcrs9 = str_replace(' ', '', $lcrs9); return $lcrs1; } // End Create Random ID Code ///////////////////////////////////////// // Begin Decode Random ID Code ///////////////////////////////////////// $TrkR99 = "c"; $ResHeadID = gRanStr1() . $TrkR99; $ResHeadID = preg_replace('/[\s]+/',' ',$ResHeadID); echo "”; echo $ResHeadID . ” = echo of Random Number plus ID“; for($i=0; $i if ($ResHeadID == "") { ""; } else { $ResHeadID = preg_replace('/[\s]+/',' ',$ResHeadID); $TrkRa1 = substr($ResHeadID, $Index1 + 8, 1); } $dTrkRes = $TrkRa1; echo $TrkRa1 . " = echo of ID after random number stripped.“; echo “”; // End Decode Random ID Code /////////////////////////////////////////

    Read the article

  • number several equations with only one number

    - by Tim
    Hi, How can I number several equations in a align environment using only one number? For example \begin{align} w^T x_i + b \geqslant 1-\xi_i \text{ if } y_i=1, \nonumber \\ w^T x_i + b \leqslant -1+\xi_i \text{ if } y_i=-1, \end{align} The numbering will appear next to the second equation. But it would be better if it appears between the lines of the two equations. In this case how to label this group of equations for later referring to? Thanks and regards!

    Read the article

  • Algorithm to calculate the number of divisors of a given number

    - by sker
    What would be the most optimal algorithm (performance-wise) to calculate the number of divisors of a given number? It'll be great if you could provide pseudocode or a link to some example. EDIT: All the answers have been very helpful, thank you. I'm implementing the Sieve of Atkin and then I'm going to use something similar to what Jonathan Leffler indicated. The link posted by Justin Bozonier has further information on what I wanted.

    Read the article

  • Creating a dynamic proxy generator with c# – Part 4 – Calling the base method

    - by SeanMcAlinden
    Creating a dynamic proxy generator with c# – Part 1 – Creating the Assembly builder, Module builder and caching mechanism Creating a dynamic proxy generator with c# – Part 2 – Interceptor Design Creating a dynamic proxy generator with c# – Part 3 – Creating the constructors   The plan for calling the base methods from the proxy is to create a private method for each overridden proxy method, this will allow the proxy to use a delegate to simply invoke the private method when required. Quite a few helper classes have been created to make this possible so as usual I would suggest download or viewing the code at http://rapidioc.codeplex.com/. In this post I’m just going to cover the main points for when creating methods. Getting the methods to override The first two notable methods are for getting the methods. private static MethodInfo[] GetMethodsToOverride<TBase>() where TBase : class {     return typeof(TBase).GetMethods().Where(x =>         !methodsToIgnore.Contains(x.Name) &&                              (x.Attributes & MethodAttributes.Final) == 0)         .ToArray(); } private static StringCollection GetMethodsToIgnore() {     return new StringCollection()     {         "ToString",         "GetHashCode",         "Equals",         "GetType"     }; } The GetMethodsToIgnore method string collection contains an array of methods that I don’t want to override. In the GetMethodsToOverride method, you’ll notice a binary AND which is basically saying not to include any methods marked final i.e. not virtual. Creating the MethodInfo for calling the base method This method should hopefully be fairly easy to follow, it’s only function is to create a MethodInfo which points to the correct base method, and with the correct parameters. private static MethodInfo CreateCallBaseMethodInfo<TBase>(MethodInfo method) where TBase : class {     Type[] baseMethodParameterTypes = ParameterHelper.GetParameterTypes(method, method.GetParameters());       return typeof(TBase).GetMethod(        method.Name,        BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,        null,        baseMethodParameterTypes,        null     ); }   /// <summary> /// Get the parameter types. /// </summary> /// <param name="method">The method.</param> /// <param name="parameters">The parameters.</param> public static Type[] GetParameterTypes(MethodInfo method, ParameterInfo[] parameters) {     Type[] parameterTypesList = Type.EmptyTypes;       if (parameters.Length > 0)     {         parameterTypesList = CreateParametersList(parameters);     }     return parameterTypesList; }   Creating the new private methods for calling the base method The following method outline how I’ve created the private methods for calling the base class method. private static MethodBuilder CreateCallBaseMethodBuilder(TypeBuilder typeBuilder, MethodInfo method) {     string callBaseSuffix = "GetBaseMethod";       if (method.IsGenericMethod || method.IsGenericMethodDefinition)     {                         return MethodHelper.SetUpGenericMethod             (                 typeBuilder,                 method,                 method.Name + callBaseSuffix,                 MethodAttributes.Private | MethodAttributes.HideBySig             );     }     else     {         return MethodHelper.SetupNonGenericMethod             (                 typeBuilder,                 method,                 method.Name + callBaseSuffix,                 MethodAttributes.Private | MethodAttributes.HideBySig             );     } } The CreateCallBaseMethodBuilder is the entry point method for creating the call base method. I’ve added a suffix to the base classes method name to keep it unique. Non Generic Methods Creating a non generic method is fairly simple public static MethodBuilder SetupNonGenericMethod(     TypeBuilder typeBuilder,     MethodInfo method,     string methodName,     MethodAttributes methodAttributes) {     ParameterInfo[] parameters = method.GetParameters();       Type[] parameterTypes = ParameterHelper.GetParameterTypes(method, parameters);       Type returnType = method.ReturnType;       MethodBuilder methodBuilder = CreateMethodBuilder         (             typeBuilder,             method,             methodName,             methodAttributes,             parameterTypes,             returnType         );       ParameterHelper.SetUpParameters(parameterTypes, parameters, methodBuilder);       return methodBuilder; }   private static MethodBuilder CreateMethodBuilder (     TypeBuilder typeBuilder,     MethodInfo method,     string methodName,     MethodAttributes methodAttributes,     Type[] parameterTypes,     Type returnType ) { MethodBuilder methodBuilder = typeBuilder.DefineMethod(methodName, methodAttributes, returnType, parameterTypes); return methodBuilder; } As you can see, you simply have to declare a method builder, get the parameter types, and set the method attributes you want.   Generic Methods Creating generic methods takes a little bit more work. /// <summary> /// Sets up generic method. /// </summary> /// <param name="typeBuilder">The type builder.</param> /// <param name="method">The method.</param> /// <param name="methodName">Name of the method.</param> /// <param name="methodAttributes">The method attributes.</param> public static MethodBuilder SetUpGenericMethod     (         TypeBuilder typeBuilder,         MethodInfo method,         string methodName,         MethodAttributes methodAttributes     ) {     ParameterInfo[] parameters = method.GetParameters();       Type[] parameterTypes = ParameterHelper.GetParameterTypes(method, parameters);       MethodBuilder methodBuilder = typeBuilder.DefineMethod(methodName,         methodAttributes);       Type[] genericArguments = method.GetGenericArguments();       GenericTypeParameterBuilder[] genericTypeParameters =         GetGenericTypeParameters(methodBuilder, genericArguments);       ParameterHelper.SetUpParameterConstraints(parameterTypes, genericTypeParameters);       SetUpReturnType(method, methodBuilder, genericTypeParameters);       if (method.IsGenericMethod)     {         methodBuilder.MakeGenericMethod(genericArguments);     }       ParameterHelper.SetUpParameters(parameterTypes, parameters, methodBuilder);       return methodBuilder; }   private static GenericTypeParameterBuilder[] GetGenericTypeParameters     (         MethodBuilder methodBuilder,         Type[] genericArguments     ) {     return methodBuilder.DefineGenericParameters(GenericsHelper.GetArgumentNames(genericArguments)); }   private static void SetUpReturnType(MethodInfo method, MethodBuilder methodBuilder, GenericTypeParameterBuilder[] genericTypeParameters) {     if (method.IsGenericMethodDefinition)     {         SetUpGenericDefinitionReturnType(method, methodBuilder, genericTypeParameters);     }     else     {         methodBuilder.SetReturnType(method.ReturnType);     } }   private static void SetUpGenericDefinitionReturnType(MethodInfo method, MethodBuilder methodBuilder, GenericTypeParameterBuilder[] genericTypeParameters) {     if (method.ReturnType == null)     {         methodBuilder.SetReturnType(typeof(void));     }     else if (method.ReturnType.IsGenericType)     {         methodBuilder.SetReturnType(genericTypeParameters.Where             (x => x.Name == method.ReturnType.Name).First());     }     else     {         methodBuilder.SetReturnType(method.ReturnType);     }             } Ok, there are a few helper methods missing, basically there is way to much code to put in this post, take a look at the code at http://rapidioc.codeplex.com/ to follow it through completely. Basically though, when dealing with generics there is extra work to do in terms of getting the generic argument types setting up any generic parameter constraints setting up the return type setting up the method as a generic All of the information is easy to get via reflection from the MethodInfo.   Emitting the new private method Emitting the new private method is relatively simple as it’s only function is calling the base method and returning a result if the return type is not void. ILGenerator il = privateMethodBuilder.GetILGenerator();   EmitCallBaseMethod(method, callBaseMethod, il);   private static void EmitCallBaseMethod(MethodInfo method, MethodInfo callBaseMethod, ILGenerator il) {     int privateParameterCount = method.GetParameters().Length;       il.Emit(OpCodes.Ldarg_0);       if (privateParameterCount > 0)     {         for (int arg = 0; arg < privateParameterCount; arg++)         {             il.Emit(OpCodes.Ldarg_S, arg + 1);         }     }       il.Emit(OpCodes.Call, callBaseMethod);       il.Emit(OpCodes.Ret); } So in the main method building method, an ILGenerator is created from the method builder. The ILGenerator performs the following actions: Load the class (this) onto the stack using the hidden argument Ldarg_0. Create an argument on the stack for each of the method parameters (starting at 1 because 0 is the hidden argument) Call the base method using the Opcodes.Call code and the MethodInfo we created earlier. Call return on the method   Conclusion Now we have the private methods prepared for calling the base method, we have reached the last of the relatively easy part of the proxy building. Hopefully, it hasn’t been too hard to follow so far, there is a lot of code so I haven’t been able to post it all so please check it out at http://rapidioc.codeplex.com/. The next section should be up fairly soon, it’s going to cover creating the delegates for calling the private methods created in this post.   Kind Regards, Sean.

    Read the article

  • Random memory corruption going undetected by memtest86

    - by sds
    Thinkpad t520; Ubuntu 12.04.1 LTS; 3.2.0-33-generic 16GB of ram Memtest86+ ran for 26 hours, 9 passes, no errors Booted into "recovery mode"; Ran fsck all filesystems - no errors; "check all packages" - no errors apparent random memory corruption: perl/R/chrome segfault every now and then, seemingly at random; sort(1) produces corrupt unsorted files. What could be possibly wrong and how do I debug it?

    Read the article

  • SQL Server stored procedure to generate random passwords

    SQL Server is used to support many applications and one such feature of most applications is the storage of passwords. Sometimes there is a need to reset a password using a temporary password or generate a random password for a new user. In this tip I cover a simple stored procedure to generate random passwords that can be incorporated into your applications. Get Smart with SQL Backup Pro Powerful centralised management, encryption and more.SQL Backup Pro was the smartest kid at school Discover why.

    Read the article

  • Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variabl

    - by Thomas
    Hi, I'm working with PHP PDO and I have the following problem: Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in /var/www/site/classes/enterprise.php on line 63 Here is my code: public function getCompaniesByCity(City $city, $options = null) { $database = Connection::getConnection(); if(empty($options)) { $statement = $database-prepare("SELECT * FROM empresas WHERE empresas.cidades_codigo = ?"); $statement-bindValue(1, $city-getId()); } else { $sql = "SELECT * FROM empresas INNER JOIN prods_empresas ON prods_empresas.empresas_codigo = empresas.codigo WHERE "; foreach($options as $option) { $sql .= 'prods_empresas.produtos_codigo = ? OR '; } $sql = substr($sql, 0, -4); $sql .= ' AND empresas.cidades_codigo = ?'; $statement = $database-prepare($sql); echo $sql; foreach($options as $i = $option) { $statement-bindValue($i + 1, $option-getId()); } $statement-bindValue(count($options), $city-getId()); } $statement-execute(); $objects = $statement-fetchAll(PDO::FETCH_OBJ); $companies = array(); if(!empty($objects)) { foreach($objects as $object) { $data = array( 'id' = $object-codigo, 'name' = $object-nome, 'link' = $object-link, 'email' = $object-email, 'details' = $object-detalhes, 'logo' = $object-logo ); $enterprise = new Enterprise($data); array_push($companies, $enterprise); } return $companies; } } Thank you very much!

    Read the article

  • How to get element order number

    - by martin-masiar
    Hello everyone, how can i get order number of some element by javascript/jquery? <ul> <li>Anton</li> <li class="abc">Victor</li> <li class="abc">Simon</li> <li>Adam</li> <li>Peter</li> <li class="abc">Tom</li> </ul> There is 3xli with abc class. Now I need to get order(sequence) number of Simon li. Thanks in advance

    Read the article

  • T-SQL - Left Outer Joins - Filters in the where clause versus the on clause.

    - by Greg Potter
    I am trying to compare two tables to find rows in each table that is not in the other. Table 1 has a groupby column to create 2 sets of data within table one. groupby number ----------- ----------- 1 1 1 2 2 1 2 2 2 4 Table 2 has only one column. number ----------- 1 3 4 So Table 1 has the values 1,2,4 in group 2 and Table 2 has the values 1,3,4. I expect the following result when joining for Group 2: `Table 1 LEFT OUTER Join Table 2` T1_Groupby T1_Number T2_Number ----------- ----------- ----------- 2 2 NULL `Table 2 LEFT OUTER Join Table 1` T1_Groupby T1_Number T2_Number ----------- ----------- ----------- NULL NULL 3 The only way I can get this to work is if I put a where clause for the first join: PRINT 'Table 1 LEFT OUTER Join Table 2, with WHERE clause' select table1.groupby as [T1_Groupby], table1.number as [T1_Number], table2.number as [T2_Number] from table1 LEFT OUTER join table2 --****************************** on table1.number = table2.number --****************************** WHERE table1.groupby = 2 AND table2.number IS NULL and a filter in the ON for the second: PRINT 'Table 2 LEFT OUTER Join Table 1, with ON clause' select table1.groupby as [T1_Groupby], table1.number as [T1_Number], table2.number as [T2_Number] from table2 LEFT OUTER join table1 --****************************** on table2.number = table1.number AND table1.groupby = 2 --****************************** WHERE table1.number IS NULL Can anyone come up with a way of not using the filter in the on clause but in the where clause? The context of this is I have a staging area in a database and I want to identify new records and records that have been deleted. The groupby field is the equivalent of a batchid for an extract and I am comparing the latest extract in a temp table to a the batch from yesterday stored in a partioneds table, which also has all the previously extracted batches as well. Code to create table 1 and 2: create table table1 (number int, groupby int) create table table2 (number int) insert into table1 (number, groupby) values (1, 1) insert into table1 (number, groupby) values (2, 1) insert into table1 (number, groupby) values (1, 2) insert into table2 (number) values (1) insert into table1 (number, groupby) values (2, 2) insert into table2 (number) values (3) insert into table1 (number, groupby) values (4, 2) insert into table2 (number) values (4) EDIT: A bit more context - depending on where I put the filter I different results. As stated above the where clause gives me the correct result in one state and the ON in the other. I am looking for a consistent way of doing this. Where - select table1.groupby as [T1_Groupby], table1.number as [T1_Number], table2.number as [T2_Number] from table1 LEFT OUTER join table2 --****************************** on table1.number = table2.number --****************************** WHERE table1.groupby = 2 AND table2.number IS NULL Result: T1_Groupby T1_Number T2_Number ----------- ----------- ----------- 2 2 NULL On - select table1.groupby as [T1_Groupby], table1.number as [T1_Number], table2.number as [T2_Number] from table1 LEFT OUTER join table2 --****************************** on table1.number = table2.number AND table1.groupby = 2 --****************************** WHERE table2.number IS NULL Result: T1_Groupby T1_Number T2_Number ----------- ----------- ----------- 1 1 NULL 2 2 NULL 1 2 NULL Where (table 2 this time) - select table1.groupby as [T1_Groupby], table1.number as [T1_Number], table2.number as [T2_Number] from table2 LEFT OUTER join table1 --****************************** on table2.number = table1.number AND table1.groupby = 2 --****************************** WHERE table1.number IS NULL Result: T1_Groupby T1_Number T2_Number ----------- ----------- ----------- NULL NULL 3 On - select table1.groupby as [T1_Groupby], table1.number as [T1_Number], table2.number as [T2_Number] from table2 LEFT OUTER join table1 --****************************** on table2.number = table1.number --****************************** WHERE table1.number IS NULL AND table1.groupby = 2 Result: T1_Groupby T1_Number T2_Number ----------- ----------- ----------- (0) rows returned

    Read the article

  • PHP - Math - Round Number Function

    - by aSeptik
    Hi All guys! this time i have a math question for you! Assuming we have three numbers one is the Number of Votes the second is the Total Values and the last is the Units Ratings. units_ratings can be a number from 1 to 10; if ( total_values / units_ratings != number_of_votes ) { //do something for let the "number_of_votes" fit the division! } I ask this to you, cause i want know the best (fastest) way of achieve this! Thanks!

    Read the article

  • SQL: select random row from table where the ID of the row isn't in another table?

    - by johnrl
    I've been looking at fast ways to select a random row from a table and have found the following site: http://74.125.77.132/search?q=cache:http://jan.kneschke.de/projects/mysql/order-by-rand/&hl=en&strip=1 What I want to do is to select a random url from my table 'urls' that I DON'T have in my other table 'urlinfo'.The query I am using now selects a random url from 'urls' but I need it modified to only return a random url that is NOT in the 'urlinfo' table. Heres the query: SELECT url FROM urls JOIN (SELECT CEIL(RAND() * (SELECT MAX(urlid) FROM urls ) ) AS urlid ) AS r2 USING(urlid); And the two tables: CREATE TABLE urls ( urlid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, url VARCHAR(255) NOT NULL, ) ENGINE=INNODB; CREATE TABLE urlinfo ( urlid INT NOT NULL PRIMARY KEY, urlinfo VARCHAR(10000), FOREIGN KEY (urlid) REFERENCES urls (urlid) ) ENGINE=INNODB;

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >