Search Results

Search found 47 results on 2 pages for 'bitmask'.

Page 1/2 | 1 2  | Next Page >

  • Bitmask data insertions in SSDT Post-Deployment scripts

    - by jamiet
    On my current project we are using SQL Server Data Tools (SSDT) to manage our database schema and one of the tasks we need to do often is insert data into that schema once deployed; the typical method employed to do this is to leverage Post-Deployment scripts and that is exactly what we are doing. Our requirement is a little different though, our data is split up into various buckets that we need to selectively deploy on a case-by-case basis. I was going to use a SQLCMD variable for each bucket (defaulted to some value other than “Yes”) to define whether it should be deployed or not so we could use something like this in our Post-Deployment script: IF ($(DeployBucket1Flag) = 'Yes')BEGIN   :r .\Bucket1.data.sqlENDIF ($(DeployBucket2Flag) = 'Yes')BEGIN   :r .\Bucket2.data.sqlENDIF ($(DeployBucket3Flag) = 'Yes')BEGIN   :r .\Bucket3.data.sqlEND That works fine and is, I’m sure, a very common technique for doing this. It is however slightly ugly because we have to litter our deployment with various SQLCMD variables. My colleague James Rowland-Jones (whom I’m sure many of you know) suggested another technique – bitmasks. I won’t go into detail about how this works (James has already done that at Using a Bitmask - a practical example) but I’ll summarise by saying that you can deploy different combinations of the buckets simply by supplying a different numerical value for a single SQLCMD variable. Each bit of that value’s binary representation signifies whether a particular bucket should be deployed or not. This is better demonstrated using the following simple script (which can be easily leveraged inside your Post-Deployment scripts): /* $(DeployData) is a SQLCMD variable that would, if you were using this in SSDT, be declared in the SQLCMD variables section of your project file. It should contain a numerical value, defaulted to 0. In this example I have declared it using a :setvar statement. Test the affect of different values by changing the :setvar statement accordingly. Examples: :setvar DeployData 1 will deploy bucket 1 :setvar DeployData 2 will deploy bucket 2 :setvar DeployData 3   will deploy buckets 1 & 2 :setvar DeployData 6   will deploy buckets 2 & 3 :setvar DeployData 31  will deploy buckets 1, 2, 3, 4 & 5 */ :setvar DeployData 0 DECLARE  @bitmask VARBINARY(MAX) = CONVERT(VARBINARY,$(DeployData)); IF (@bitmask & 1 = 1) BEGIN     PRINT 'Bucket 1 insertions'; END IF (@bitmask & 2 = 2) BEGIN     PRINT 'Bucket 2 insertions'; END IF (@bitmask & 4 = 4) BEGIN     PRINT 'Bucket 3 insertions'; END IF (@bitmask & 8 = 8) BEGIN     PRINT 'Bucket 4 insertions'; END IF (@bitmask & 16 = 16) BEGIN     PRINT 'Bucket 5 insertions'; END An example of running this using DeployData=6 The binary representation of 6 is 110. The second and third significant bits of that binary number are set to 1 and hence buckets 2 and 3 are “activated”. Hope that makes sense and is useful to some of you! @Jamiet P.S. I used the awesome HTML Copy feature of Visual Studio’s Productivity Power Tools in order to format the T-SQL code above for this blog post.

    Read the article

  • How to dynamically compose a bitmask?

    - by mystify
    Lets say I have to provide an value as bitmask. NSUInteger options = kFoo | kBar | kFooBar; and lets say that bitmask is really huge and may have 100 options. But which options I have, depends on a lot of situations. How could I dynamically compose such a bitmask? Is this valid? NSUInteger options; if (foo) { options = options | kFoo; } if (bar) { options = options | kBar; } if (fooBar) { options = options | kFooBar; } (despite the fact that this would probably crash when doing that | bitmask operator thing to "nothing".

    Read the article

  • PHP : How to understand bitmask value of access from ini_get_all function

    - by justjoe
    i'm start to use ini_get_all function to retrieve all configuration option on a shared host server. in the end i got this chunk of array : [allow_call_time_pass_reference] => Array ( [global_value] => 1 [local_value] => 1 [access] => 6 ) [allow_url_fopen] => Array ( [global_value] => 1 [local_value] => 1 [access] => 4 ) The PHP manual just give descripstion : It's possible for a directive to have multiple access levels, which is why access shows the appropriate bitmask values. so, can anybody explain about 'access' ? ans how to understand its bitmask values ?

    Read the article

  • Creating a bitmask parameter for a function or method

    - by synic
    I noticed a lot of Android functions have a parameter that you can pass in that's a bitmask, for different options, like on PendingIntent, you can pass in things like you can call getActivity() with PendingIntent.FLAG_CANCEL_CURRENT|PendingIntent.FLAG_NO_CREATE. I'm wondering how I can create a function that has a parameter like this?

    Read the article

  • Fastest way to calculate an X-bit bitmask?

    - by Virtlink
    I have been trying to solve this problem for a while, but couldn't with just integer arithmetic and bitwise operators. However, I think its possible and it should be fairly easy. What am I missing? The problem: to get an integer value of arbitrary length (this is not relevant to the problem) with it's X least significant bits sets to 1 and the rest to 0. For example, given the number 31, I need to get an integer value which equals 0x7FFFFFFF (31 least significant bits are 1 and the rest zeros). Of course, using a loop OR-ing a shifted 1 to an integer X times will do the job. But that's not the solution I'm looking for. It should be more in the direction of (X << Y - 1), thus using no loops.

    Read the article

  • How to mask image with another image in ActionScript 3.0

    - by Nicola
    Hi Gurus, my issue is this, my users import an image with FileReference and I need to mask it and then send it to server. My problem is this: I'm be able do keep the filereference event and transfer the image data into my canvas. I'm be able to send to server the result of masking. But I'm NOT be able to mask the image that my users have load in my canvas. There are any help/example?? Thanks Nicola

    Read the article

  • Most efficient way to extract bit flags

    - by Hallik
    I have these possible bit flags. 1, 2, 4, 8, 16, 64, 128, 256, 512, 2048, 4096, 16384, 32768, 65536 So each number is like a true/false statement on the server side. So if the first 3 items, and only the first 3 items are marked "true" on the server side, the web service will return a 7. Or if all 14 items above are true, I would still get a single number back from the web service which is is the sum of all those numbers. What is the best way to handle the number I get back to find out which items are marked as "true"?

    Read the article

  • How can I implement forum privileges

    - by RobertPitt
    I've started developing a forum application in PHP on my MVC Framework and I've got to the stage where I assign permissions to members (for example: READ, WRITE, UPDATE, DELETE). Now, I know I can add 5 columns under the user table in my database and set them to 1 | 0, but that to me seems like too much if I want to add other rules, like MOVE for example. And how can I dynamically assign these privileges them to users individually? I've heard of using a bitmasks, but it would be really good if I could fully understand them before I continue. Do you have an example of how I might implement this?

    Read the article

  • Efficient way to create/unpack large bitfields in C?

    - by drhorrible
    I have one microcontroller sampling from a lot of ADC's, and sending the measurements over a radio at a very low bitrate, and bandwidth is becoming an issue. Right now, each ADC only give us 10 bits of data, and its being stored in a 16-bit integer. Is there an easy way to pack them in a deterministic way so that the first measurement is at bit 0, second at bit 10, third at bit 20, etc? To make matters worse, the microcontroller is little endian, and I have no control over the endianness of the computer on the other side.

    Read the article

  • Erlang bit indexing

    - by GTDev
    I am currently trying to learn erlang and what I am trying to do is to perform an operation on specific indices of an array stored in a bit array or int. If there is a 0 in a position, the index into the array at that position is not used. So envision the following: Example the array is: [1, 3, 5, 42, 23] My bit array is: 21 = 10101 in binary so I'm using indicies 1,3,5 so I'm calling a function on [1, 5, 23] my function is of the form my_function(Array, BitArray) -> SubArray = get_subarray_from_bitarray(Array, BitArray), process_subarray(SubArray). And I need help with the get_subarray_from_bitarray(). I know erlang has special syntax around bit strings (something like <<) so is there an efficient way of indexing into the bit array to get the indicies?

    Read the article

  • How to produce 64 bit masks?

    - by egiakoum1984
    Based on the following simple program the bitwise left shit operator works only for 32 bits. Is it true? #include <iostream> #include <stdlib.h> using namespace std; int main(void) { long long currentTrafficTypeValueDec; int input; cout << "Enter input:" << endl; cin >> input; currentTrafficTypeValueDec = 1 << (input - 1); cout << currentTrafficTypeValueDec << endl; cout << (1 << (input - 1)) << endl; return 0; } The output of the program: Enter input: 30 536870912 536870912 Enter input: 62 536870912 536870912 How could I produce 64-bit masks?

    Read the article

  • Bitfield mask/operations with optional items

    - by user1560249
    I'm trying to find a way to handle several bitfield cases that include optional, required, and not allowed positions. yy?nnn?y 11000001 ?yyy?nnn 01110000 nn?yyy?n 00011100 ?nnn?yyy 00000111 In these four cases, the ? indicates that the bit can be either 1 or 0 while y indicates a 1 is required and n indicates that a 0 is required. The bits to the left/right of the required bits can be anything and the remaining bits must be 0. Is there a masking method I can use to test if an input bit set satisfies one of these cases?

    Read the article

  • Storing class constants (for use as bitmask) in a database?

    - by fireeyedboy
    Let's say I have a class called Medium which can represent different types of media. For instance: uploaded video embedded video uploaded image embedded image I represent these types with contants, like this: class MediumAbstract { const UPLOAD = 0x0001; const EMBED = 0x0010; const VIDEO = 0x0100; const IMAGE = 0x1000; const VIDEO_UPLOAD = 0x0101; // for convenience const VIDEO_EMBED = 0x0110; // for convenience const IMAGE_UPLOAD = 0x1001; // for convenience const IMAGE_EMBED = 0x1010; // for convenience const ALL = 0x1111; // for convenience } Thus, it is easy for me to do a combined search on them on an (abstract) repository, with something like: { public function findAllByType( $type ) { ... } } $media = $repo->findAllByType( MediumAbstract::VIDEO | MediumAbstract::IMAGE_UPLOAD ); // or $media = $repo->findAllByType( MediumAbstract::ALL ); // etc.. How do you feel about using these constant values in a concrete repository like a database? Is it ok? Or should I substitute them with meaningful data in the database. Table medium: | id | type | location | etc.. ------------------------------------------------- | 1 | use constants here? | /some/path | etc.. (Of course I'll only be using the meaningful constants: VIDEO_UPLOAD, VIDEO_EMBED, IMAGE_UPLOAD and IMAGE_EMBED)

    Read the article

  • 2D Mask antialiasing in xna hlsl

    - by mohsen
    I have two texture2d , one of these is a mask texture and have 2kind color and i use that for mask (filter) second texture2D something like float4 tex = tex2D(sprite, texCoord); float4 bitMask = tex2D(mask, texCoord); if (bitMask.a >0) { return float4(0,0,0,0); } else { return float4(tex.b,tex.g,tex.r,1); } but because mask texture is just two color the result is too jagged i want know how i can do some antialiasing for edges that smooth these ty for reading and sry for my bad english

    Read the article

  • How to force browsers to always reload xslt files?

    - by bitmask
    Related: Apache: How can I force the browser to reload CSS files? I'm building an xml page (on an apache2) that is supposed to be translated to xhtml by the browser, so my server also serves a main.xslt which is used as stylesheet by the xml file, similar to the scenario with the css files in the linked question. However, none of tricks provided in either that answer, nor some issues on SO solve the issue for Opera. While Firefox responds to F5 by fetching not only the xml file but also the xslt file, Opera only reloads the xml file. I tried both, setting the Last-Modified HTTP header via an .htaccess file and using the expires module of apache2. This is what my .htaccess looks right now: AddType text/xsl;charset=utf-8 .xslt ExpiresByType text/xsl "modification plus 1 second" Header set Last-Modified "Wed, 08 Jan 2000 23:11:55 GMT" #Header set Last-Modified "Wed, 08 Jan 2020 23:11:55 GMT" If I open the xsl myself and manually reload it, the xml presentation is updated as well, but this is tedious for development. Note: There is no php or any kind of scripting involved. Everything is static.

    Read the article

  • Unavailable packages repository

    - by bitmask
    I'm running ubuntu 11.10 (oneiric) on this machine, and suddenly, apt is unable to update properly. If I ask it to update its package information, by running apt-get update (or alternatively telling the update manager to "check"), it succeeds for about 120 packages (more precisely, I get about 120 Ign/Hit notes) and then says it cannot find universe Sources and restricted amd64: Hit http://de.archive.ubuntu.com oneiric-backports/multiverse Translation-en Hit http://de.archive.ubuntu.com oneiric-backports/restricted Translation-en Hit http://de.archive.ubuntu.com oneiric-backports/universe Translation-en Err http://de.archive.ubuntu.com oneiric/universe Sources 404 Not Found [IP: 141.30.13.20 80] Err http://de.archive.ubuntu.com oneiric/restricted amd64 Packages 404 Not Found [IP: 141.30.13.20 80] W: Failed to fetch http://de.archive.ubuntu.com/ubuntu/dists/oneiric/universe/source/Sources 404 Not Found [IP: 141.30.13.20 80] W: Failed to fetch http://de.archive.ubuntu.com/ubuntu/dists/oneiric/restricted/binary-amd64/Packages 404 Not Found [IP: 141.30.13.20 80] E: Some index files failed to download. They have been ignored, or old ones used instead. I manually checked the de server and cannot find anything wrong with the stuff it's complaining about. Also it looks pretty much like, say, the us mirror. But oddly enough, the IP it lists, seems to point to a debian package server, which obviously does not contain ubuntu packages. So, is this a local problem that I can fix somehow (and if so, how?) or is there actually some server down right now?

    Read the article

  • How do you call the process of taking a part of a function and making an individual function of it?

    - by bitmask
    I know there was a technical term for this. I'm just can't remember what it was. If the title needs clarification, here is what I mean; If this is the old code: Result foobar(Param1,Param2,Param3) { code that does abc code that does xyz code that does asdf more code that does something } and it's changed into: SomeResult do_xyz(SomeParams) { code that does xyz } Result foobar() { code that does abc do_xyz(args); code that does asdf more code that does something }

    Read the article

  • Can I use wikipedia/commons images to create a logo for my program?

    - by bitmask
    I'm not perfectly clear on the implications of the GFDL for reusing pictures in this manner. Would adding a reference in the git's root folder's README suffice, or would that clutter every use of the logo, as you would have to attribute all original contributors on every single usage (like, e.g. presentations, flyers, websites, ...)? The software itself qualifies as FOSS, although it doesn't have a GNU* license.

    Read the article

  • Why i can not load a simple pixel shader effect (. fx) file in xna?

    - by Mehdi Bugnard
    I just want to load a simple *.fx file into my project to make a (pixel shader) effect. But whenever I try to compile my project, I get the following error in visual studio Error List: Errors compiling .. ID3DXEffectCompiler: There were no techniques ID3DXEffectCompiler: Compilation failed I already searched on google and found many people with the same problem. And I realized that it was a problem of encoding. With the return lines unrecognized '\ n' . I tried to copy and paste to notepad and save as with ASCII or UTF8 encoding. But the result is always the same. Do you have an idea please ? Thanks a looot :-) Here is my [.fx] file : sampler BaseTexture : register(s0); sampler MaskTexture : register(s1) { addressU = Clamp; addressV = Clamp; }; //All of these variables are pixel values //Feel free to replace with float2 variables float MaskLocationX; float MaskLocationY; float MaskWidth; float MaskHeight; float BaseTextureLocationX; //This is where your texture is to be drawn float BaseTextureLocationY; //texCoord is different, it is the current pixel float BaseTextureWidth; float BaseTextureHeight; float4 main(float2 texCoord : TEXCOORD0) : COLOR0 { //We need to calculate where in terms of percentage to sample from the MaskTexture float maskPixelX = texCoord.x * BaseTextureWidth + BaseTextureLocationX; float maskPixelY = texCoord.y * BaseTextureHeight + BaseTextureLocationY; float2 maskCoord = float2((maskPixelX - MaskLocationX) / MaskWidth, (maskPixelY - MaskLocationY) / MaskHeight); float4 bitMask = tex2D(MaskTexture, maskCoord); float4 tex = tex2D(BaseTexture, texCoord); //It is a good idea to avoid conditional statements in a pixel shader if you can use math instead. return tex * (bitMask.a); //Alternate calculation to invert the mask, you could make this a parameter too if you wanted //return tex * (1.0 - bitMask.a); }

    Read the article

  • Vim: Show the index of tabs in the tabline

    - by bitmask
    Lets say I opened file1.txt, file2.txt, file3a.txt and file3b.txt such that the tabline (the thing on the top) looks like this: file1.txt file2.txt 2 file3a.txt (Note how file3b.txt. is missing because it is shown in a split, in the same tab as file3a.txt) To move more quickly between tabs (with <Number>gt), I would like each tab to display its index, along the filename. Like so: 1:<file1.txt> 2:<file2.txt> 3:<2 file3a.txt> The formatting (the angle braces in particular) are optional; I just want the index to appear there (the 1:, 2: and so on). No clues on :h tab-page-commands or google whatsoever.

    Read the article

  • How do those bitmasks actually work?

    - by mystify
    For example, this method from NSCalendar takes a bitmask: - (NSDate *)dateByAddingComponents:(NSDateComponents *)comps toDate:(NSDate *)date options:(NSUInteger)opts So options can be like: NSUInteger options = kCFCalendarUnitYear; or like: NSUInteger options = kCFCalendarUnitYear | kCFCalendarUnitMonth | kCFCalendarUnitDay; What I don't get is, how is this actually done? I mean: How can they pull out those values which are merged into options? If I wanted to program something like this, that can take a bitmask, how would that look?

    Read the article

  • typedef a functions prototype

    - by bitmask
    I have a series of functions with the same prototype, say int func1(int a, int b) { // ... } int func2(int a, int b) { // ... } // ... Now, I want to simplify their definition and declaration. Of course I could use a macro like that: #define SP_FUNC(name) int name(int a, int b) But I'd like to keep it in C, so I tried to use the storage specifier typedef for this: typedef int SpFunc(int a, int b); This seems to work fine for the declaration: SpFunc func1; // compiles but not for the definition: SpFunc func1 { // ... } which gives me the following error: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token Is there a way to do this correctly or is it impossible? To my understanding of C this should work, but it doesn't. Why? Note, gcc understands what I am trying to do, because, if I write SpFunc func1 = { /* ... */ } it tells me error: function 'func1' is initialized like a variable Which means that gcc understands that SpFunc is a function type.

    Read the article

  • Best way to mask 2D sprites in XNA?

    - by electroflame
    I currently am trying to mask some sprites. Rather than explaining it in words, I've made up some example pictures: The area to mask (in white) Now, the red sprite that needs to be cropped. The final result. Now, I'm aware that in XNA you can do two things to accomplish this: Use the Stencil Buffer. Use a Pixel Shader. I have tried to do a pixel shader, which essentially did this: float4 main(float2 texCoord : TEXCOORD0) : COLOR0 { float4 tex = tex2D(BaseTexture, texCoord); float4 bitMask = tex2D(MaskTexture, texCoord); if (bitMask.a > 0) { return float4(tex.r, tex.g, tex.b, tex.a); } else { return float4(0, 0, 0, 0); } } This seems to crop the images (albeit, not correct once the image starts to move), but my problem is that the images are constantly moving (they aren't static), so this cropping needs to be dynamic. Is there a way I could alter the shader code to take into account it's position? Alternatively, I've read about using the Stencil Buffer, but most of the samples seem to hinge on using a rendertarget, which I really don't want to do. (I'm already using 3 or 4 for the rest of the game, and adding another one on top of it seems overkill) The only tutorial I've found that doesn't use Rendertargets is one from Shawn Hargreaves' blog over here. The issue with that one, though is that it's for XNA 3.1, and doesn't seem to translate well to XNA 4.0. It seems to me that the pixel shader is the way to go, but I'm unsure of how to get the positioning correct. I believe I would have to change my onscreen coordinates (something like 500, 500) to be between 0 and 1 for the shader coordinates. My only problem is trying to work out how to correctly use the transformed coordinates. Thanks in advance for any help!

    Read the article

1 2  | Next Page >