How can I convert my phone country code to iso2 in React Native - reactjs

For example, I have +92 phone code for Pakistan and I want to convert it to iso2( e.g Pakistan's iso2 is 'PK'). So, is there any library to do this? I have tried 'country-code-lookup' but it is giving wrong result.
import * as lookup from 'country-code-lookup';
lookup.byIso(parseInt('+92'))
It should return an object with iso2 'PK', but it is giving me a wrong result. I have also tried lookup.byIso(parseInt('92'), without + at parameter, but still getting wrong result! Your help would be appreciable! Thanks
Link of country-code-lookup : https://github.com/richorama/country-code-lookup

Try to use React Native Phone Number Input package:
https://reactnativecode.com/react-native-phone-number-input/

Related

How to order by date defined on context model wagtail

i am getting and error trying to order by a fecha_inicio_evento date field on my model https://gist.github.com/9d3e1b3874eb43e6932699b7ea4b13c6 this is the screenshot of my error https://i.imgur.com/ifJzKc0.jpg ,
can you give me a hand folks not sure what i do wrong.
You have to use .specific() at line 23 of your models.py like this:
talleres = self.get_children().live().specific().order_by('-fecha_inicio_evento')

How to save table output in an exportable manner in Sage

I am a sage novice trying to export a table output to some image format (so that it might be shared). I tried using the .save() function as so:
my_table1 = table(my inputs)
result = my_table1.transpose()
result.save('here')
My table outputs properly after I run the program (not featured), but for some reason I receive the following error when I try and save the table:
"Error! /home/sage/Documents/here.sobj is not UTF-8 encoded
Saving disabled.
See Console for more details."
Any help in exporting this table is greatly appreciated. Additionally, if you require any more information please do not hesitate to ask!
Background: I am working in Jupyter for Sage on a browser via localhost/8000; not sure if that matters. My OS is Windows 10 and I am using Sage version 7.6.
Would LaTeX output help? Using an example in the documentation for table?:
rows = [['a', 'b', 'c'], [100,2,3], [4,5,60]]
table(rows)._latex_()
'\\begin{tabular}{lll}\na & b & c \\\\\n$100$ & $2$ & $3$ \\\\\n$4$ & $5$ & $60$ \\\\\n\\end{tabular}'
You could try for the html but that would be harder, because it returns a HTMLFragment object, and you'd need the MathJax for it to look right.
str(table(rows)._html_())
'<div class="notruncate">\n<table class="table_form">\n<tbody>\n<tr class ="row-a">\n<td>a</td>\n<td>b</td>\n<td>c</td>\n</tr>\n<tr class ="row-b">\n<td><script type="math/tex">100</script></td>\n<td><script type="math/tex">2</script></td>\n<td><script type="math/tex">3</script></td>\n</tr>\n<tr class ="row-a">\n<td><script type="math/tex">4</script></td>\n<td><script type="math/tex">5</script></td>\n<td><script type="math/tex">60</script></td>\n</tr>\n</tbody>\n</table>\n</div>'
In any case, the image wouldn't be savable as-is. Unless you took a screenshot!

Displaying Parse Data to ContainerList

I want to display data from Parse in a list from GamesScores class using Container in Codename One, this is what I've tried so far and it's not showing anything nor giving any errors:
Container container = findListCont();
container.setLayout(BoxLayout.y());
container.setScrollableY(true);
ParseQuery<ParseObject> query = ParseQuery.getQuery("GameScore");
List<ParseObject> results = (List<ParseObject>) query.find();
System.out.println("Size: " + results.size());
container.addComponent(results, f);
Please help me out, I'm a new in Codename One. If there tutorials on it, please share or anything to help me achieve the desired results.
I'm actually shocked this isn't failing. You are using the add constraint to place the object result as a constraint and you add the form object into the container...
You need to loop over the results and convert them to components to add into the layout. It also seems that you are using the old GUI builder which I would recommend against.
Generally something like this rough pseudo code should work assuming you are using a box Y layout:
for(ParseObject o : results) {
MultiButton mb = new MultiButton(o.getDisplayValue());
f.add(mb);
}
f.revalidate();

How to get unique identifiacation number of iphone

I want to get unique id of iphone.currently I am using Display.getInstance().getUdid(); but it gives different unique id each time I install an application on iphone.
Can you please let me how to resolve it?
You can no longer get the Unique id per device because of apples revised security policy . identifierForVendor is the best alternative you can go for.
You can try
UIDevice *device = [UIDevice currentDevice];
NSString *currentDeviceId = [[device identifierForVendor]UUIDString];
getUDID() returns a faux number that can't be made unique due to Apple's restrictions.
You can get it by calling this function:
UIDevice.currentDevice().identifierForVendor

Display result GeoQuerySet

I'm trying to query my PostGis database thanks to geoDjango but I have an error where I found no solution on the internet.
close_loc=PlanetOsmPoint.objects.get(way__distance_lte=(lePoint, D(**distance_from_point)))
Whatever I try on the result (close_loc) with a print, I have this error :
django.db.utils.DatabaseError: Only lon/lat coordinate systems are supported in geography.
I tried to convert it to a correct format thanks to transform(SRID) but nothing was solved, still the same problem.
Here's some informations :
Transformation :
sr1=SpatialReference('54004')
sr2=SpatialReference('NAD83')
ct=CoordTransform(sr1, sr2)
What I'm doing after getting the close_loc :
close_loc.transform(ct)
print close_loc[0]
close_loc type is GeoQuerySet.
How can I exploit this result ?
The transform() function expects an integer, not a string. The correct syntax is:
close_loc.transform( new_srid_number )
In your case, something like this:
close_loc.transform(54004)
Hope it'll work !

Resources