w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
While Sending Html Mails from my web application Recieved Mails contains Symbols like &ldquo,&rdquo, ‘
Check with another constructor for htmlView: ContentType mimeType = new System.Net.Mime.ContentType("text/html"); var htmlView = AlternateView.CreateAlternateViewFromString(bodyMessage, mimeType);

Categories : Asp Net Mvc

How to prevent .json requests with Turn.js?
Inside your file "Magazine.js", you have, at line 76 the following code function loadRegions(page, element) { $.getJSON(grerda_basePath+'pages/'+page+'-regions.json'). done(function(data) { $.each(data, function(key, region) { addRegion(region, element); }); }); } I think you can delete or comment it to see what it does. It took me something like 30seconds to find this ajax call. To find it, I just open firefox + firebug, and searched for the string ".json" inside your code. You can add breakpoints, and look into the console to check what you've done

Categories : Javascript

How do I turn all rejections into custom json in spray?
If you just want to turn all of the rejections into your custom json format, you can create a rejection handler. For example, I'll put this in my ServiceActor and do the following: class ApiServiceActor extends Actor with HttpServiceActor with ApiServices { def jsonify(response: HttpResponse): HttpResponse = { response.withEntity(HttpBody(ContentType.`application/json`, JSONObject(Map( "details" -> response.entity.asString.toJson, "errorType" -> ApiErrorType.Unknown.toJson )).toString())) } implicit val apiRejectionHandler = RejectionHandler { case rejections => mapHttpResponse(jsonify) { RejectionHandler.Default(rejections) } } def receive = runRoute { yourRoute ~ yourOtherRoute ~ someOtherRoute } }

Categories : Json

Why do int keys of a python dict turn into strings when using json.dumps?
The simple reason is that JSON does not allow integer keys. object {} { members } members pair pair , members pair string : value # Keys *must* be strings. As to how to get around this limitation - you will first need to ensure that the receiving implementation can handle the technically-invalid JSON. Then you can either replace all of the quote marks or use a custom serializer.

Categories : Python

What is the best way to turn strings into an JSON object with nested keys in Node.js?
I don't think theres an inbuilt function in underscore to do that, but its a fairly simple matter to write one yourself: var input = { "usa.ca.los": 12345, "usa.ca.sfo": 12346, "usa.ws.sea": 22333, "others.a.b.c.d.e": 33333 } function parse(input){ var output = {}; for(var key in input){ setByString(output, input[key], key); } return output; } function setByString(obj, value, key){ var split = key.split('.'); while(split.length){ key = split.shift(); if(split.length){ if(!obj.hasOwnProperty(key)){ obj[key] = {}; } obj = obj[key]; } else { obj[key] = value; } } } console.log(parse(input));

Categories : Json

Drupal services module JSON response fetched: Backbone.js model attributes turn into string
So I finally managed to crack this issue and I found my solution here: how to get numeric types from mysql using PDO. I thought I'd document the solution. Drupal 7 uses PDO. Results fetched using PDO, using Drupal's default PDO settings result in stringified values. In Drupal's includes/database.inc file you will find this around lines 40-50: $connection_options['pdo'] += array( // So we don't have to mess around with cursors and unbuffered queries by default. PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE, // Because MySQL's prepared statements skip the query cache, because it's dumb. PDO::ATTR_EMULATE_PREPARES => TRUE, ); The statement here that MySQL's prepared statements skip the query cache is not entirely true, as can be found here: http://dev.mysql.com/doc/refman/5.1/

Categories : Backbone Js

How to turn silent mode on during a specific time period in Android? and turn back to normal after the whole duration?
You can use the android FrameWork class AudioManager as follow : AudioManager manager = (AudioManager)getSystemService(AUDIO_SERVICE); manager.setRingerMode(AudioManager.RINGER_MODE_SILENT); Hope it helps :)

Categories : Android

Tween Multiple object turn by turn in tweenlite
Usually I'd do it like this: for (var i:int = 0; i < 5; i++) { TweenLite.to(object, duration, {delay: duration * i}); } It will create all the Tweens at once, but they won't really effect your performance since only the active tweens are really noticeable. I did that with over 200 objects and had no lag at all.You might however want to pool the TweenLite object on mobile platforms, but again - you probably won't see the difference up to 800+ objects.

Categories : Actionscript

Android app: how to turn off listener and turn it back on again?
Instead of inline creating the SeekBar.OnSeekBarChangeListener, create a member variable of type SeekBar.OnSeekBarChangeListener. When you want it to turn it on, you can pass the variable to it. When you want to turn it off, you can pass it the null. private SeekBar sbt; //Not sure where this gets initialized in your code. private SeekBar.OnSeekBarChangeListener mListener = new SeekBar.OnSeekBarChangeListener() { int progressChanged = 0; @Override public void onStopTrackingTouch(SeekBar seekBar) { // Toast.makeText(ProductDetailsInfoActivity.this,"seek bar progress:"+progressChanged, // Toast.LENGTH_SHORT).show(); // TODO Auto-generated method stub } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TOD

Categories : Android

turn cURL json array response to an associate array
json_decode gives you an associative array when you pass "true" as the second argument: $json = '[{"Id":1079,"Name":"Test ","Status":1,"MemberId":1308,"Description":"This is a Test Event","SponsoredBy":null,"StartTime":"2013-06-30T12:00:00","EndTime":"2013-06-30T23:59:00","SearchDescription":null,"Types":[1,4,6]}]'; $response = json_decode($json, true); echo $response[0]["Name"]; gives: Test Edit: json_decode() is giving you back an array of arrays, so you need to reference the array that is at position [0] in the response, if you get me. I've done that above in my example with $response[0], but have a look at this example, hope it makes it clearer! $result = json_decode($json, true); var_dump($result); gives: array(1) { [0]=> array(10) { ["Id"]=>

Categories : PHP

json database get image setting data for json using while loop carousel type jquery json
Look for a jquery carousel plugin. http://vandelaydesign.com/blog/tools/jquery-carousel-plugins/ http://www.webdesigntunes.com/freebies/30-amazing-free-jquery-slider-and-carousel-plugins-of-2013/ Edit: does this help? $data = array(); $x = 0; while ($test = mysql_fetch_array($query)) { $data[$x]['content'] = "<div class='slide_inner'><a class='photo_link' href='#'><img class='photo' src='{$test['image']}' alt='Bike'></a><a class='caption' href='#'>Sample Carousel Pic Goes Here And The Best Part is that...</a></div>"; $data[$x]['content_button'] = "<div class='thumb'><img src='{$test['thumb']}' alt='bike is nice'></div><p>Agile Carousel Place Holder</p>"; $x++; } echo json_encode($data);

Categories : PHP

python json.loads / json.load truncates nested json objects?
JSON doesn't care about the keys for objects, but the json.load and json.loads convert to a Python object using this conversion table. JSON objects are turned into python dict's, which means you can't have repeated keys.

Categories : Python

Json Data converted to Json string but not in Json Dictionary
Well there is no error in what you are doing and the log says clearly you are getting a NSDictionary, and If you try to log an NSDictionary it is obvious you get a json string response.See this line NSLog(@" dicjson : %@ json string : %@ error : %@",dicJsonRequest,strJsonRequest,convertError.localizedDescription); Here the NDDictionary contains the value correctly since the log shows dicjson : { email = "test@test.com"; name = abcd; password = test; } So you have a valid dictionary in hand.Just do the remaining coding

Categories : Iphone

JSON.NET: Serialize json string property into json object
You need a converter to do that, here is an example: public class RawJsonConverter : JsonConverter { public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { writer.WriteRawValue(value.ToString()); } public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { throw new NotImplementedException(); } public override bool CanConvert(Type objectType) { return typeof(string).IsAssignableFrom(objectType); } public override bool CanRead { get { return false; } } } Then decorate your class with it: public class Foo { public int Id; [JsonConverter(typeof(RawJsonConverter))] public string RawData; } Then, when you use:

Categories : C#

Turn "abc" to "[97, 98 99]"
You can use list comprehension and ord. >>> nums = str([ord(char) for char in "abc"]) >>> nums "[97, 98, 99]"

Categories : Python

Turn value into 2value
So, short answer: What you're looking for is a left shift. in C and many other languages, your particular wish would be served by 1 << 8. You could do it in x86 assembler with shl but there's really no sane reason to do so since pretty much any compiler you come across is going to compile the code into the native shift instruction.

Categories : Algorithm

How to turn on 3G?
From your description, it sounds as though you want to turn the 3G device's radio on. You can do this in C# or C++ via Windows Mobile Broadband IMbnRadio and IMbnRadioEvents interfaces. I had a quick look on Google for a Windows setting that would tell the OS not to deactivate the device at shutdown, but didn't find anything. EDIT: MbnApi does let you do a lot of things. It consists of many interfaces, and the two that I linked to above are specifically for switching the radio off and on. You don't need the rest. The 3G module can either be software disabled (radio off/on) or hardware disabled (a switch on the computer). The exact implementation of these two things, is up to the individual manufacturer. They don't work exactly the same on machines from different manufacturers. So

Categories : Windows

Turn On GPS using NDK
In general, the Android NDK interface is much more limited than the SDK interface. To supplement it, you are able to access Java functions through the JNI interface. There is no extra functionality in the NDK that does not already exist in the Java SDK.

Categories : Android

What is Fiddler and how do I turn it off?
Fiddler is a data monitoring tool that allows you to see incoming and outgoing HTTP(s) traffic from your computer. http://fiddler2.com/ It is a desktop app, so if you haven't got it installed on your PC - then you don't need to turn it off

Categories : C#

How to turn these N queries to one
The way that you would get 10 words around "rivolgimento": select lt.* from lemmatized_text ltr join lemmatized_text lt on ltr.lemma = 'rivolgimento' and lt.position between ltr.position - 10 and ltr.position + 10; If you want the words in one row, per appearance of 'rivolgimento', then something like: select ltr.position, group_concat(lt.lemma separator ' ') from lemmatized_text ltr join lemmatized_text lt on ltr.lemma = 'rivolgimento' and lt.position between ltr.position - 10 and ltr.position + 10 group by ltr.position;

Categories : Mysql

How to turn off cache?
There's any research effort…… Here's your answer for perfect no-cached content using HTML: <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Expires" content="0" /> ==> from this post: http://stackoverflow.com/a/2068407/2213706. And here's something about If-Modified-Since header: ==> http://stackoverflow.com/a/1192640/2213706

Categories : Http

for every value which in-turn is a key is put in one-line
from collections import OrderedDict with open('abc') as f: dic = OrderedDict() seen = set() for line in f: spl = line.split() + [""] key ,v = spl[:2] if v in dic and dic[v] == [""]: del dic[v] for k1,v1 in dic.items(): if key in v1: dic[k1].append(v) break else: dic[key] = [v] with open('ouput.txt', 'w') as f: for k,v in dic.items(): f.write("{} {} ".format(k," ".join(v))) Output: 344670 332807 353314 353311 338169 334478

Categories : Python

Turn a slug into an id
In your routing file: your_route_name: pattern: /my_app/{category}/{subcategory}/{page} defaults: { _controller: YourBundle:YourController:FindPost } In your controller: public function FindPostAction($category, $subcategory, $page) { //...use $category, $subcategory, $page here }

Categories : PHP

QuickFix C++ how do I turn on SSL?
Thanks for the config file. I have never used then switch SocketUseSSL=Y Instead, in our production environment, in order to encrypt data over SSL we are using a free software: sTunnel It's quite straightforward to install and config, and run over many different platforms. Hope this can help.

Categories : C++

Can you turn NumLock on in XNA?
I don't know if this is that you are looking for, but I found this article. In order to know whether or not Caps Lock, Num Lock or Scroll Lock keys are on, we need to make use of the Win32 API through a call to an unmanaged function. Since we'll make a call to an unmanaged function, the following using statement is in order: using System.Runtime.InteropServices; The following is the definition for the unmanaged function we'll be using, GetKeyState(): // An unmanaged function that retrieves the states of each key [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)] public static extern short GetKeyState(int keyCode); // Get they key state and store it as bool bool NumLock = (((ushort)GetKeyState(0x90

Categories : C#

How do you turn a .gif into a byte[][]?
If you're using standard image io, you could do the following: BufferedImage image = ImageIO.read( <your image file> ); ByteArrayOutputStream baos=new ByteArrayOutputStream(); int width=image.getWidth(null); int height=image.getHeight(null); BufferedImage bi=new BufferedImage(width,height,BufferedImage.TYPE_BYTE_GRAY); bi.getGraphics().drawImage(image,0,0,null); ImageIO.write(bi,"RAW",baos); baos.flush(); byte[] resultImageAsRawBytes = baos.toByteArray(); baos.close(); What this basically does is: it reads the image into a BufferedImage, renders it into a grayscale images and writes the result to a ByteArrayOutputStream which allows you to access the raw bytes. A few notes though: - You'd need to add exception handling yourself - I'm not 100% sure about the "RAW" format (unfor

Categories : Java

Turn Flash On/Off
It looks like you can't retrieve the acquisition device twice (I'm not sure why), so you should store it in a property: protected AudioVideoCaptureDevice Device { get; set; } private async void ButtonTurnOn_Click(object sender, RoutedEventArgs e) { var sensorLocation = CameraSensorLocation.Back; try { if (this.Device == null) { // get the AudioViceoCaptureDevice this.Device = await AudioVideoCaptureDevice.OpenAsync(sensorLocation, AudioVideoCaptureDevice.GetAvailableCaptureResolutions(sensorLocation).First()); } // turn flashlight on var supportedCameraModes = AudioVideoCaptureDevice .GetSupportedPropertyValues(sensorLocation, KnownCameraAudioVideoProperties.VideoTorchMode); if (

Categories : C#

how to turn on vpn in ios app ? ( public api )
even astrill is an app available for ios (iPhone VPN connect app).. it provides a toggle to switch vpn on and off from the app directly... so my guess is it used some third party api.. right now.. there is no public api available to toggle vpn from an app.. urlscheme could have been used to atleast open vpn setting from ur app .. but even that was deprecated.. so no chance for now

Categories : IOS

iOS - UILocalNotification do not turn on screen
The answer is no. You can not change the way UILocalNotification works. Either you don't use it or you accept its working way. And the way UILocalNotification works is reasonable. At lease I think so.

Categories : IOS

Get Right or Left turn according to bearing value
oOOPS... I got the calculations wrong. Here's a bit from a spread sheet, I just tested it.. =MOD(A1+540, 360) - MOD(B1+540, 360) Negatives indicate left. Sorry about the other miss-guided code. bool right = (( (a1 + 540) % 360 - (b1 + 540) % 360 ) > 0 ); Not quite accurate because zero change would be seen as left.. I'll leave that bit to you.

Categories : Android

Turn data type into a map
Your tree function worked with trees that contained a to make values of type b, but your Exp data type doesn't contain anything except expressions to combine (or count). Let's make a second data type that we can count occurences of. It'd better be Ord, so we need Eq, and Show'll be good for output: data Term = NumberTerm | AddTerm | SubtractTerm | MultiplyTerm | DivideTerm deriving (Eq, Ord, Show) Each of those represents a term of the Exp type. I've renamed your insert' to inc: inc :: Ord a => a -> Map a Int -> Map a Int inc a = insertWith (+) a 1 No we're ready to count: countExp :: Exp -> Map Term Int A Number has just one term (no subterms), so we'll start with empty and increment the number of NumberTerms: countExp (Number _) = inc NumberTerm empty Add t

Categories : Haskell

Turn "foreach" into "for" with structures
You can access the details of the array with <?php for ($i = 0; $i <=4; $i++) { echo $_additional[$i]['label']; echo $_helper->productAttribute($_product, $_additional[$i]['value'], $_additional[$i]['code']); }

Categories : PHP

How to turn off/disable NFC programmataically?
If you really have to turn NFC off, use NfcAdapter.disable();. However, you won't be able to use disable() API if your app is not system application which is build together with the platform. Alternatively, you may show a notice (a dialog?) to the user and ask her if she wants to turn off the NFC. If user agrees, you can redirect her to global Settings UI using following Intent: startActivity(new Intent("android.settings.NFC_SETTINGS"));

Categories : Android

How can I turn this into an AngularJs Directive?
One option if the user really has to enter a value would be to add the required html5 attribute and style based on the :invalid rule: /* style based on invalid */ select:invalid { color: red } /* so drop-down items don't inherit color */ select:invalid option { color: black; } html: <select required> You could do your styling all in css based on value, but the value attribute isn't set when the value property changes: /* style based on value */ select[value=""] { color: #aaa; } /* so drop-down items don't inherit color */ select option { color: black; } /* if you want the style in the drop-down list too */ select option:nth-child(1) { color: #aaa; } To fix that you could use jQuery to set the value attribute based on the value property (fiddle): $('#priority'

Categories : Javascript

Android device(4.0 or above) GPS turn on/off
After Android 2.3 it is no longer possible. Only apps signed with manufacturer platform certificate can use that permission. The correct thing is to send the user to the location settings page, and let him enable GPS if he wish. e.g., Intent i = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(i);

Categories : Android

how would I turn these functions into a loop?
First a minor change to the markup could be needed (Added class i_contact and o_contact and data-index) <span class="i_contact i_contact<%= n %>" data-pos-x="<%= i_connection.pos_x %>" data-pos-y="<%= i_connection.pos_y %>" data-pos-width="<%= i_connection.pos_width %>" data-pos-height="<%= i_connection.pos_height %>" ="spanid<%= n %>" data-index="<%= n %>"></span> <span class="o_contact o_contact<%= n %>" data-pos-x="<%= o_connection.pos_x %>" data-pos-y="<%= o_connection.pos_y %>" data-pos-width="<%= o_connection.pos_width %>" data-pos-height="<%= o_connection.pos_height %>" id="spanid<%= n %>" data-index="<%= n %>"> </span> Then $(document).ready(function(){ $('span.i_

Categories : Jquery

Rails turn feature on/off on the fly
Unless you have a way of communicating to all your processes at once, which is non-standard, then you'd need some kind of centralized configuration system. Redis is a really fast key-value store which works well for this, but a database can also do the job if a few milliseconds per page load to figure out which features to enable isn't a big deal. If you're only deploying on a single server, you could also use a static YAML or JSON configuration file that's read before each request is processed. The overhead of this is almost immeasurable.

Categories : Ruby On Rails

How to turn a jp2 image to a jpg file?
You can't. GD2 doesn't support JP2 (JPG 2000) format. You will have to use Imagick library. I had 1.4million image files in jp2 format, and I used IrfanView batch function. It event let me re-cosntruct the directory structure, which consisted of three levels, like [0-f]/[0-f]/[0=f]/image.jpg

Categories : PHP

turn rows into column for every nth row
Assuming the file has a number of lines evenly divisible by 5 (or that any remainder lines are to be ignored), this should work just fine: filein=out.txt fid=15 #file identifier nlines=`cat $filein | wc -l` #count number of lines in file eval "exec $fid<$filein" for cnt in $(seq 1 $((nlines/5))); do read <&$fid line1 read <&$fid line2 read <&$fid line3 read <&$fid line4 read <&$fid line5 echo $line1 $line2 $line3 $line4 $line5 done eval "exec $fid<&-" Basically, it just does a for loop for 1/5th the number of lines in the file, reading 5 lines at a time and spitting them all out at once.

Categories : Linux

Turn a Callback into a Pointer in JNA
You don't. You pass the callback instance and let JNA handle the pointer conversions. Make sure you keep a strong reference to the callback object so it doesn't get GC'd. If you need to, make another function mapping that uses your callback type instead of Pointer. You can get the native pointer value for a callback instance, but there are very few reasons why you'd ever need to.

Categories : Misc



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.