qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
5,667,802
How can I know the IP address of my iPhone simulator?
2011/04/14
[ "https://Stackoverflow.com/questions/5667802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/418029/" ]
Jep, like Todd said, the same as your machines IP. You can also simply visit <http://www.whatismyip.com> with mobile Safari or your Mac's web browser ;-)
I think the by visiting the website <http://www.test-ipv6.com/> is also a good choice. As the site tells you both the ipv4 and ipv6 global-unicast address
13,735,566
I have a method in MyWebpage.aspx.cs lik so: ``` public partial class MyWebpage : PageBase { private readonly DataAccessLayer dataAccessLayer; protected string GetMyTitle(string myVar, string myId) { if (string.IsNullOrEmpty(myVar)) { return string.Empty; } return dataAccessLayer.GetMyTitle(Convert.ToInt32(myId), myVar); } } ``` In the DataAccessLayer class, I have a methoud that talks to the DB and does the DAL stuff and returns the title. What's the best practice on accessing the DAL from MyWebPage.aspx.cs class (as in do I need to create a new DataAccessLayer() object each time? Where should I create it in my PageBase class or everytime I call it in a code behind?
2012/12/06
[ "https://Stackoverflow.com/questions/13735566", "https://Stackoverflow.com", "https://Stackoverflow.com/users/665557/" ]
First thing is accessing DAL from your code behind or presentation layer generally is not a good practice. Because in this case you need to put your Business logic code in your code behind(Presentation Layer) which causes conflicting of concerns, high coupling, duplication and many other issues. So, if you're look for the best practices, I suggest to have a look at the following links: * [Data Layer Guidelines](http://msdn.microsoft.com/en-us/library/ee658127.aspx) * [Layered Application Guidelines](http://msdn.microsoft.com/en-us/library/ee658109.aspx) * [Object-Relational Metadata Mapping Patterns (especially Repository Pattern) and Domain Logic Patterns](http://www.martinfowler.com/eaaCatalog/) And these are really good books: * [Patterns of enterprise application architecture (By Martin Fowler)](https://rads.stackoverflow.com/amzn/click/com/0321127420) * [Microsoft® .NET: Architecting Applications for the Enterprise](https://rads.stackoverflow.com/amzn/click/com/073562609X) Also about having static function for calling the DAL. As you know static functions are vulnerable to the multi-threading, so if you are using anything shared in the DAL functions (which its the case sometimes, like shared connection, command etc) it will break your code, so I think it's better to avoid static functions in this layer.
I'm a fan of the [repository pattern](http://martinfowler.com/eaaCatalog/repository.html). Everybody has their own take on it but I like the idea of one sql table => one repository and share the name, just like ORM tools. Entity Framework might make quick work of your DAL and you can still implement a DAL pattern like repositories. Here is a [code generator](http://enterprisecodegen.azurewebsites.net/) that takes a sql connection string and gives a fairly standard implementation of the Enterprise Data Access Application Block. It is not very robust as it was designed against a bland sql schema. If you use the example database have it will give you code samples that you can use to design a data access layer to your liking.
3,460,650
I am interested in taking an arbitrary dict and copying it into a new dict, mutating it along the way. One mutation I would like to do is swap keys and value. Unfortunately, some values are dicts in their own right. However, this generates a "unhashable type: 'dict'" error. I don't really mind just stringifying the value and giving it the key. But, I'd like to be able to do something like this: ``` for key in olddict: if hashable(olddict[key]): newdict[olddict[key]] = key else newdict[str(olddict[key])] = key ``` Is there a clean way to do this that *doesn't* involve trapping an exception and parsing the message string for "unhashable type" ?
2010/08/11
[ "https://Stackoverflow.com/questions/3460650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26227/" ]
### Python 3.x Use [`collections.abc.Hashable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Hashable) or [`typing.Hashable`](https://docs.python.org/3/library/typing.html#typing.Hashable). ``` >>> import typing >>> isinstance({}, typing.Hashable) False >>> isinstance(0, typing.Hashable) True ``` Note: both are the same one, the latter is simply an alias of the former. Also note that `collections.Hashable` was removed in Python 3.10+ (deprecated since 3.7). ### Python 2.6+ (an original answer) Since Python 2.6 you can use the abstract base class [`collections.Hashable`](https://docs.python.org/2.7/library/collections.html#collections.Hashable): ``` >>> import collections >>> isinstance({}, collections.Hashable) False >>> isinstance(0, collections.Hashable) True ``` This approach is also mentioned briefly in the documentation for [**`__hash__`**](http://docs.python.org/reference/datamodel.html#object.__hash__). > > Doing so means that not only will instances of the class raise an appropriate `TypeError` when a program attempts to retrieve their hash value, but they will also be correctly identified as unhashable when checking `isinstance(obj, collections.Hashable)` (unlike classes which define their own `__hash__()` to explicitly raise `TypeError`). > > >
``` def hashable(v): """Determine whether `v` can be hashed.""" try: hash(v) except TypeError: return False return True ```
3,460,650
I am interested in taking an arbitrary dict and copying it into a new dict, mutating it along the way. One mutation I would like to do is swap keys and value. Unfortunately, some values are dicts in their own right. However, this generates a "unhashable type: 'dict'" error. I don't really mind just stringifying the value and giving it the key. But, I'd like to be able to do something like this: ``` for key in olddict: if hashable(olddict[key]): newdict[olddict[key]] = key else newdict[str(olddict[key])] = key ``` Is there a clean way to do this that *doesn't* involve trapping an exception and parsing the message string for "unhashable type" ?
2010/08/11
[ "https://Stackoverflow.com/questions/3460650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26227/" ]
``` def hashable(v): """Determine whether `v` can be hashed.""" try: hash(v) except TypeError: return False return True ```
All hashable built in python objects have a `.__hash__()` method. You can check for that. ``` olddict = {"a":1, "b":{"test":"dict"}, "c":"string", "d":["list"] } for key in olddict: if(olddict[key].__hash__): print str(olddict[key]) + " is hashable" else: print str(olddict[key]) + " is NOT hashable" ``` output ``` 1 is hashable string is hashable {'test': 'dict'} is NOT hashable ['list'] is NOT hashable ```
3,460,650
I am interested in taking an arbitrary dict and copying it into a new dict, mutating it along the way. One mutation I would like to do is swap keys and value. Unfortunately, some values are dicts in their own right. However, this generates a "unhashable type: 'dict'" error. I don't really mind just stringifying the value and giving it the key. But, I'd like to be able to do something like this: ``` for key in olddict: if hashable(olddict[key]): newdict[olddict[key]] = key else newdict[str(olddict[key])] = key ``` Is there a clean way to do this that *doesn't* involve trapping an exception and parsing the message string for "unhashable type" ?
2010/08/11
[ "https://Stackoverflow.com/questions/3460650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26227/" ]
``` def hashable(v): """Determine whether `v` can be hashed.""" try: hash(v) except TypeError: return False return True ```
Why not use duck typing? ``` for key in olddict: try: newdict[olddict[key]] = key except TypeError: newdict[str(olddict[key])] = key ```
3,460,650
I am interested in taking an arbitrary dict and copying it into a new dict, mutating it along the way. One mutation I would like to do is swap keys and value. Unfortunately, some values are dicts in their own right. However, this generates a "unhashable type: 'dict'" error. I don't really mind just stringifying the value and giving it the key. But, I'd like to be able to do something like this: ``` for key in olddict: if hashable(olddict[key]): newdict[olddict[key]] = key else newdict[str(olddict[key])] = key ``` Is there a clean way to do this that *doesn't* involve trapping an exception and parsing the message string for "unhashable type" ?
2010/08/11
[ "https://Stackoverflow.com/questions/3460650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26227/" ]
### Python 3.x Use [`collections.abc.Hashable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Hashable) or [`typing.Hashable`](https://docs.python.org/3/library/typing.html#typing.Hashable). ``` >>> import typing >>> isinstance({}, typing.Hashable) False >>> isinstance(0, typing.Hashable) True ``` Note: both are the same one, the latter is simply an alias of the former. Also note that `collections.Hashable` was removed in Python 3.10+ (deprecated since 3.7). ### Python 2.6+ (an original answer) Since Python 2.6 you can use the abstract base class [`collections.Hashable`](https://docs.python.org/2.7/library/collections.html#collections.Hashable): ``` >>> import collections >>> isinstance({}, collections.Hashable) False >>> isinstance(0, collections.Hashable) True ``` This approach is also mentioned briefly in the documentation for [**`__hash__`**](http://docs.python.org/reference/datamodel.html#object.__hash__). > > Doing so means that not only will instances of the class raise an appropriate `TypeError` when a program attempts to retrieve their hash value, but they will also be correctly identified as unhashable when checking `isinstance(obj, collections.Hashable)` (unlike classes which define their own `__hash__()` to explicitly raise `TypeError`). > > >
All hashable built in python objects have a `.__hash__()` method. You can check for that. ``` olddict = {"a":1, "b":{"test":"dict"}, "c":"string", "d":["list"] } for key in olddict: if(olddict[key].__hash__): print str(olddict[key]) + " is hashable" else: print str(olddict[key]) + " is NOT hashable" ``` output ``` 1 is hashable string is hashable {'test': 'dict'} is NOT hashable ['list'] is NOT hashable ```
3,460,650
I am interested in taking an arbitrary dict and copying it into a new dict, mutating it along the way. One mutation I would like to do is swap keys and value. Unfortunately, some values are dicts in their own right. However, this generates a "unhashable type: 'dict'" error. I don't really mind just stringifying the value and giving it the key. But, I'd like to be able to do something like this: ``` for key in olddict: if hashable(olddict[key]): newdict[olddict[key]] = key else newdict[str(olddict[key])] = key ``` Is there a clean way to do this that *doesn't* involve trapping an exception and parsing the message string for "unhashable type" ?
2010/08/11
[ "https://Stackoverflow.com/questions/3460650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26227/" ]
### Python 3.x Use [`collections.abc.Hashable`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Hashable) or [`typing.Hashable`](https://docs.python.org/3/library/typing.html#typing.Hashable). ``` >>> import typing >>> isinstance({}, typing.Hashable) False >>> isinstance(0, typing.Hashable) True ``` Note: both are the same one, the latter is simply an alias of the former. Also note that `collections.Hashable` was removed in Python 3.10+ (deprecated since 3.7). ### Python 2.6+ (an original answer) Since Python 2.6 you can use the abstract base class [`collections.Hashable`](https://docs.python.org/2.7/library/collections.html#collections.Hashable): ``` >>> import collections >>> isinstance({}, collections.Hashable) False >>> isinstance(0, collections.Hashable) True ``` This approach is also mentioned briefly in the documentation for [**`__hash__`**](http://docs.python.org/reference/datamodel.html#object.__hash__). > > Doing so means that not only will instances of the class raise an appropriate `TypeError` when a program attempts to retrieve their hash value, but they will also be correctly identified as unhashable when checking `isinstance(obj, collections.Hashable)` (unlike classes which define their own `__hash__()` to explicitly raise `TypeError`). > > >
Why not use duck typing? ``` for key in olddict: try: newdict[olddict[key]] = key except TypeError: newdict[str(olddict[key])] = key ```
54,558,489
I am using a simple groupby query in scala spark where the objective is to get the first value in the group in a sorted dataframe. Here is my spark dataframe ``` +---------------+------------------------------------------+ |ID |some_flag |some_type | Timestamp | +---------------+------------------------------------------+ | 656565654| true| Type 1|2018-08-10 00:00:00| | 656565654| false| Type 1|2017-08-02 00:00:00| | 656565654| false| Type 2|2016-07-30 00:00:00| | 656565654| false| Type 2|2016-05-04 00:00:00| | 656565654| false| Type 2|2016-04-29 00:00:00| | 656565654| false| Type 2|2015-10-29 00:00:00| | 656565654| false| Type 2|2015-04-29 00:00:00| +---------------+----------+-----------+-------------------+ ``` Here is my aggregate query ``` val sampleDF = df.sort($"Timestamp".desc).groupBy("ID").agg(first("Timestamp"), first("some_flag"), first("some_type")) ``` The expected result is ``` +---------------+-------------+---------+-------------------+ |ID |some_falg |some_type| Timestamp | +---------------+-------------+---------+-------------------+ | 656565654| true| Type 1|2018-08-10 00:00:00| +---------------+-------------+---------+-------------------+ ``` But getting following wierd output and it keeps changing like a random row ``` +---------------+-------------+---------+-------------------+ |ID |some_falg |some_type| Timestamp | +---------------+-------------+---------+-------------------+ | 656565654| false| Type 2|2015-10-29 00:00:00| +---------------+-------------+---------+-------------------+ ``` Also please note that there are no nulls in the dataframe. I am scratching me head where I am doing something wrong. Need help!
2019/02/06
[ "https://Stackoverflow.com/questions/54558489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5453723/" ]
Just out of curiosity: ``` hash = Hash.new do |h, k| h[k] = h.dup.clear.extend(Module.new do define_method(:level, ->{ h.level - 1 }) end).tap { |this| raise "" if this.level <= 0 } end.extend(Module.new { define_method(:level, ->{ 5 }) }) #⇒ {} hash["0"]["1"]["2"]["3"] #⇒ {} hash["0"]["1"]["2"]["3"]["4"] #⇒ RuntimeError: "" ``` --- Or, as a function: ``` def nhash lvl Hash.new do |h, k| h[k] = h.dup.clear.extend(Module.new do define_method(:level, ->{ h.level - 1 }) end).tap { |this| raise "" if this.level < 0 } end.extend(Module.new { define_method(:level, ->{ lvl }) }) end ``` Resulting in: ``` ✎ h = nhash 2 #⇒ {} ✎ h[0][1] = [1, 2, 3] #⇒ [1, 2, 3] ✎ h[2][0] #⇒ {} ✎ h[2][0][5] #⇒ RuntimeError: ``` One might reset the default proc instead of raising if necessary. The only drawback of this approach, on attempt to call the level above permitted, all the intermediate empty hashes will be created. This *also* might be overcome by defining the method, accumulating the path (instead of simply returning the level,) and erasing empty parents before raising.
You can use [`default_proc`](http://ruby-doc.org/core-2.3.0/Hash.html#method-i-default_proc) for this. The best explanation is that given in the docs: > > If Hash::new was invoked with a block, return that block, otherwise return nil. > > > So in this case, each new hash key is instantiated with its parent hash's default. For example: ``` hash = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) } ``` That way, every nested level will have the same default: ``` hash[0][1] = [1, 2, 3] hash[:first_level] # => {} hash[:first_level][:second_level] # => {} hash[2] # => {} hash # => {0=>{1=>[1, 2, 3]}, :first_level=>{:second_level=>{}}, 2=>{}} ``` --- Edit based on comment: In that case, you could use something ugly, though working, like this: ``` hash = Hash.new { |h, k| h[k] = Hash.new { |h, k| h[k] = Hash.new { |h, k| h[k] = raise('Too Deep') } } } hash[1] # => {} hash[1][2] # => {} hash[1][2][3] # => RuntimeError: Too Deep ```
84,438
I am building a website which requires the feeds facility (like what you have in Facebook or Google Plus). Facebook uses single column feeds, Google uses multi column feeds which are card based. **My Question:** Which layout is best suited for a good UI where the user gets enough attention to most of the feed contents as well as feels easy to work with? I am ready to use any layout apart from what Google or FB uses. So, is there any other better way to represent feeds? Of course for handheld devices, the transition will happen to single column feeds due to the limited screen space. But what about other devices. PS: I am not only concerned about the columns for the feeds but also better way to represent them. I did refer: [1-column vs n-column timelines / news feeds](https://ux.stackexchange.com/questions/43891/1-column-vs-n-column-timelines-news-feeds) **UPDATE:** The website I am developing is a social networking website. So, the content which will be displayed in the feed will include user posts, images, videos, etc. (Any User generated content) Thanks in advance.
2015/09/11
[ "https://ux.stackexchange.com/questions/84438", "https://ux.stackexchange.com", "https://ux.stackexchange.com/users/74484/" ]
I would go with a facebook based scroll but keep in mind that Infinite scrolling can decline your bounce rate. Time.com’s bounce rate down 15 percentage points since adopting continuous scroll...you can read about it here: <https://blog.growth.supply/13-mind-blowing-statistics-on-user-experience-48c1e1ede755> I think if you are going to adopt any feed, facebook feed is widely recognized and more users are used to it as oppose to google +
As a frequent user of Google plus, I'd say: let the user decide. Depending on screen size and window size one might like to use a three or more column layout and others prefer wide items in a single column. Just create a simple slider widget to let them choose for their own and set a sensible default like 2 columns.
655,479
I’m still pretty new to powershell and practical implementations of it… but I created a script to monitor disk health and have some very bizarre results on 2012 R2. Wondering if anyone has seen the likes of this and/or has a solution… Or is it a bug? The script in question is: ``` $OutputFile=$env:temp + "\~VMRepl-Status.txt" get-vmreplication | Out-File -FilePath $OutputFile measure-vmreplication | Out-File -FilePath $OutputFile -Append Get-PhysicalDisk | Sort Size | FT FriendlyName, Size, MediaType, Manufacturer, Model, HealthStatus, OperationalStatus -AutoSize | Out-File -FilePath $OutputFile -Append Get-PhysicalDisk | Get-StorageReliabilityCounter | ft deviceid, temperature, wear -AutoSize | Out-File -FilePath $OutputFile -Append $body=(Get-Content $OutputFile | out-string) Send-MailMessage -To [removed] -From [removed] -body $body -SmtpServer 10.24.42.45 -subject "Hyper-V Replica and Disk Disk Status" ``` I execute the above powershell script using a two line batch file: ``` @echo off Powershell.exe -executionpolicy remotesigned -File c:\Windows\scripts\DailyReplicaStatusUpdate.ps1 ``` If I execute the powershell script from a command line or by right clicking and running as administrator, I get: ``` FriendlyName Size MediaType Manufacturer Model HealthStatus OperationalStatus ------------ ---- --------- ------------ ----- ------------ ----------------- PhysicalDisk15 119185342464 SSD INTEL SS DSC2BW120A4 Healthy OK PhysicalDisk3 119185342464 SSD INTEL SSDSC2BW120A4 Healthy OK PhysicalDisk0 1000203804160 UnSpecified SAMSUNG HD103SI Healthy OK PhysicalDisk9 1499480457216 UnSpecified ST315003 41AS Healthy OK PhysicalDisk14 1499480457216 UnSpecified ST315003 41AS Healthy OK PhysicalDisk2 1999575711744 HDD TOSHIBA DT01ACA200 Healthy OK PhysicalDisk1 1999575711744 HDD ST2000DL003-9VT166 Healthy OK PhysicalDisk6 1999575711744 HDD WDC WD20 EARS-00MVWB0 Healthy OK PhysicalDisk4 1999575711744 HDD ST2000DL 003-9VT166 Healthy OK PhysicalDisk11 1999575711744 UnSpecified ST320005 42AS Healthy OK PhysicalDisk21 2000398934016 UnSpecified Seagate Desktop Healthy OK PhysicalDisk10 2999766220800 UnSpecified WDC WD30 EZRX-00DC0B0 Healthy OK PhysicalDisk5 2999766220800 UnSpecified TOSHIBA DT01ACA300 Healthy OK PhysicalDisk7 2999766220800 UnSpecified TOSHIBA DT01ACA300 Healthy OK PhysicalDisk12 2999766220800 HDD ST3000DM 001-1CH166 Healthy OK PhysicalDisk13 2999766220800 HDD ST3000DM 001-1CH166 Healthy OK PhysicalDisk8 2999766220800 HDD ST3000DM 001-9YN166 Healthy OK PhysicalDisk22 3000592977920 UnSpecified Seagate Expansion Desk Healthy OK ``` But if I initiate it from a scheduled task, I get: ``` FriendlyName Size MediaType Manufacturer Model Healt hStat us ------------ ---- --------- ------------ ----- ----- PhysicalDisk15 119185342464 SSD INTEL SS DSC2BW120A4 He... PhysicalDisk3 119185342464 SSD INTEL SSDSC2BW120A4 He... PhysicalDisk0 1000203804160 UnSpecified SAMSUNG HD103SI He... PhysicalDisk9 1499480457216 UnSpecified ST315003 41AS He... PhysicalDisk14 1499480457216 UnSpecified ST315003 41AS He... PhysicalDisk2 1999575711744 HDD TOSHIBA DT01ACA200 He... PhysicalDisk1 1999575711744 HDD ST2000DL003-9VT166 He... PhysicalDisk6 1999575711744 HDD WDC WD20 EARS-00MVWB0 He... PhysicalDisk4 1999575711744 HDD ST2000DL 003-9VT166 He... PhysicalDisk11 1999575711744 UnSpecified ST320005 42AS He... PhysicalDisk21 2000398934016 UnSpecified Seagate Desktop He... PhysicalDisk10 2999766220800 UnSpecified WDC WD30 EZRX-00DC0B0 He... PhysicalDisk5 2999766220800 UnSpecified TOSHIBA DT01ACA300 He... PhysicalDisk7 2999766220800 UnSpecified TOSHIBA DT01ACA300 He... PhysicalDisk12 2999766220800 HDD ST3000DM 001-1CH166 He... PhysicalDisk13 2999766220800 HDD ST3000DM 001-1CH166 He... PhysicalDisk8 2999766220800 HDD ST3000DM 001-9YN166 He... PhysicalDisk22 3000592977920 UnSpecified Seagate Expansion Desk He... ``` I'd love to know how to get it to stop truncating the lines and allow me to get the actual health status - full text - without losing any other information along the way (I COULD drop the size or something else and shorten each line's length). At the end of the day, the goal is to get the output like I get from running it on a command line rather than the output I'm getting when it runs via the Task Scheduler.
2014/12/30
[ "https://serverfault.com/questions/655479", "https://serverfault.com", "https://serverfault.com/users/10010/" ]
Alright, your problem is the use of the [`Out-String` cmdlet](http://technet.microsoft.com/en-us/library/hh849952.aspx). It has a default value of 80, though you can change that by defining a different width, with the `-Width` switch. Looks like you're 25 characters over, so you should be able to fix it by changing line 6 to: > > $body=(Get-Content $OutputFile | out-string -Width 105) > > >
The console window has a different width when run from the scheduled task (if you could see the window it would look more like a standard black command prompt than the blue Powershell window you're used to seeing). This matters because you're using `ft` (`Format-Table`), which is typically used for output to a screen only. You can resize the console window using `$host.Console.RawUI` and its properties but I do recommend not using a `Format-` command even though it may be easier in this instance. Also this will not work in ISE. Instead, format the strings yourself for the email message.
63,424,453
I have a list of Twitter hashtags named `li`. I want to make a new list `top_10` of the most frequent hashtags from that. So far I have done ([#](https://stackoverflow.com/a/3594640/7673979)): ``` li = ['COVID19', 'Covid19', 'covid19', 'coronavirus', 'Coronavirus',...] tag_counter = dict() for tag in li: if tag in tag_counter: tag_counter[tag] += 1 else: tag_counter[tag] = 1 popular_tags = sorted(tag_counter, key = tag_counter.get, reverse = True) top_10 = popular_tags[:10] print('\nList of the top 10 popular hashtags are :\n',top_10) ``` As the hashtags are not case-sensitive, I want to apply case-insensitivity while creating my `tag_counter`.
2020/08/15
[ "https://Stackoverflow.com/questions/63424453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7673979/" ]
Use [`collections.Counter`](https://docs.python.org/3/library/collections.html#collections.Counter) from the standard library ```py from collections import Counter list_of_words = ['hello', 'hello', 'world'] lowercase_words = [w.lower() for w in list_of_words] Counter(lowercase_words).most_common(1) ``` Returns: ``` [('hello', 2)] ```
You can use `Counter` from collections library ``` from collections import Counter li = ['COVID19', 'Covid19', 'covid19', 'coronavirus', 'Coronavirus'] print(Counter([i.lower() for i in li]).most_common(10)) ``` Output: ``` [('covid19', 3), ('coronavirus', 2)] ```
63,424,453
I have a list of Twitter hashtags named `li`. I want to make a new list `top_10` of the most frequent hashtags from that. So far I have done ([#](https://stackoverflow.com/a/3594640/7673979)): ``` li = ['COVID19', 'Covid19', 'covid19', 'coronavirus', 'Coronavirus',...] tag_counter = dict() for tag in li: if tag in tag_counter: tag_counter[tag] += 1 else: tag_counter[tag] = 1 popular_tags = sorted(tag_counter, key = tag_counter.get, reverse = True) top_10 = popular_tags[:10] print('\nList of the top 10 popular hashtags are :\n',top_10) ``` As the hashtags are not case-sensitive, I want to apply case-insensitivity while creating my `tag_counter`.
2020/08/15
[ "https://Stackoverflow.com/questions/63424453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7673979/" ]
Use [`collections.Counter`](https://docs.python.org/3/library/collections.html#collections.Counter) from the standard library ```py from collections import Counter list_of_words = ['hello', 'hello', 'world'] lowercase_words = [w.lower() for w in list_of_words] Counter(lowercase_words).most_common(1) ``` Returns: ``` [('hello', 2)] ```
See below ``` from collections import Counter lst = ['Ab','aa','ab','Aa','Cct','aA'] lower_lst = [x.lower() for x in lst ] counter = Counter(lower_lst) print(counter.most_common(1)) ```
63,424,453
I have a list of Twitter hashtags named `li`. I want to make a new list `top_10` of the most frequent hashtags from that. So far I have done ([#](https://stackoverflow.com/a/3594640/7673979)): ``` li = ['COVID19', 'Covid19', 'covid19', 'coronavirus', 'Coronavirus',...] tag_counter = dict() for tag in li: if tag in tag_counter: tag_counter[tag] += 1 else: tag_counter[tag] = 1 popular_tags = sorted(tag_counter, key = tag_counter.get, reverse = True) top_10 = popular_tags[:10] print('\nList of the top 10 popular hashtags are :\n',top_10) ``` As the hashtags are not case-sensitive, I want to apply case-insensitivity while creating my `tag_counter`.
2020/08/15
[ "https://Stackoverflow.com/questions/63424453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7673979/" ]
Normalize data first, with lower or upper. ``` li = ['COVID19', 'Covid19', 'covid19', 'coronavirus', 'Coronavirus'] li = [x.upper() for x in li] # OR, li = [x.lower() for x in li] tag_counter = dict() for tag in li: if tag in tag_counter: tag_counter[tag] += 1 else: tag_counter[tag] = 1 popular_tags = sorted(tag_counter, key = tag_counter.get, reverse = True) top_10 = popular_tags[:10] print('\nList of the top 10 popular hashtags are :\n',top_10) ```
You can use `Counter` from collections library ``` from collections import Counter li = ['COVID19', 'Covid19', 'covid19', 'coronavirus', 'Coronavirus'] print(Counter([i.lower() for i in li]).most_common(10)) ``` Output: ``` [('covid19', 3), ('coronavirus', 2)] ```
63,424,453
I have a list of Twitter hashtags named `li`. I want to make a new list `top_10` of the most frequent hashtags from that. So far I have done ([#](https://stackoverflow.com/a/3594640/7673979)): ``` li = ['COVID19', 'Covid19', 'covid19', 'coronavirus', 'Coronavirus',...] tag_counter = dict() for tag in li: if tag in tag_counter: tag_counter[tag] += 1 else: tag_counter[tag] = 1 popular_tags = sorted(tag_counter, key = tag_counter.get, reverse = True) top_10 = popular_tags[:10] print('\nList of the top 10 popular hashtags are :\n',top_10) ``` As the hashtags are not case-sensitive, I want to apply case-insensitivity while creating my `tag_counter`.
2020/08/15
[ "https://Stackoverflow.com/questions/63424453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7673979/" ]
Normalize data first, with lower or upper. ``` li = ['COVID19', 'Covid19', 'covid19', 'coronavirus', 'Coronavirus'] li = [x.upper() for x in li] # OR, li = [x.lower() for x in li] tag_counter = dict() for tag in li: if tag in tag_counter: tag_counter[tag] += 1 else: tag_counter[tag] = 1 popular_tags = sorted(tag_counter, key = tag_counter.get, reverse = True) top_10 = popular_tags[:10] print('\nList of the top 10 popular hashtags are :\n',top_10) ```
See below ``` from collections import Counter lst = ['Ab','aa','ab','Aa','Cct','aA'] lower_lst = [x.lower() for x in lst ] counter = Counter(lower_lst) print(counter.most_common(1)) ```
4,095,009
I've used VS2008 on my development machine for some years now, with windows SDK v7.1. I've installed VS2010, and it's using the Windows SDK v7.0a, but I need it to use the Windows 7.1 SDK (which I had installed prior to installing VS2010). When I run the Windows SDK 7.1 configuration tool, to switch the Windows SDK in use, the tool updates for VS2008, but not for VS2010. The message it reports is: ``` "The Windows SDK Configuration Tool has successfully set Windows SDK version v7.1 as the current version for Visual Studio 2008" ``` The configuration tool is installed with the Windows 7.1 SDK and is found here: ``` "C:\Program Files\Microsoft SDKs\Windows\v7.1\Setup\WindowsSdkVer.exe" ``` VS2010 continues to use WSDK 7.0a, which extremely frustrating, as I need to do DirectShow development (so I need to build the baseclasses, which aren't released with 7.0a release of WSDK). Would I be correct in assuming that it's not updating VS2010 settings because VS2010 wasn't installed at the time that I installed Windows 7.1 SDK? Can I fix this manually, or should I uninstall Windows 7.1 SDK, then reinstall it? Any other suggestions / workarounds for this?
2010/11/04
[ "https://Stackoverflow.com/questions/4095009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
For all those using *Visual Studio Command Prompt* I mention you have to modify `VCVarsQueryRegistry.bat` file (it's being called (indirectly) by `%VSINSTALLDIR%\VC\vcvarsall.bat`) which is placed in `%VSINSTALLDIR%\Common7\Tools` folder (typicaly `C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools`) by modifying line 26 from ``` @for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" /v "InstallationFolder"') DO ( ``` to ``` @for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1" /v "InstallationFolder"') DO ( ``` I wish someone from Microsoft explained why `WindowsSdkVer.exe` doesn't work for VS 2010...
Take a look at this page guys. This is going to solve your problems -> [Building Applications that Use the Windows SDK](http://msdn.microsoft.com/en-us/library/ff660764.aspx)
4,095,009
I've used VS2008 on my development machine for some years now, with windows SDK v7.1. I've installed VS2010, and it's using the Windows SDK v7.0a, but I need it to use the Windows 7.1 SDK (which I had installed prior to installing VS2010). When I run the Windows SDK 7.1 configuration tool, to switch the Windows SDK in use, the tool updates for VS2008, but not for VS2010. The message it reports is: ``` "The Windows SDK Configuration Tool has successfully set Windows SDK version v7.1 as the current version for Visual Studio 2008" ``` The configuration tool is installed with the Windows 7.1 SDK and is found here: ``` "C:\Program Files\Microsoft SDKs\Windows\v7.1\Setup\WindowsSdkVer.exe" ``` VS2010 continues to use WSDK 7.0a, which extremely frustrating, as I need to do DirectShow development (so I need to build the baseclasses, which aren't released with 7.0a release of WSDK). Would I be correct in assuming that it's not updating VS2010 settings because VS2010 wasn't installed at the time that I installed Windows 7.1 SDK? Can I fix this manually, or should I uninstall Windows 7.1 SDK, then reinstall it? Any other suggestions / workarounds for this?
2010/11/04
[ "https://Stackoverflow.com/questions/4095009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In project properties -> Configuration Properties -> General, set Platform Toolkit to WindowsSDK7.1 (or whatever version you want to use). Remember when you do this to select all configurations (release, debug, etc.) and all platforms (win32, x64, etc.) as appropriate. The documentation says you can set this option in the solution properties, but that does not seem to be the case.
Take a look at this page guys. This is going to solve your problems -> [Building Applications that Use the Windows SDK](http://msdn.microsoft.com/en-us/library/ff660764.aspx)
20,943,369
I am trying to calculate the grand total of columns I just created with a SUM (if). I have a table with several product numbers but I want to get totals for specific products only. This is my query: ``` Select date(orders.OrderDate) As Date, Sum(If((orders.ProductNumber = '1'), orders.Qty, 0)) As `Product 1`, Sum(If((orders.ProductNumber = '2'), orders.Qty, 0)) As `Product 2`, Sum(If((orders.ProductNumber = '3'), orders.Qty, 0)) As `Product 3`, From orders Group By date(orders.OrderDate) ``` I get the totals for each product in columns as expected, but when I try to get the grand total `(Product 1 + product 2 + Product 3)` using `Sum(orders.Qty) as Total`, I get the SUM of ALL products in the table and not only the 3 I am looking for. How can I get the `SUM(Product 1 + Product 2 + Product 3)`? Thank you
2014/01/06
[ "https://Stackoverflow.com/questions/20943369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/241067/" ]
Try this: ``` SELECT DATE(o.OrderDate) AS date, SUM(IF(o.ProductNumber = '1', o.Qty, 0)) AS `Product 1`, SUM(IF(o.ProductNumber = '2', o.Qty, 0)) AS `Product 2`, SUM(IF(o.ProductNumber = '3', o.Qty, 0)) AS `Product 3`, SUM(IF(o.ProductNumber IN ('1', '2', '3'), o.Qty, 0)) AS `Total` FROM orders o GROUP BY DATE(o.OrderDate) ```
Simply pre-cutting rows other than 1, 2, 3. This is faster when `ProductNumber` is INDEXed column. ``` SELECT DATE(orders.OrderDate) AS Date, SUM(IF((orders.ProductNumber = '1'), orders.Qty, 0)) AS `Product 1`, SUM(IF((orders.ProductNumber = '2'), orders.Qty, 0)) AS `Product 2`, SUM(IF((orders.ProductNumber = '3'), orders.Qty, 0)) AS `Product 3`, SUM(orders.Qty) AS Total FROM orders WHERE orders.ProductNumber IN ('1', '2', '3') GROUP BY DATE(orders.OrderDate) ```
26,939
How do you import a GIMP XCF File into Blender when running it on windows 7? I see all this stuff for how to do it in Linux, but is there anyway to do it with windows? And what is this <http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Import-Export/GIMPImageToScene> talking about?
2015/03/10
[ "https://blender.stackexchange.com/questions/26939", "https://blender.stackexchange.com", "https://blender.stackexchange.com/users/13088/" ]
There is an "import GIMP" addon currently available, but it doesn't look like it's very stable at this point. You can activate it under *User Preferences > Addons > Import GIMP to scene*. Use key search word GIMP to locate it. Then it just a matter of opening the import menu, selecting xcf and importing the file. like I said though, it's kinda unstable, wait for more hardy versions to come out if you can.
Xcftools requires compiling, which it was designed for within a Unix environment. On windows 7/later. Also keep an eye on the console for any errors, and what line those errors appear on while using the *Import GIMP to scene* script. You can use Notepad++/blender's script editor to check these. An alternative however that works just as well (as the script converts your layers to PNG's anyway): Use the 'Export Layers' script within GIMP (you might need to search [gimp plugin registry](http://registry.gimp.org/)) [![enter image description here](https://i.stack.imgur.com/NUNWQ.png)](https://i.stack.imgur.com/NUNWQ.png) It will export all of your layers into one neat folder, with each separate image named by the layer it's taken from. Then you can use the tried and tested *Images as planes* addon that is more robust.[![enter image description here](https://i.stack.imgur.com/lH8uS.png)](https://i.stack.imgur.com/lH8uS.png)
38,229,947
Here is the html code I am using: ``` <div class="container"> <div class="row"> <div class='col-sm-6'> <div class="form-group"> <div class='input-group date' id='datetimepicker1'> <input type='text' class="form-control" data-ng-model="dateOfCal" /> <span class="input-group-addon"> <span class="glyphicon glyphicon-calendar"></span> </span> </div> </div> </div> <script type="text/javascript"> $(function () { $('#datetimepicker1').datetimepicker(); }); </script> </div> </div> ``` This works on index.html, but when I move this code to an html page that is accessed by ``` <div ng-view=''></div> ``` the calendar no longer pops up.
2016/07/06
[ "https://Stackoverflow.com/questions/38229947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6557260/" ]
Use this query only: ``` SELECT A,B,C AS LEN,D,E FROM TABLE1 ``` On your form, hide the textbox bound to LEN. Create a new unbound textbox, say, txtLEN. Now use code like this where SelectMetric is the checkbox to mark when using metric values: ``` Private Sub Form_Current() Dim Factor As Currency If Me!SelectMetric.Value = True Then Factor = 0.3048 Else Factor = 1 End If Me!txtLen.Value = Factor * Me!LEN.Value End Sub Private Sub txtLen_AfterUpdate() Dim Factor As Currency If Me!SelectMetric.Value = True Then Factor = 0.3048 Else Factor = 1 End If Me!Len.Value = Me!txtLEN.Value / Factor End Sub ```
Just change what is displayed in the textbox. Set up the text box to have a control source of ``` =Length*txtConversionFactor ``` Where `txtConversionFactor` is a hidden textbox which either has `1` in it if your units are to be displayed in feet or 0.3048 if they are to be displayed in meters. It could even be a combobox bound to a table like this ``` MultiplyFeetByToGetOutputUnits OutputUnits 1 ft 0.3048 m 12 in 0.000189394 mile ``` Then you can convert to whatever you want without changing your form.
39,079,165
I have about 12 databases, each with 50 tables and most of them with 30+ columns; the db was running in strict mode as OFF, but now we had to migrate the db to cleardb service which by default has strict mode as ON. all the tables that had "Not Null" constraint, the inserts have stopped working, just because the default values are not being passed; while in case of strict mode as OFF if the value are not provided, the MYSQL will presume the default value of the column datatype. Is there a script I can use to get the metadata about all the columns of all tables and generate a script to alter all the tables with such columns to change the default to "Null"
2016/08/22
[ "https://Stackoverflow.com/questions/39079165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1251674/" ]
You should consider using the `information_schema` tables to generate DDL statements to alter the tables. This kind of query will get you the list of offending columns. ``` SELECT CONCAT_WS('.',TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME) col FROM information_schema.COLUMNS WHERE IS_NULLABLE = 0 AND LENGTH(COLUMN_DEFAULT) = 0 AND TABLE_SCHEMA IN ('db1', 'db2', 'db3') ``` You can do similar things to generate `ALTER` statements to change the tables. But beware, MySQL likes to rewrite tables when you alter certain things. It might take time. **DO NOT** attempt to `UPDATE` the information\_schema directly! You could try changing the strict\_mode setting when you connect to the SaaS service, so your software will work compatibly. This is a large project and is probably important business for cleardb. Why not ask them for help in changing the strict\_mode setting?
This is what I came up with on the base of @Ollie-jones script <https://gist.github.com/brijrajsingh/efd3c273440dfebcb99a62119af2ecd5> ``` SELECT CONCAT_WS('.',TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME) col,CONCAT('alter table ',TABLE_NAME,' MODIFY COLUMN ', COLUMN_NAME,' ',DATA_TYPE,'(',CHARACTER_MAXIMUM_LENGTH,') NULL DEFAULT NULL') as script_col FROM information_schema.COLUMNS WHERE is_nullable=0 and length(COLUMN_DEFAULT) is NULL and CHARACTER_MAXIMUM_LENGTH is not NULL and table_schema = 'immh' Union SELECT CONCAT_WS('.',TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME) col,CONCAT('alter table ',TABLE_NAME,' MODIFY COLUMN ', COLUMN_NAME,' ',DATA_TYPE,' NULL DEFAULT NULL') as script_col FROM information_schema.COLUMNS WHERE is_nullable=0 and length(COLUMN_DEFAULT) is NULL and CHARACTER_MAXIMUM_LENGTH is NULL and table_schema = 'immh' ```
62,350
I wanted to speed up my rendering time, and I found that using GPU speed up a lot. But I don't have a very fast GPU (NVIDIA GeForce 320M 256 MB), so I want to know what do the difference between using GPU or CPU, so I would compare my CPU (2,66 GHz Intel Core 2 Duo) with my GPU (NVIDIA GeForce 320M 256 MB).
2016/09/04
[ "https://blender.stackexchange.com/questions/62350", "https://blender.stackexchange.com", "https://blender.stackexchange.com/users/29230/" ]
Gpu's have many cores (yours may have 72 cores) but they run at lower speed (frequency) .Gpu cores can understand simpier instructions that a cpu core can understand.Cpu has much less cores than gpu cores but they run at higher frequency and they understand complex set of instructions.These are some key differences.
A GPU can usually render faster than a CPU.Try rendering a single frame with your gpu and then your cpu and see witch one is faster.
29,431,694
``` import UIKit class ViewController: UIViewController { @IBOutlet weak var yourScore: UITextField! @IBOutlet weak var totalScore: UITextField! @IBOutlet weak var labelText: UILabel! @IBAction func buttonPressed(sender: AnyObject) { let score1: Int = yourScore.text.toInt()! let score2: Int = totalScore.text.toInt()! let mistakes = score2 - score1 let scoreFinal = ((((score2 / 2) - mistakes)*23)/score2)+75 labelText.text = "\(scoreFinal)" } override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } ``` Something is wrong with my code. Is it because of data types or something? When I load the application, it just opens fine but when the button is pressed, the app crashes. <http://i.stack.imgur.com/B2i5Z.png>
2015/04/03
[ "https://Stackoverflow.com/questions/29431694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3887815/" ]
jQuery can help: ``` <div id="my_div">image here</div> <script> $(function(){ $("#my_div").hover(function(){ // Put here some action for onMouseOver }, function(){ // Put here some action for onMouseOut }); }); </script> ``` Or even: ``` <div id="my_div">image here</div> <script> $( "#my_div" ).mouseout(function() { // Put here some action for onMouseOut }); </script> ```
```html <html> <script language="javascript"> function chng() { alert("mouseout"); } </script> <body> <div onmouseout="chng()"> //Image Here </div> </body> </html> ```
3,014,004
chi-square test(principle used in C4.5's CVP Pruning), also called chi-square statistics, also called chi-square goodness-of fit How to prove **$\sum\_{i=1}^{i=r}\sum\_{j=1}^{j=c}\frac{(x\_{ij}-E\_{ij} )^2}{E\_{ij}} = \chi^2\_{(r-1)(c-1)}$** where $E\_{ij}=\frac{N\_i·N\_j}{N}$, $N$ is the total counts of the whole datasets. $N\_i$ are the counts of the sub-datasets of the same-value of feature $N\_j$ are the counts of the sub-datasets of the same-class please help,thanks~! [here is contingency table](https://i.stack.imgur.com/AqB6c.png) /------------------------------------------------ here are some references which are not clear: <https://arxiv.org/pdf/1808.09171.pdf> (not mention why $k-1$ is used in formula(5)) <https://www.math.utah.edu/~davar/ps-pdf-files/Chisquared.pdf> (Not mention why $\Theta<1$ from (9)->(10)) <https://arxiv.org/pdf/1808.09171> (page 4th not mention what is X\*with a line on it) <http://personal.psu.edu/drh20/asymp/fall2006/lectures/ANGELchpt07.pdf> (Page 109th,Not mention why $Cov(X\_{ij},X\_{il}=-p\_ip\_l)$)
2018/11/26
[ "https://math.stackexchange.com/questions/3014004", "https://math.stackexchange.com", "https://math.stackexchange.com/users/553237/" ]
The proof uses $x\_{ij}\approx\operatorname{Poisson}(E\_{ij})\approx N(E\_{ij},\,E\_{ij})$. The reason for $k-1$ is that $\sum\_i N\_i=N$ removes a degree of freedom. The reason for $\Theta\le 1$ is because the $\theta\_i$ are probabilities.
<https://blog.csdn.net/appleyuchi/article/details/84567158> I try to prove it from multi-nominal distribution. The above link is my record,NOT very rigorous, If there are something wrong ,please let me know,thanks. If there are other proof which is much easier to understand ,please let me know,thanks. Many thanks for all your help~!
9,460,035
I have an excel file in which there are 10 columns with the data starting from: ``` Text1 | Text4 | Text7 Text2 | Text5 | Text8 Text3 | Text6 | Text9 ``` For my requirement, I have to remove the part `Text` from all these cells. How is this done in Excel? I am a complete newbie to this.
2012/02/27
[ "https://Stackoverflow.com/questions/9460035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/458790/" ]
You can do this directly with your data without formula **Manually** * Select the area of interest * Press Ctrl & F to bring up the Find and Replace dialog * Select the ‘Replace’ tab * Under ‘Find what’ put `Text`, leave ‘Replace With’ blank * Ensure ‘Match entire cell content’ is unchecked ![sample](https://i.stack.imgur.com/2Oh0C.png) **VBA** `Selection.Replace "Text", vbNullString, xlPart`
Use a formula: ``` =VALUE(SUBSTITUTE(A1,"Text","")) ```
9,460,035
I have an excel file in which there are 10 columns with the data starting from: ``` Text1 | Text4 | Text7 Text2 | Text5 | Text8 Text3 | Text6 | Text9 ``` For my requirement, I have to remove the part `Text` from all these cells. How is this done in Excel? I am a complete newbie to this.
2012/02/27
[ "https://Stackoverflow.com/questions/9460035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/458790/" ]
You can do this directly with your data without formula **Manually** * Select the area of interest * Press Ctrl & F to bring up the Find and Replace dialog * Select the ‘Replace’ tab * Under ‘Find what’ put `Text`, leave ‘Replace With’ blank * Ensure ‘Match entire cell content’ is unchecked ![sample](https://i.stack.imgur.com/2Oh0C.png) **VBA** `Selection.Replace "Text", vbNullString, xlPart`
Assuming the first cell is A1 type this in the formula bar = Mid(A1, 5, Len(A1) -4) you can fill series for the other cells.
9,460,035
I have an excel file in which there are 10 columns with the data starting from: ``` Text1 | Text4 | Text7 Text2 | Text5 | Text8 Text3 | Text6 | Text9 ``` For my requirement, I have to remove the part `Text` from all these cells. How is this done in Excel? I am a complete newbie to this.
2012/02/27
[ "https://Stackoverflow.com/questions/9460035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/458790/" ]
You can do this directly with your data without formula **Manually** * Select the area of interest * Press Ctrl & F to bring up the Find and Replace dialog * Select the ‘Replace’ tab * Under ‘Find what’ put `Text`, leave ‘Replace With’ blank * Ensure ‘Match entire cell content’ is unchecked ![sample](https://i.stack.imgur.com/2Oh0C.png) **VBA** `Selection.Replace "Text", vbNullString, xlPart`
Find and replace tool works well, if the "text" varies though it will no longer work. For future people looking for a fix for a similar problem but where the text is different then you just place " \*" in the find what box then replace. (don't use the quote marks but do put in a space before the \*) This removes any entry after the text. swapping the \* and the space will remove any text before the space.
18,652,495
The question is simple. I have a lot of ajax functions all across my application. Some examples are - ``` $.ajax({ type: "POST", url: "http://www.dev.com/login/", data: data, success: function(result) { //success }, dataType: "json", }); $.ajax({ type: "POST", url: "http://www.dev.com/register/", data: data, success: function(result) { //success }, dataType: "json", }); ``` Now if I want to change my url from "`www.dev.com/login/`" to "`www.dev.com/login/?apikey=#########`", similarly for register, I will have to change the urls everywhere. Instead I would like to be able to change the url of every ajax function on the go. Like, have a script which detects when an ajax function is called and appends '`?apikey=######`' to the url parameter. Thank you.
2013/09/06
[ "https://Stackoverflow.com/questions/18652495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/478377/" ]
You can set `data-url` for DOM and make ajax request according to that `data-url` **Example** ``` <a data-url="http://somelocation/login" >login</a> <a data-url="http://somelocation/register" >Register</a> ``` Then you can get this data url into ajax url as below, ``` url: $(this).data('url'), ``` and you are done.
As what I understand you require this ``` $(document).bind("beforeSend", function(){ // this.url; do whatever you want to do with url }); ``` However I had not try with changing that url, you need to google for it.
18,652,495
The question is simple. I have a lot of ajax functions all across my application. Some examples are - ``` $.ajax({ type: "POST", url: "http://www.dev.com/login/", data: data, success: function(result) { //success }, dataType: "json", }); $.ajax({ type: "POST", url: "http://www.dev.com/register/", data: data, success: function(result) { //success }, dataType: "json", }); ``` Now if I want to change my url from "`www.dev.com/login/`" to "`www.dev.com/login/?apikey=#########`", similarly for register, I will have to change the urls everywhere. Instead I would like to be able to change the url of every ajax function on the go. Like, have a script which detects when an ajax function is called and appends '`?apikey=######`' to the url parameter. Thank you.
2013/09/06
[ "https://Stackoverflow.com/questions/18652495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/478377/" ]
You can use the `$.ajaxSetup()` to set the required extra data with all the Ajax call made by the page through jQuery. ``` $.ajaxSetup({ data: {apikey:"#####"} }); ``` Check the API over here <http://api.jquery.com/jQuery.ajaxSetup/> You can check the console to see the parameters send to url. <http://jsfiddle.net/MTHxt/1/>
As what I understand you require this ``` $(document).bind("beforeSend", function(){ // this.url; do whatever you want to do with url }); ``` However I had not try with changing that url, you need to google for it.
82,791
Preface ======= I've installed gravity forms, created a form and users are submitting data to my site. What I want to do is show the data users are submitting to my site on one of my pages. I know there's the [Gravity Forms Directory](http://wordpress.org/extend/plugins/gravity-forms-addons/) plugin. But this gives only a fixed data presentation. Question ======== **Is there anything in gravity forms that can do something like this? (pseudo code)**: ``` <?php gforms_get_field( $form_id, $entry_id, 'user_name_field' ); ?> ```
2013/01/23
[ "https://wordpress.stackexchange.com/questions/82791", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15010/" ]
You can look at the docs, but you'll probably end up reading the *real* documentation: the source code. If you do, you'll find that: * `GFFormsModel::get_leads($form_id)` returns a list of entries for a form (maybe you know that one already), where each item in the array is itself an array, an "[Entry object](http://www.gravityhelp.com/documentation/page/Entry_Object)" * `GFFormsModel::get_form_meta($form_id)` returns a list of field meta elements (i.e. describes name, type, rules etc.) in the form, where each item in the array is a "[Field object](http://www.gravityhelp.com/documentation/page/Fields)" Once you have an Entry object, you can access the fields as elements, by field number. If you need to find a field by name or type, you need to iterate over the list of fields in the form to get a match, and then access the entry's field by field ID. NB: determining a field's type is best done by passing the field's meta element to `GFFormsModel::get_input_type($field)` Edit: note also that only the first 200 characters of each field are returned in the Entry object. If you have fields that store more information, you'll need to ask for it, e.g. by calling `GFFormsModel::get_field_value_long($lead, $field_number, $form)`.
You could use a `gform_after_submission` hook to write everything you need to a custom post type, which might be easier to manipulate "out in the field", and will be safe from, say, someone deleting a single field and obliterating all the data associated with it. <http://www.gravityhelp.com/documentation/page/Gform_after_submission> Yoast has a pretty good writeup on writing to custom fields, without even using the hook. <http://yoast.com/gravity-forms-custom-post-types/> Good luck!
82,791
Preface ======= I've installed gravity forms, created a form and users are submitting data to my site. What I want to do is show the data users are submitting to my site on one of my pages. I know there's the [Gravity Forms Directory](http://wordpress.org/extend/plugins/gravity-forms-addons/) plugin. But this gives only a fixed data presentation. Question ======== **Is there anything in gravity forms that can do something like this? (pseudo code)**: ``` <?php gforms_get_field( $form_id, $entry_id, 'user_name_field' ); ?> ```
2013/01/23
[ "https://wordpress.stackexchange.com/questions/82791", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15010/" ]
You can look at the docs, but you'll probably end up reading the *real* documentation: the source code. If you do, you'll find that: * `GFFormsModel::get_leads($form_id)` returns a list of entries for a form (maybe you know that one already), where each item in the array is itself an array, an "[Entry object](http://www.gravityhelp.com/documentation/page/Entry_Object)" * `GFFormsModel::get_form_meta($form_id)` returns a list of field meta elements (i.e. describes name, type, rules etc.) in the form, where each item in the array is a "[Field object](http://www.gravityhelp.com/documentation/page/Fields)" Once you have an Entry object, you can access the fields as elements, by field number. If you need to find a field by name or type, you need to iterate over the list of fields in the form to get a match, and then access the entry's field by field ID. NB: determining a field's type is best done by passing the field's meta element to `GFFormsModel::get_input_type($field)` Edit: note also that only the first 200 characters of each field are returned in the Entry object. If you have fields that store more information, you'll need to ask for it, e.g. by calling `GFFormsModel::get_field_value_long($lead, $field_number, $form)`.
Thanks to webaware for their answer. Here's some copy/pasta for anyone looking for a quick start. This takes an entry ID and retrieves the lead and form from that. In this case I'm using the URL to pass the value. e.g. somedomain.com?entry=123. ``` <?php $lead_id = $_GET['entry']; $lead = RGFormsModel::get_lead( $lead_id ); $form = GFFormsModel::get_form_meta( $lead['form_id'] ); $values= array(); foreach( $form['fields'] as $field ) { $values[$field['id']] = array( 'id' => $field['id'], 'label' => $field['label'], 'value' => $lead[ $field['id'] ], ); } ?> <pre><?php print_r($values); ?></pre> ```
82,791
Preface ======= I've installed gravity forms, created a form and users are submitting data to my site. What I want to do is show the data users are submitting to my site on one of my pages. I know there's the [Gravity Forms Directory](http://wordpress.org/extend/plugins/gravity-forms-addons/) plugin. But this gives only a fixed data presentation. Question ======== **Is there anything in gravity forms that can do something like this? (pseudo code)**: ``` <?php gforms_get_field( $form_id, $entry_id, 'user_name_field' ); ?> ```
2013/01/23
[ "https://wordpress.stackexchange.com/questions/82791", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15010/" ]
Thanks to webaware for their answer. Here's some copy/pasta for anyone looking for a quick start. This takes an entry ID and retrieves the lead and form from that. In this case I'm using the URL to pass the value. e.g. somedomain.com?entry=123. ``` <?php $lead_id = $_GET['entry']; $lead = RGFormsModel::get_lead( $lead_id ); $form = GFFormsModel::get_form_meta( $lead['form_id'] ); $values= array(); foreach( $form['fields'] as $field ) { $values[$field['id']] = array( 'id' => $field['id'], 'label' => $field['label'], 'value' => $lead[ $field['id'] ], ); } ?> <pre><?php print_r($values); ?></pre> ```
You could use a `gform_after_submission` hook to write everything you need to a custom post type, which might be easier to manipulate "out in the field", and will be safe from, say, someone deleting a single field and obliterating all the data associated with it. <http://www.gravityhelp.com/documentation/page/Gform_after_submission> Yoast has a pretty good writeup on writing to custom fields, without even using the hook. <http://yoast.com/gravity-forms-custom-post-types/> Good luck!
24,856,143
I'm trying to figure out the best way to take a json object which I'm storing as a scope, and filter/query it to display specific data from within it. For example: ``` $scope.myBook = {"bookName": "Whatever", "pages": [ {"pageid": 1, "pageBody": "html content for the page", "pageTitle": "Page 1"}, {"pageid": 2, "pageBody": "html content for the page", "pageTitle": "Page 2"}, {"pageid": 3, "pageBody": "html content for the page", "pageTitle": "Page 3"}, ] } ``` How would I go about grabbing the object for pageid:2 ?
2014/07/21
[ "https://Stackoverflow.com/questions/24856143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1165935/" ]
You can use this approach: template: ``` <div ng-repeat="page in myBook.pages | filter:pageMatch(pageid)"> {{ page.pageBody }} </div> ``` scope: ``` $scope.pageMatch = function(pageid) { return function(page) { return page.pageid === pageid; }; }; ``` Set `pageid` to needed value in `filter:pageMatch(pageid)` to display necessary page content.
``` function getPage (id) { angular.forEach($scope.myBook.pages, function (page, pageIndex) { if (page.pageId == id) { console.log("Do something here."); return page; } }); } ``` Otherwise . . . ``` $scope.myBook.pages[1]; ```
24,856,143
I'm trying to figure out the best way to take a json object which I'm storing as a scope, and filter/query it to display specific data from within it. For example: ``` $scope.myBook = {"bookName": "Whatever", "pages": [ {"pageid": 1, "pageBody": "html content for the page", "pageTitle": "Page 1"}, {"pageid": 2, "pageBody": "html content for the page", "pageTitle": "Page 2"}, {"pageid": 3, "pageBody": "html content for the page", "pageTitle": "Page 3"}, ] } ``` How would I go about grabbing the object for pageid:2 ?
2014/07/21
[ "https://Stackoverflow.com/questions/24856143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1165935/" ]
You can use this approach: template: ``` <div ng-repeat="page in myBook.pages | filter:pageMatch(pageid)"> {{ page.pageBody }} </div> ``` scope: ``` $scope.pageMatch = function(pageid) { return function(page) { return page.pageid === pageid; }; }; ``` Set `pageid` to needed value in `filter:pageMatch(pageid)` to display necessary page content.
I ended up asking the AngularJS IRC - And one of the guys put this plunker together with exactly what I was looking for. [Plnkr Example](http://plnkr.co/edit/7MT8hVDssf3CG1GfKrJW?p=preview) Props to <https://github.com/robwormald> for the answer. ``` /* See PLNKR Link Above for the answer */ ```
64,161,202
Using rxjs, I would like to make a group of http calls with the value returned from a previous call. I would like the inner calls to execute in parallel. I also need to return the value from the first call as soon as it is available. I need to be able to subscribe to the result and handle any errors. Errors produced by the inner calls should not cause sibling calls to cancel. I have the following code that works, but waits to return the initial value until the inner calls are complete because of the use of `forkJoin`: ``` public create(customer: Customer, groupIds: number[]): Observerable<Customer> { const response = this.http.post<Customer>('/customer', customer).pipe(mergeMap( (created) => { return forkJoin([ of(created), forkJoin(groupIds.map(groupId => { const membership = new Membership(created.Id, groupId); return this.http.post<Membership>('/membership', membership); ) ]); } )).pipe(map(a => a[0])); return response; } ``` Is there a way to return the created customer without waiting for the inner calls to complete? Barring that, is there a way to write the above code more concisely? (Note: `this.http` is of type `HttpClient` from Angular, and returns an `Observable<T>`)
2020/10/01
[ "https://Stackoverflow.com/questions/64161202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/140377/" ]
Because `std::move` is basically just a cast that doesn't actually move anything! You need to update the values in the other object yourself: ``` DemoVector(DemoVector&& rhs) { data_ = rhs.data_; size_ = rhs.size_; capacity_ = rhs.capacity_; rhs.data_ = nullptr; rhs.size_ = 0; rhs.capacity = 0; } ``` Or alternatively to make use of the existing constructor: ``` DemoVector(DemoVector&& rhs): DemoVector() { // Or write your own swap function to reuse this elsewhere std::swap(data_, rhs.data_); std::swap(size_, rhs.size_); std::swap(capacity_, rhs.capacity_); } ``` It's up to you how you want users of your class to handle moved-from objects. In the second case, and possibly also the first depending on how the rest of your class works, `rhs` (`b` in your test case) will be an empty vector.
`std::move(rhs.data_)` doesn't actually move anything. `std::move` is nothing more than a named *cast*. It produces an rvalue reference that *allows* move semantics to occur. But for primitive types, it's just a copy operation. The pointer is being copied, and so you end up with two pointers that contain the same address. Since you don't want the source object to still be pointing at the the same buffer, simply modify it. That's why move-semantics is build around non-const references. Move constructors are commonplace now, so there's a standard utility (C++14) to help write them in a way that makes code behave more as you'd expect. It's [`std::exchange`](https://en.cppreference.com/w/cpp/utility/exchange). You can simply write ``` DemoVector(DemoVector&& rhs) : data_(std::exchange(rhs.data_, nullptr)) , size_(std::exchange(rhs.size_ , 0)) , capacity_(std::exchange(rhs.capacity_ , 0)) {} ``` And all the values get adjusted properly. `std::exchange` modifies its first argument to hold the value of the second argument. And finally, it return the old value of the first argument. Very handy to shift values around in one-liner initializations.
2,577,627
Using explode i have converted the string into array , But the array look like Array ( [0] => root) But i want i make my array somthing like Array ( [root] => root) How to make this manner.. Thanks
2010/04/05
[ "https://Stackoverflow.com/questions/2577627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/246963/" ]
``` $array = explode($separator, $some_string); $array = array_combine($array, $array); ```
You could make it an associative array like so: ``` $exploded = explode (.......); $exploded_associative = array(); foreach ($exploded as $part) if ($part) $exploded_associative[$part] = $part; print_r($exploded_associative); // Will output "root" => "root" .... ``` what exactly do you need this for?
21,070,555
I'm making Connect Four for computer science class as my CPT. SO far I've created the panels but I am having an issue. What I am trying to do is make one panel per slot on the board and fill it with a picture of an empty slot of a connect four board, and when every spot is combined, it'll look like a complete connect four board. Basically I'm adding a grid layout panel to my main panel and filling the grid panel with multiple other panels containing the the slot picture. I've created a sub-routine to do so. But when I run my program, only one slot comes up in the middle, not the 42 that are supposed to show (the board is 7 by 6). My goal right now is to for my sub-routine to create 42 JPanels and put them into the grid panel I have created. I know this may not make a lot of sense but hopefully the code will help you understand more. Thanks for your help.\ P.S. emptyBox.jpg is basically a picture of an empty slot on a connect four board. I want to fill the panel up with these so it looks like a complete board. Here's the code so far: ``` import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; import java.io.*; public class ConnectFour { static JFrame mainWindow; static JButton firstArrow = new JButton("Drop"); static JButton secondArrow = new JButton("Drop"); static JButton thirdArrow = new JButton("Drop"); static JButton fourthArrow = new JButton("Drop"); static JButton fifthArrow = new JButton("Drop"); static JButton sixthArrow = new JButton("Drop"); static JButton seventhArrow = new JButton("Drop"); static JPanel[][] gridArray = new JPanel[6][7]; static JLabel emptyLabel = new JLabel(); static JPanel emptyPanel; static ImageIcon emptyBox; static JLabel redLabel = new JLabel(); static JPanel redPanel; static ImageIcon redBox; static JLabel blackLabel = new JLabel(); static JPanel blackPanel; static ImageIcon blackBox; public static void main(String[] args) { JPanel mainPanel = new JPanel(); JPanel gridPanel = new JPanel(); JPanel buttonPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); gridPanel.setLayout(new GridLayout(6, 7)); buttonPanel.setLayout(new GridLayout(1, 7)); mainPanel.setBackground(new Color(23, 13, 44)); emptyBox = new ImageIcon("emptyBox.jpg"); emptyLabel = new JLabel(emptyBox); emptyPanel = new JPanel(); emptyPanel.add(emptyLabel); mainPanel.add(gridPanel, BorderLayout.CENTER); mainPanel.add(buttonPanel, BorderLayout.NORTH); gridPanel.add(emptyPanel); buttonPanel.add(firstArrow); buttonPanel.add(secondArrow); buttonPanel.add(thirdArrow); buttonPanel.add(fourthArrow); buttonPanel.add(fifthArrow); buttonPanel.add(sixthArrow); buttonPanel.add(seventhArrow); mainWindow = new JFrame("Connect Four"); mainWindow.setContentPane(mainPanel); mainWindow.setSize(846, 730); mainWindow.setLocationRelativeTo(null); mainWindow.setVisible(true); mainWindow.setResizable(false); fillGrid(); } public static void fillGrid() { for(int j = 0; j < 6; j++) { for (int k = 0; k < 7; k++) { gridArray[j][k] = emptyPanel; } } } } ```
2014/01/12
[ "https://Stackoverflow.com/questions/21070555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2871898/" ]
I think you want to and a new JPanel instead of just making it = to the empty panel. What's happening is that you are trying to add one component to a parent containter multiple times, which won't work. A component can only be added *once*. So you the result you're getting, is the only the gridPanel slot being added an `emptyPanel` ``` public static void fillGrid() { for(int j = 0; j < 6; j++) { for (int k = 0; k < 7; k++) { gridArray[j][k] = new JPanel(); gridArray[j][k].add(new Label(emptybox)); gridPanel.add(gridArray[j][k]); } } } ``` You'll also want to move this `gridPanel.add(emptyPanel);` What you can also do, for repetitive tasks is create a simple helper method ``` private JPanel greateOnePanel(){ JPanel panel = new JPanel(); ImageIcon icon = new IMageIcon("emptybox.jpg"): JLabel label = new JLabale(icon); panel.add(label); return panel; } ``` Then in your loop just ``` public static void fillGrid() { for(int j = 0; j < 6; j++) { for (int k = 0; k < 7; k++) { gridPanel.add(createOnePanel()); } } } ```
You need to actually create 42 panels. Currently you have an array with 42 references to the same panel. Change the fillGrid method, so it calls the constructor of JPanel and set the necessary Label etc. (like you do above). Then add it to the GridLayout.
66,073,565
I'm trying to do a time calculator using the input type="time" value, but getting NaN as a result. Here's my code: ```js document.getElementById("MathButton").onclick = timeCalc; function timeCalc() { let startTime = document.getElementById("startTime").value; let endTime = document.getElementById("endTime").value; let diff = endTime - startTime; document.getElementById("diff").innerHTML = (diff); console.log(diff); console.log(startTime, endTime); ``` ```html <div> <p>START</p> <input type="time" id="startTime" name="start" value="08:00"><br /> <p>END</p> <input type="time" id="endTime" name="end" value="16:30"> <br /> <button id="MathButton">Calculate!</button> <br /> <p>Total: <br /> <span id="diff"></span>&nbsp; hours.</p> </div> ``` I just can't get it to do the math, but I can see that both values are present if I add startTime and endTime to the console log. \*\*I accepted Doan's answer as correct as it is the least amount of code and gets the job done. I was able to understand that he took my times and made them into date objects, but since I am relatively new to this I was hoping for more of an explanation. Was able to figure it out though, and get my next part of the program built using this knowledge.
2021/02/06
[ "https://Stackoverflow.com/questions/66073565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15019190/" ]
Here you go ```js document.getElementById("MathButton").onclick = timeCalc; function timeCalc() { let startTime = document.getElementById("startTime").value; let endTime = document.getElementById("endTime").value; //create date format var timeStart = new Date("01/01/2007 " + startTime ); var timeEnd = new Date("01/01/2007 " + endTime ); var diff= timeEnd - timeStart; diff= diff/ 60 / 60 / 1000; document.getElementById("diff").innerHTML = (diff); } ``` ```html <div> <p>START</p> <input type="time" id="startTime" name="start" value="08:00"><br /> <p>END</p> <input type="time" id="endTime" name="end" value="16:30"> <br /> <button id="MathButton">Calculate!</button> <br /> <p>Total: <br /> <span id="diff"></span>&nbsp; hours.</p> </div> ```
You can't just subtract two string first you have to convert them to integers to apply mathematical operations to them. Just split them by ':' like- ``` startTime.split(":") endTime.split(":") diff = toString(startTime[0]- startTime[0])+":"+toString(startTime[1]- startTime[1]) ``` this will form a list then excess the elements by index to subtract them startTime[0] for hours and so on
66,073,565
I'm trying to do a time calculator using the input type="time" value, but getting NaN as a result. Here's my code: ```js document.getElementById("MathButton").onclick = timeCalc; function timeCalc() { let startTime = document.getElementById("startTime").value; let endTime = document.getElementById("endTime").value; let diff = endTime - startTime; document.getElementById("diff").innerHTML = (diff); console.log(diff); console.log(startTime, endTime); ``` ```html <div> <p>START</p> <input type="time" id="startTime" name="start" value="08:00"><br /> <p>END</p> <input type="time" id="endTime" name="end" value="16:30"> <br /> <button id="MathButton">Calculate!</button> <br /> <p>Total: <br /> <span id="diff"></span>&nbsp; hours.</p> </div> ``` I just can't get it to do the math, but I can see that both values are present if I add startTime and endTime to the console log. \*\*I accepted Doan's answer as correct as it is the least amount of code and gets the job done. I was able to understand that he took my times and made them into date objects, but since I am relatively new to this I was hoping for more of an explanation. Was able to figure it out though, and get my next part of the program built using this knowledge.
2021/02/06
[ "https://Stackoverflow.com/questions/66073565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15019190/" ]
Subtracting two strings will result into NaN. Here, I have converted both the strings to date first and then subtracted it. Since substracting two dates gives the result in millisecond, `result/ 60 /60 /1000` converts it to hours. ```js document.getElementById("MathButton").onclick = timeCalc; function timeCalc() { let startTime = new Date().toDateString("yyyy-MM-dd") + " " + document.getElementById("startTime").value; let endTime = new Date().toDateString("yyyy-MM-dd") + " " + document.getElementById("endTime").value; let diff = (new Date(endTime) - new Date(startTime)) / 60/ 60 / 1000; document.getElementById("diff").innerHTML = (diff); console.log(diff); } ``` ```html <div> <p>START</p> <input type="time" id="startTime" name="start" value="08:00"><br /> <p>END</p> <input type="time" id="endTime" name="end" value="16:30"> <br /> <button id="MathButton">Calculate!</button> <br /> <p>Total: <br /> <span id="diff"></span>&nbsp; hours.</p> </div> ```
You can't just subtract two string first you have to convert them to integers to apply mathematical operations to them. Just split them by ':' like- ``` startTime.split(":") endTime.split(":") diff = toString(startTime[0]- startTime[0])+":"+toString(startTime[1]- startTime[1]) ``` this will form a list then excess the elements by index to subtract them startTime[0] for hours and so on
389,850
I need to use a VPN on my mac from time to time. While I'm doing so, it interferes with the ability to use AirDrop and Sidecar. My VPN has the ability to whitelist certain apps, so is there a collection of 'apps' that AirPlay and/or Sidecar uses? I think Sidecar doesn't work with a wired connection when the VPN is on. I've tried whitelisting e.g. Finder but that's not enough, I'm not sure what else could be useful.
2020/04/29
[ "https://apple.stackexchange.com/questions/389850", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/189019/" ]
VPN can be set up to be compatible with both sidecar and airdrop. The process of installing some VPN also can and will break these both if desired or they are targeted for blocking. The details matter of the network setup since macOS can have multiple networks assigned to one physical interface and software like VPN and admin control over networking can also block these transmissions.
(This solved my similar issue with Airdrop, not tested Sidecar yet.) I do not have VPN at router but on individual devices, so VPN broke my iCloud copy/paste and airdrop. It may be because they were not "sharing" the same wifi network anymore, as in, they had two different data tunnels, and the only solution I found was to deploy VPN at router or to turn off VPN. I dig Mullvad VPN Mac app preferences, and found that there is an option to enable "Local network sharing" that allows local network access to connected devices. I turned it on and voila, I had my airdrop back. I believe that major VPN providers' Mac app has this function, and if you toggle this function, you can get your problem solved. ps.: I strictly use Wireguard protocol, not OpenVPN. Not sure if it has anything to do with it, just saying...
60,340,394
**I'm learning reactjs I started with installing nodejs and then ran these commands inside my project folder "React"** ``` npx create-react-app hello-world cd hello-world npm start ``` **but then instead of going to the browser i receive error:** > > npm ERR! missing script: start > > > npm ERR! A complete log of this run can be found in: npm ERR! > > C:\Users\abc\AppData\Roaming\npm-cache\_logs\2020-02-21T13\_34\_26\_640Z-debug.log > > > **PACKAGE.JSON CODE:** ``` { "name": "hello-world", "version": "0.1.0", "private": true, "dependencies": { "react": "^16.12.0", "react-dom": "^16.12.0", "react-scripts": "3.4.0" } } ``` Help me solve this error i dont want it to demotivate me from learning React
2020/02/21
[ "https://Stackoverflow.com/questions/60340394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
npm scripts are missing inside your `package.json` file > > npm ERR! missing script: start > > > Edit your `package.json` as follows: ``` { "name": "hello-world", "version": "0.1.0", "private": true, "scripts": { "start": "react-scripts start", "build": "react-scripts build" }, "dependencies": { "react": "^16.12.0", "react-dom": "^16.12.0", "react-scripts": "3.4.0" } } ```
I was also facing almost same type of problem. But then tried `yarn create react-app my-app` in power shell with admin privilege which seemed to do the trick. > > Also you’ll need to have Node >= 8.10, yarn >= 0.25+ on your machine > as the official doc suggests. > > >
48,006,138
I am trying to sort several datasets in SAS using a loop within a macro, using a list of numbers, some of which have leading zeros, within dataset names (eg., in the example code, a list of `01,02`), and this code will also guide some other loops I would like to build. I used the SAS guidance on looping through a nonsequential list of values with a macro DO loop code as a starting point from here: <http://support.sas.com/kb/26/155.html>. ``` data dir1201; input compid directorid X; format ; datalines; 01 12 11 02 15 5 ; run; data dir1202; input compid directorid X; format ; datalines; 01 12 1 03 18 8 ; run; %macro loops1(values); /* Count the number of values in the string */ %let count=%sysfunc(countw(&values)); /* Loop through the total number of values */ %do i = 1 %to &count; %let value=%qscan(&values,&i,%str(,)); proc sort data=dir12&value out=dir12sorted&value nodupkey; by directorid compid; run; %end; %mend; options mprint mlogic; %loops1(%str(01,02)) ``` I assume `str` is needed for nonsequential lists, but that is also useful when I want to retain leading zeros; I see the macro variable seems to incorporate the 01 or 02 in the log, but then I receive the error 22 and 200 right afterward. Here is a snippet of the log error using this example code: ``` 339 %macro loops1(values); 340 /* Count the number of values in the string */ 341 %let count=%sysfunc(countw(&values)); 342 /* Loop through the total number of values */ 343 %do i = 1 %to &count; 344 %let value=%qscan(&values,&i,%str(,)); 345 proc sort data=dir12&value out=dir12sorted&value nodupkey; 346 by directorid compid; 347 run; 348 %end; 349 %mend; 350 options mprint mlogic; 351 %loops1(%str(01,02)) MLOGIC(LOOPS1): Beginning execution. MLOGIC(LOOPS1): Parameter VALUES has value 0102 MLOGIC(LOOPS1): %LET (variable name is COUNT) MLOGIC(LOOPS1): %DO loop beginning; index variable I; start value is 1; stop value is 2; by value is 1. MLOGIC(LOOPS1): %LET (variable name is VALUE) NOTE: Line generated by the macro variable "VALUE". 1 dir1201 -- 22 -- 200 ERROR: File WORK.DIR12.DATA does not exist. ``` I don't understand why `dir1201` is showing, but then the error is referencing the dataset `work.dir12` (ignoring the `01`)
2017/12/28
[ "https://Stackoverflow.com/questions/48006138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3556010/" ]
The macro quoting is confusing the parser into thinking the macro quoting signals the start of a new token. You can either add `%unquote()` to remove the macro quoting. ``` proc sort data=%unquote(dir12&value) out=%unquote(dir12sorted&value) nodupkey; ``` Or just don't add the macro quoting to begin with. ``` %let value=%scan(&values,&i,%str(,)); ``` It will be much easier to use your macro if you design it to take space delimited values rather than comma delimited. Then there is no need to add macro quoting to the call either. ``` %macro loops1(values); %local i value ; %do i = 1 %to %sysfunc(countw(&values,%str( ))); %let value=%scan(&values,&i,%str( )); proc sort data=dir12&value out=dir12sorted&value nodupkey; by directorid compid; run; %end; %mend loops1; %loops1(values=01 02) ```
The macro declaration option `/PARMBUFF` is used to make the automatic macro variable `SYSPBUFF` available for scanning an arbitrary number of comma separated values passed as arguments. ``` %macro loops1/parmbuff; %local index token; %do index = 1 %to %length(&syspbuff); %let token=%scan(&syspbuff,&index); %if %Length(&token) = 0 %then %goto leave1; proc sort data=dir12&token out=dir12sorted&token nodupkey; by directorid compid; run; %end; %leave1: %mend; options mprint nomlogic; %loops1(01,02) ``` [SYSPBUFF](http://documentation.sas.com/?docsetId=mcrolref&docsetTarget=n0dwee153ed7b2n1wl471mgtczle.htm&docsetVersion=9.4&locale=en) [MACRO / PARMBUFF](http://documentation.sas.com/?docsetId=mcrolref&docsetTarget=p1nypovnwon4uyn159rst8pgzqrl.htm&docsetVersion=9.4&locale=en)
48,006,138
I am trying to sort several datasets in SAS using a loop within a macro, using a list of numbers, some of which have leading zeros, within dataset names (eg., in the example code, a list of `01,02`), and this code will also guide some other loops I would like to build. I used the SAS guidance on looping through a nonsequential list of values with a macro DO loop code as a starting point from here: <http://support.sas.com/kb/26/155.html>. ``` data dir1201; input compid directorid X; format ; datalines; 01 12 11 02 15 5 ; run; data dir1202; input compid directorid X; format ; datalines; 01 12 1 03 18 8 ; run; %macro loops1(values); /* Count the number of values in the string */ %let count=%sysfunc(countw(&values)); /* Loop through the total number of values */ %do i = 1 %to &count; %let value=%qscan(&values,&i,%str(,)); proc sort data=dir12&value out=dir12sorted&value nodupkey; by directorid compid; run; %end; %mend; options mprint mlogic; %loops1(%str(01,02)) ``` I assume `str` is needed for nonsequential lists, but that is also useful when I want to retain leading zeros; I see the macro variable seems to incorporate the 01 or 02 in the log, but then I receive the error 22 and 200 right afterward. Here is a snippet of the log error using this example code: ``` 339 %macro loops1(values); 340 /* Count the number of values in the string */ 341 %let count=%sysfunc(countw(&values)); 342 /* Loop through the total number of values */ 343 %do i = 1 %to &count; 344 %let value=%qscan(&values,&i,%str(,)); 345 proc sort data=dir12&value out=dir12sorted&value nodupkey; 346 by directorid compid; 347 run; 348 %end; 349 %mend; 350 options mprint mlogic; 351 %loops1(%str(01,02)) MLOGIC(LOOPS1): Beginning execution. MLOGIC(LOOPS1): Parameter VALUES has value 0102 MLOGIC(LOOPS1): %LET (variable name is COUNT) MLOGIC(LOOPS1): %DO loop beginning; index variable I; start value is 1; stop value is 2; by value is 1. MLOGIC(LOOPS1): %LET (variable name is VALUE) NOTE: Line generated by the macro variable "VALUE". 1 dir1201 -- 22 -- 200 ERROR: File WORK.DIR12.DATA does not exist. ``` I don't understand why `dir1201` is showing, but then the error is referencing the dataset `work.dir12` (ignoring the `01`)
2017/12/28
[ "https://Stackoverflow.com/questions/48006138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3556010/" ]
The macro quoting is confusing the parser into thinking the macro quoting signals the start of a new token. You can either add `%unquote()` to remove the macro quoting. ``` proc sort data=%unquote(dir12&value) out=%unquote(dir12sorted&value) nodupkey; ``` Or just don't add the macro quoting to begin with. ``` %let value=%scan(&values,&i,%str(,)); ``` It will be much easier to use your macro if you design it to take space delimited values rather than comma delimited. Then there is no need to add macro quoting to the call either. ``` %macro loops1(values); %local i value ; %do i = 1 %to %sysfunc(countw(&values,%str( ))); %let value=%scan(&values,&i,%str( )); proc sort data=dir12&value out=dir12sorted&value nodupkey; by directorid compid; run; %end; %mend loops1; %loops1(values=01 02) ```
Since you're looping over dates, I think something like this may be more helpful in the long run: ``` %macro date_loop(start, end); %let start=%sysfunc(inputn(&start, anydtdte9.)); %let end=%sysfunc(inputn(&end, anydtdte9.)); %let dif=%sysfunc(intck(month, &start, &end)); %do i=0 %to &dif; %let date=%sysfunc(intnx(month, &start, &i, b), yymmdd4.); %put &date; %end; %mend date_loop; %date_loop(01Jan2012, 01Jan2015); ``` This is a slightly modified version from the one in the SAS documentation (macro Appendix, example 11). <http://documentation.sas.com/?docsetId=mcrolref&docsetTarget=n01vuhy8h909xgn16p0x6rddpoj9.htm&docsetVersion=9.4&locale=en>
48,006,138
I am trying to sort several datasets in SAS using a loop within a macro, using a list of numbers, some of which have leading zeros, within dataset names (eg., in the example code, a list of `01,02`), and this code will also guide some other loops I would like to build. I used the SAS guidance on looping through a nonsequential list of values with a macro DO loop code as a starting point from here: <http://support.sas.com/kb/26/155.html>. ``` data dir1201; input compid directorid X; format ; datalines; 01 12 11 02 15 5 ; run; data dir1202; input compid directorid X; format ; datalines; 01 12 1 03 18 8 ; run; %macro loops1(values); /* Count the number of values in the string */ %let count=%sysfunc(countw(&values)); /* Loop through the total number of values */ %do i = 1 %to &count; %let value=%qscan(&values,&i,%str(,)); proc sort data=dir12&value out=dir12sorted&value nodupkey; by directorid compid; run; %end; %mend; options mprint mlogic; %loops1(%str(01,02)) ``` I assume `str` is needed for nonsequential lists, but that is also useful when I want to retain leading zeros; I see the macro variable seems to incorporate the 01 or 02 in the log, but then I receive the error 22 and 200 right afterward. Here is a snippet of the log error using this example code: ``` 339 %macro loops1(values); 340 /* Count the number of values in the string */ 341 %let count=%sysfunc(countw(&values)); 342 /* Loop through the total number of values */ 343 %do i = 1 %to &count; 344 %let value=%qscan(&values,&i,%str(,)); 345 proc sort data=dir12&value out=dir12sorted&value nodupkey; 346 by directorid compid; 347 run; 348 %end; 349 %mend; 350 options mprint mlogic; 351 %loops1(%str(01,02)) MLOGIC(LOOPS1): Beginning execution. MLOGIC(LOOPS1): Parameter VALUES has value 0102 MLOGIC(LOOPS1): %LET (variable name is COUNT) MLOGIC(LOOPS1): %DO loop beginning; index variable I; start value is 1; stop value is 2; by value is 1. MLOGIC(LOOPS1): %LET (variable name is VALUE) NOTE: Line generated by the macro variable "VALUE". 1 dir1201 -- 22 -- 200 ERROR: File WORK.DIR12.DATA does not exist. ``` I don't understand why `dir1201` is showing, but then the error is referencing the dataset `work.dir12` (ignoring the `01`)
2017/12/28
[ "https://Stackoverflow.com/questions/48006138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3556010/" ]
The macro declaration option `/PARMBUFF` is used to make the automatic macro variable `SYSPBUFF` available for scanning an arbitrary number of comma separated values passed as arguments. ``` %macro loops1/parmbuff; %local index token; %do index = 1 %to %length(&syspbuff); %let token=%scan(&syspbuff,&index); %if %Length(&token) = 0 %then %goto leave1; proc sort data=dir12&token out=dir12sorted&token nodupkey; by directorid compid; run; %end; %leave1: %mend; options mprint nomlogic; %loops1(01,02) ``` [SYSPBUFF](http://documentation.sas.com/?docsetId=mcrolref&docsetTarget=n0dwee153ed7b2n1wl471mgtczle.htm&docsetVersion=9.4&locale=en) [MACRO / PARMBUFF](http://documentation.sas.com/?docsetId=mcrolref&docsetTarget=p1nypovnwon4uyn159rst8pgzqrl.htm&docsetVersion=9.4&locale=en)
Since you're looping over dates, I think something like this may be more helpful in the long run: ``` %macro date_loop(start, end); %let start=%sysfunc(inputn(&start, anydtdte9.)); %let end=%sysfunc(inputn(&end, anydtdte9.)); %let dif=%sysfunc(intck(month, &start, &end)); %do i=0 %to &dif; %let date=%sysfunc(intnx(month, &start, &i, b), yymmdd4.); %put &date; %end; %mend date_loop; %date_loop(01Jan2012, 01Jan2015); ``` This is a slightly modified version from the one in the SAS documentation (macro Appendix, example 11). <http://documentation.sas.com/?docsetId=mcrolref&docsetTarget=n01vuhy8h909xgn16p0x6rddpoj9.htm&docsetVersion=9.4&locale=en>
10,467,473
I was doing some OpenGL programming in C++. This is part of my code: ``` #include <time.h> #include <windows.h> #include <gl/gl.h> #include <gl/glu.h> #include <gl/glut.h> <<< Error here "Cannot open source file gl/glut.h" ``` How can I fix this? EDIT: I am using Microsoft Visual C++ Express Edition. Sorry forgot to mention it
2012/05/06
[ "https://Stackoverflow.com/questions/10467473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1369403/" ]
You probably haven't installed GLUT: 1. Install GLUT If you do not have GLUT installed on your machine you can download it from: <http://www.xmission.com/~nate/glut/glut-3.7.6-bin.zip> (or whatever version) GLUT Libraries and header files are • glut32.lib • glut.h Source: <http://cacs.usc.edu/education/cs596/OGL_Setup.pdf> **EDIT:** The quickest way is to download the latest header, and compiled DLLs for it, place it in your system32 folder or reference it in your project. Version 3.7 (latest as of this post) is here: <http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip> ``` Folder references: glut.h: 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\GL\' glut32.lib: 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\' glut32.dll: 'C:\Windows\System32\' For 64-bit machines, you will want to do this. glut32.dll: 'C:\Windows\SysWOW64\' Same pattern applies to freeglut and GLEW files with the header files in the GL folder, lib in the lib folder, and dll in the System32 (and SysWOW64) folder. 1. Under Visual C++, select Empty Project. 2. Go to Project -> Properties. Select Linker -> Input then add the following to the Additional Dependencies field: opengl32.lib glu32.lib glut32.lib ``` [Reprinted from here](http://visualambition.wordpress.com/2010/08/12/glut-and-visual-studio-2010/)
Here you can find every thing you need: <http://web.eecs.umich.edu/~sugih/courses/eecs487/glut-howto/#win>
10,467,473
I was doing some OpenGL programming in C++. This is part of my code: ``` #include <time.h> #include <windows.h> #include <gl/gl.h> #include <gl/glu.h> #include <gl/glut.h> <<< Error here "Cannot open source file gl/glut.h" ``` How can I fix this? EDIT: I am using Microsoft Visual C++ Express Edition. Sorry forgot to mention it
2012/05/06
[ "https://Stackoverflow.com/questions/10467473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1369403/" ]
You probably haven't installed GLUT: 1. Install GLUT If you do not have GLUT installed on your machine you can download it from: <http://www.xmission.com/~nate/glut/glut-3.7.6-bin.zip> (or whatever version) GLUT Libraries and header files are • glut32.lib • glut.h Source: <http://cacs.usc.edu/education/cs596/OGL_Setup.pdf> **EDIT:** The quickest way is to download the latest header, and compiled DLLs for it, place it in your system32 folder or reference it in your project. Version 3.7 (latest as of this post) is here: <http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip> ``` Folder references: glut.h: 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\GL\' glut32.lib: 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\' glut32.dll: 'C:\Windows\System32\' For 64-bit machines, you will want to do this. glut32.dll: 'C:\Windows\SysWOW64\' Same pattern applies to freeglut and GLEW files with the header files in the GL folder, lib in the lib folder, and dll in the System32 (and SysWOW64) folder. 1. Under Visual C++, select Empty Project. 2. Go to Project -> Properties. Select Linker -> Input then add the following to the Additional Dependencies field: opengl32.lib glu32.lib glut32.lib ``` [Reprinted from here](http://visualambition.wordpress.com/2010/08/12/glut-and-visual-studio-2010/)
If you are using Visual Studio Community 2015 and trying to Install GLUT you should place the header file `glut.h` in `C:\Program Files (x86)\Windows Kits\8.1\Include\um\gl`
10,467,473
I was doing some OpenGL programming in C++. This is part of my code: ``` #include <time.h> #include <windows.h> #include <gl/gl.h> #include <gl/glu.h> #include <gl/glut.h> <<< Error here "Cannot open source file gl/glut.h" ``` How can I fix this? EDIT: I am using Microsoft Visual C++ Express Edition. Sorry forgot to mention it
2012/05/06
[ "https://Stackoverflow.com/questions/10467473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1369403/" ]
You probably haven't installed GLUT: 1. Install GLUT If you do not have GLUT installed on your machine you can download it from: <http://www.xmission.com/~nate/glut/glut-3.7.6-bin.zip> (or whatever version) GLUT Libraries and header files are • glut32.lib • glut.h Source: <http://cacs.usc.edu/education/cs596/OGL_Setup.pdf> **EDIT:** The quickest way is to download the latest header, and compiled DLLs for it, place it in your system32 folder or reference it in your project. Version 3.7 (latest as of this post) is here: <http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip> ``` Folder references: glut.h: 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\GL\' glut32.lib: 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\' glut32.dll: 'C:\Windows\System32\' For 64-bit machines, you will want to do this. glut32.dll: 'C:\Windows\SysWOW64\' Same pattern applies to freeglut and GLEW files with the header files in the GL folder, lib in the lib folder, and dll in the System32 (and SysWOW64) folder. 1. Under Visual C++, select Empty Project. 2. Go to Project -> Properties. Select Linker -> Input then add the following to the Additional Dependencies field: opengl32.lib glu32.lib glut32.lib ``` [Reprinted from here](http://visualambition.wordpress.com/2010/08/12/glut-and-visual-studio-2010/)
Try to change `#include <gl/glut.h>` to `#include "gl/glut.h"` in Visual Studio 2013.
10,467,473
I was doing some OpenGL programming in C++. This is part of my code: ``` #include <time.h> #include <windows.h> #include <gl/gl.h> #include <gl/glu.h> #include <gl/glut.h> <<< Error here "Cannot open source file gl/glut.h" ``` How can I fix this? EDIT: I am using Microsoft Visual C++ Express Edition. Sorry forgot to mention it
2012/05/06
[ "https://Stackoverflow.com/questions/10467473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1369403/" ]
You probably haven't installed GLUT: 1. Install GLUT If you do not have GLUT installed on your machine you can download it from: <http://www.xmission.com/~nate/glut/glut-3.7.6-bin.zip> (or whatever version) GLUT Libraries and header files are • glut32.lib • glut.h Source: <http://cacs.usc.edu/education/cs596/OGL_Setup.pdf> **EDIT:** The quickest way is to download the latest header, and compiled DLLs for it, place it in your system32 folder or reference it in your project. Version 3.7 (latest as of this post) is here: <http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip> ``` Folder references: glut.h: 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\GL\' glut32.lib: 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\' glut32.dll: 'C:\Windows\System32\' For 64-bit machines, you will want to do this. glut32.dll: 'C:\Windows\SysWOW64\' Same pattern applies to freeglut and GLEW files with the header files in the GL folder, lib in the lib folder, and dll in the System32 (and SysWOW64) folder. 1. Under Visual C++, select Empty Project. 2. Go to Project -> Properties. Select Linker -> Input then add the following to the Additional Dependencies field: opengl32.lib glu32.lib glut32.lib ``` [Reprinted from here](http://visualambition.wordpress.com/2010/08/12/glut-and-visual-studio-2010/)
Visual Studio Community 2017 ============================ Go here : `C:\Program Files (x86)\Windows Kits\10` and do whatever you were supposed to go in the given directory for **VS 13**. in the lib folder, you will find some versions, I copied the **32-bit glut.lib** files in **amd** and **x86** and **64-bit glut.lib** in **arm64** and **x64** directories in `um` folder for every version that I could find. That worked for me. EDIT : I tried this in windows 10, maybe you need to go to `C:\Program Files (x86)\Windows Kits\8.1` folder for **windows 8/8.1**.
10,467,473
I was doing some OpenGL programming in C++. This is part of my code: ``` #include <time.h> #include <windows.h> #include <gl/gl.h> #include <gl/glu.h> #include <gl/glut.h> <<< Error here "Cannot open source file gl/glut.h" ``` How can I fix this? EDIT: I am using Microsoft Visual C++ Express Edition. Sorry forgot to mention it
2012/05/06
[ "https://Stackoverflow.com/questions/10467473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1369403/" ]
If you are using Visual Studio Community 2015 and trying to Install GLUT you should place the header file `glut.h` in `C:\Program Files (x86)\Windows Kits\8.1\Include\um\gl`
Here you can find every thing you need: <http://web.eecs.umich.edu/~sugih/courses/eecs487/glut-howto/#win>
10,467,473
I was doing some OpenGL programming in C++. This is part of my code: ``` #include <time.h> #include <windows.h> #include <gl/gl.h> #include <gl/glu.h> #include <gl/glut.h> <<< Error here "Cannot open source file gl/glut.h" ``` How can I fix this? EDIT: I am using Microsoft Visual C++ Express Edition. Sorry forgot to mention it
2012/05/06
[ "https://Stackoverflow.com/questions/10467473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1369403/" ]
Visual Studio Community 2017 ============================ Go here : `C:\Program Files (x86)\Windows Kits\10` and do whatever you were supposed to go in the given directory for **VS 13**. in the lib folder, you will find some versions, I copied the **32-bit glut.lib** files in **amd** and **x86** and **64-bit glut.lib** in **arm64** and **x64** directories in `um` folder for every version that I could find. That worked for me. EDIT : I tried this in windows 10, maybe you need to go to `C:\Program Files (x86)\Windows Kits\8.1` folder for **windows 8/8.1**.
Here you can find every thing you need: <http://web.eecs.umich.edu/~sugih/courses/eecs487/glut-howto/#win>
10,467,473
I was doing some OpenGL programming in C++. This is part of my code: ``` #include <time.h> #include <windows.h> #include <gl/gl.h> #include <gl/glu.h> #include <gl/glut.h> <<< Error here "Cannot open source file gl/glut.h" ``` How can I fix this? EDIT: I am using Microsoft Visual C++ Express Edition. Sorry forgot to mention it
2012/05/06
[ "https://Stackoverflow.com/questions/10467473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1369403/" ]
If you are using Visual Studio Community 2015 and trying to Install GLUT you should place the header file `glut.h` in `C:\Program Files (x86)\Windows Kits\8.1\Include\um\gl`
Try to change `#include <gl/glut.h>` to `#include "gl/glut.h"` in Visual Studio 2013.
10,467,473
I was doing some OpenGL programming in C++. This is part of my code: ``` #include <time.h> #include <windows.h> #include <gl/gl.h> #include <gl/glu.h> #include <gl/glut.h> <<< Error here "Cannot open source file gl/glut.h" ``` How can I fix this? EDIT: I am using Microsoft Visual C++ Express Edition. Sorry forgot to mention it
2012/05/06
[ "https://Stackoverflow.com/questions/10467473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1369403/" ]
If you are using Visual Studio Community 2015 and trying to Install GLUT you should place the header file `glut.h` in `C:\Program Files (x86)\Windows Kits\8.1\Include\um\gl`
Visual Studio Community 2017 ============================ Go here : `C:\Program Files (x86)\Windows Kits\10` and do whatever you were supposed to go in the given directory for **VS 13**. in the lib folder, you will find some versions, I copied the **32-bit glut.lib** files in **amd** and **x86** and **64-bit glut.lib** in **arm64** and **x64** directories in `um` folder for every version that I could find. That worked for me. EDIT : I tried this in windows 10, maybe you need to go to `C:\Program Files (x86)\Windows Kits\8.1` folder for **windows 8/8.1**.
10,467,473
I was doing some OpenGL programming in C++. This is part of my code: ``` #include <time.h> #include <windows.h> #include <gl/gl.h> #include <gl/glu.h> #include <gl/glut.h> <<< Error here "Cannot open source file gl/glut.h" ``` How can I fix this? EDIT: I am using Microsoft Visual C++ Express Edition. Sorry forgot to mention it
2012/05/06
[ "https://Stackoverflow.com/questions/10467473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1369403/" ]
Visual Studio Community 2017 ============================ Go here : `C:\Program Files (x86)\Windows Kits\10` and do whatever you were supposed to go in the given directory for **VS 13**. in the lib folder, you will find some versions, I copied the **32-bit glut.lib** files in **amd** and **x86** and **64-bit glut.lib** in **arm64** and **x64** directories in `um` folder for every version that I could find. That worked for me. EDIT : I tried this in windows 10, maybe you need to go to `C:\Program Files (x86)\Windows Kits\8.1` folder for **windows 8/8.1**.
Try to change `#include <gl/glut.h>` to `#include "gl/glut.h"` in Visual Studio 2013.
37,243
Following situation: * Application is only accessible via HTTPS/SPDY * nginx is sending the SSL session ID to the upstream server * Upon session start I'd like to use the first 128 characters of that string * In PHP: `$csrf_token = substr($_SERVER["SSL_SESSION_ID"], 0, 128);` * The CSRF token is stored on the server in the user’s session and a new token will be generated if a new session is generated My question(s): * Is this approach secure (enough)? + This question is regarding the usage of the SSL session ID and not related to the usage of session based CSRF tokens! * Would it be possible to use less characters (e.g. 32)? * Should I add some sort of secret salt to it? * Anything else that might be a problem with this?
2013/06/10
[ "https://security.stackexchange.com/questions/37243", "https://security.stackexchange.com", "https://security.stackexchange.com/users/27000/" ]
You can do this but the moment your app grows larger and needs ssl offloading it will break. Also take care about the length as you are exposing a part of the ssl session id which is responsible for protecting your CIA. If you would take a too large part of the Id or all of it and an attacker would be able to get it through xss, it could also break your ssl session. Please don't be a dave.
Re-purposing crypto datapoints for other purposes is one of the capital sins of data security. There is no logical reason to do what you are suggesting. And whether or not a specific vulnerability for what you are suggesting is immediately available, it's still a bad idea. Just use a random value, which is the known, vetted, accepted approach. Otherwise you stray into [Dave](https://security.stackexchange.com/q/25585/2264) territory.
28,657
The common wisdom is to store all of your vegetable trimmings (cleaned) in the freezer, and then chuck everything into the stock pot when it's time to make stock. For a meat stock, it's common to throw the bones, giblets, neck and any other left-over bits into the stock pot as well. There must be some things which are undesirable or ill-advised for stock. What should one avoid as an ingredient for making stock, and why?
2012/11/26
[ "https://cooking.stackexchange.com/questions/28657", "https://cooking.stackexchange.com", "https://cooking.stackexchange.com/users/1685/" ]
You want to avoid salt, until the time of use--especially after reduction. Similarly, unless you know the use for the stock in advance you might want to avoid strong herbs like sage or lemongrass. Tomatoes probably are not suitable in my opinion for most meat stocks. And no fingers. Definitely avoid the fingers in the stock. It is really hot, and can hurt!
The only avoidance I've ever heard is staying away from the Liver in your stock recipes, at least until the last few minutes of cooking. This can apparently make your stock bitter. Other than that, I'd say experiment with anything you want. The worst that can happen is you get a funny taste so long as you're cooking everything above a temperature that will kill any bacteria.
28,657
The common wisdom is to store all of your vegetable trimmings (cleaned) in the freezer, and then chuck everything into the stock pot when it's time to make stock. For a meat stock, it's common to throw the bones, giblets, neck and any other left-over bits into the stock pot as well. There must be some things which are undesirable or ill-advised for stock. What should one avoid as an ingredient for making stock, and why?
2012/11/26
[ "https://cooking.stackexchange.com/questions/28657", "https://cooking.stackexchange.com", "https://cooking.stackexchange.com/users/1685/" ]
There isn't anything that is necessarily "bad" or should always be avoided in stock, but some ingredients have qualities you won't always want. * Dark greens (spinach, kale, etc) can make a stock bitter and of course greenish in color. Cabbage also can impart a overwhelming bitterness. * Potatoes can cloud a stock from their starchiness, so they are not good when you want clear stock for something like a soup or consomme. * Tomatoes may overpower flavors in a light stock, but are a critical component in most dark stocks (browning tomato paste improves the color) * Onion skins add a deeper flavor, but yellow or red skins can change the color of a light colored stock dramatically. * Skin and extra fat from the meat used is sometimes avoided to reduce the amount of skimming required later on (I personally don't skim, the extra fat doesn't bother me) * The bones of very oily fish (mackerel, salmon, and trout for example) are usually avoided because they can make a stock too strong in specific flavors to work in any other dish. Oily fish stocks also tend to have an unpleasant odor.
The only avoidance I've ever heard is staying away from the Liver in your stock recipes, at least until the last few minutes of cooking. This can apparently make your stock bitter. Other than that, I'd say experiment with anything you want. The worst that can happen is you get a funny taste so long as you're cooking everything above a temperature that will kill any bacteria.
28,657
The common wisdom is to store all of your vegetable trimmings (cleaned) in the freezer, and then chuck everything into the stock pot when it's time to make stock. For a meat stock, it's common to throw the bones, giblets, neck and any other left-over bits into the stock pot as well. There must be some things which are undesirable or ill-advised for stock. What should one avoid as an ingredient for making stock, and why?
2012/11/26
[ "https://cooking.stackexchange.com/questions/28657", "https://cooking.stackexchange.com", "https://cooking.stackexchange.com/users/1685/" ]
There isn't anything that is necessarily "bad" or should always be avoided in stock, but some ingredients have qualities you won't always want. * Dark greens (spinach, kale, etc) can make a stock bitter and of course greenish in color. Cabbage also can impart a overwhelming bitterness. * Potatoes can cloud a stock from their starchiness, so they are not good when you want clear stock for something like a soup or consomme. * Tomatoes may overpower flavors in a light stock, but are a critical component in most dark stocks (browning tomato paste improves the color) * Onion skins add a deeper flavor, but yellow or red skins can change the color of a light colored stock dramatically. * Skin and extra fat from the meat used is sometimes avoided to reduce the amount of skimming required later on (I personally don't skim, the extra fat doesn't bother me) * The bones of very oily fish (mackerel, salmon, and trout for example) are usually avoided because they can make a stock too strong in specific flavors to work in any other dish. Oily fish stocks also tend to have an unpleasant odor.
You want to avoid salt, until the time of use--especially after reduction. Similarly, unless you know the use for the stock in advance you might want to avoid strong herbs like sage or lemongrass. Tomatoes probably are not suitable in my opinion for most meat stocks. And no fingers. Definitely avoid the fingers in the stock. It is really hot, and can hurt!
14,877,390
I have a user table that stores data about the user. Let's say one of those things I need to store is about all the widget manufacturers that the user uses. I need to get data about each of those manufacturers (from the manufacturers table) to present to the user. In the user table should I store the users manufacturers as multiple values in a column like below and then split it out to create my query? ### user ``` id | username | password | widget_man_id | etc 1 | bob | **** | 1,4,3 | some data 2 | don | ***** | 2,3,1 | some more data . . ``` Or should I create a new table that holds all users information about the manufacturers they use? Like so... ### user\_man ``` id | manufacturer | user | order 1 | 1 | 1 | 1 2 | 4 | 1 | 2 3 | 3 | 1 | 3 4 | 2 | 2 | 1 5 | 3 | 2 | 2 6 | 1 | 2 | 3 . . ``` and then perform a query like this for a given user... ``` select manufacturer, order from user_man where user=1 ``` \*\*ALSO, how could I sort the results in descending order based on the *order* field?
2013/02/14
[ "https://Stackoverflow.com/questions/14877390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/631642/" ]
Do not put multiple values into a single column and then split them out. This is much slower for querying as each of the values cannot be indexed. You are much better off having a table with a separate record for each one. You can index this table and your queries will run much faster.
Separate table is the only the way to go. To order your results in descending order just add `DESC` keyword ``` SELECT manufacturer FROM user_man WHERE user=1 ORDER BY `order` DESC ```
14,877,390
I have a user table that stores data about the user. Let's say one of those things I need to store is about all the widget manufacturers that the user uses. I need to get data about each of those manufacturers (from the manufacturers table) to present to the user. In the user table should I store the users manufacturers as multiple values in a column like below and then split it out to create my query? ### user ``` id | username | password | widget_man_id | etc 1 | bob | **** | 1,4,3 | some data 2 | don | ***** | 2,3,1 | some more data . . ``` Or should I create a new table that holds all users information about the manufacturers they use? Like so... ### user\_man ``` id | manufacturer | user | order 1 | 1 | 1 | 1 2 | 4 | 1 | 2 3 | 3 | 1 | 3 4 | 2 | 2 | 1 5 | 3 | 2 | 2 6 | 1 | 2 | 3 . . ``` and then perform a query like this for a given user... ``` select manufacturer, order from user_man where user=1 ``` \*\*ALSO, how could I sort the results in descending order based on the *order* field?
2013/02/14
[ "https://Stackoverflow.com/questions/14877390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/631642/" ]
Do not put multiple values into a single column and then split them out. This is much slower for querying as each of the values cannot be indexed. You are much better off having a table with a separate record for each one. You can index this table and your queries will run much faster.
The common approach would be to have a table user (like yours but without the widget\_man\_id): **user** ``` id | username | password | etc 1 | bob | **** | some data 2 | don | ***** | some more data ``` A manufacturer table: **manufacturer** ``` id | name | etc 1 | man1 | some data 2 | man2 | some more data ``` And a many-to-many relationship table (like your example): **user\_man** ``` id | manufacturer | user | order 1 | 1 | 1 | 1 2 | 4 | 1 | 2 3 | 3 | 1 | 3 4 | 2 | 2 | 1 5 | 3 | 2 | 2 6 | 1 | 2 | 3 ```
14,877,390
I have a user table that stores data about the user. Let's say one of those things I need to store is about all the widget manufacturers that the user uses. I need to get data about each of those manufacturers (from the manufacturers table) to present to the user. In the user table should I store the users manufacturers as multiple values in a column like below and then split it out to create my query? ### user ``` id | username | password | widget_man_id | etc 1 | bob | **** | 1,4,3 | some data 2 | don | ***** | 2,3,1 | some more data . . ``` Or should I create a new table that holds all users information about the manufacturers they use? Like so... ### user\_man ``` id | manufacturer | user | order 1 | 1 | 1 | 1 2 | 4 | 1 | 2 3 | 3 | 1 | 3 4 | 2 | 2 | 1 5 | 3 | 2 | 2 6 | 1 | 2 | 3 . . ``` and then perform a query like this for a given user... ``` select manufacturer, order from user_man where user=1 ``` \*\*ALSO, how could I sort the results in descending order based on the *order* field?
2013/02/14
[ "https://Stackoverflow.com/questions/14877390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/631642/" ]
What you are trying to implement here is a [Many-to-Many](http://en.wikipedia.org/wiki/Many-to-many_%28data_model%29) relationship between your `Users` and `Manufacturers`. The only good way to do this in most RDBMS, such as MySQL, is through a [Junction Table](http://en.wikipedia.org/wiki/Junction_table). Although it does not reflect a particular object of your model, it will help modeling the relationships between the two others. Create a third table, and do not forget to create Foreign Keys so you can prevent errors while updating or inserting records, and use some interesting features such as cascade deletion.
Separate table is the only the way to go. To order your results in descending order just add `DESC` keyword ``` SELECT manufacturer FROM user_man WHERE user=1 ORDER BY `order` DESC ```
14,877,390
I have a user table that stores data about the user. Let's say one of those things I need to store is about all the widget manufacturers that the user uses. I need to get data about each of those manufacturers (from the manufacturers table) to present to the user. In the user table should I store the users manufacturers as multiple values in a column like below and then split it out to create my query? ### user ``` id | username | password | widget_man_id | etc 1 | bob | **** | 1,4,3 | some data 2 | don | ***** | 2,3,1 | some more data . . ``` Or should I create a new table that holds all users information about the manufacturers they use? Like so... ### user\_man ``` id | manufacturer | user | order 1 | 1 | 1 | 1 2 | 4 | 1 | 2 3 | 3 | 1 | 3 4 | 2 | 2 | 1 5 | 3 | 2 | 2 6 | 1 | 2 | 3 . . ``` and then perform a query like this for a given user... ``` select manufacturer, order from user_man where user=1 ``` \*\*ALSO, how could I sort the results in descending order based on the *order* field?
2013/02/14
[ "https://Stackoverflow.com/questions/14877390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/631642/" ]
What you are trying to implement here is a [Many-to-Many](http://en.wikipedia.org/wiki/Many-to-many_%28data_model%29) relationship between your `Users` and `Manufacturers`. The only good way to do this in most RDBMS, such as MySQL, is through a [Junction Table](http://en.wikipedia.org/wiki/Junction_table). Although it does not reflect a particular object of your model, it will help modeling the relationships between the two others. Create a third table, and do not forget to create Foreign Keys so you can prevent errors while updating or inserting records, and use some interesting features such as cascade deletion.
The common approach would be to have a table user (like yours but without the widget\_man\_id): **user** ``` id | username | password | etc 1 | bob | **** | some data 2 | don | ***** | some more data ``` A manufacturer table: **manufacturer** ``` id | name | etc 1 | man1 | some data 2 | man2 | some more data ``` And a many-to-many relationship table (like your example): **user\_man** ``` id | manufacturer | user | order 1 | 1 | 1 | 1 2 | 4 | 1 | 2 3 | 3 | 1 | 3 4 | 2 | 2 | 1 5 | 3 | 2 | 2 6 | 1 | 2 | 3 ```
21,477,011
I'm totally new to Java language. It is difficult for me to efficiently manipulate strings although I've learned many things about the String class and fIle I/O. After writing some codes, I found that the split method in the String class is not a panacea. I'd like to parse this text file like ``` 1 (201, <202,203>), (203, <204,208>), (204, <>) 2 (201, <202,203>), (204, <>) 3 (201, <202,203>), (203, <204,208>) 4 (201, <202,203>), (202, <>), (208, <>) 5 (202, <>), (208, <>) 6 (202, <>) ``` The first column is characters in this text file, not line number. After reading the first line of it, I'd like to receive 1, 201, 202, 203, 203, 204, 208, and 204, as int value sequentially. What String methods it would be a good idea to use? Thank you in advance. --- Code (you may not need.) ``` import java.io.*; public class IF_Parser { private FileInputStream fstream; private DataInputStream in; private BufferedReader br; public IF_Parser(String filename) throws IOException { try { fstream = new FileInputStream(filename); // Get the object of DataInputStream in = new DataInputStream(fstream); br = new BufferedReader(new InputStreamReader(in)); } catch (Exception e) { System.err.println("Error: " + e.getMessage()); } } public void Parse_given_file() throws IOException { try { String strLine; int line = 1; while ((strLine = br.readLine()) != null) { System.out.println("Line " + line); int i; String[] splits = strLine.split("\t"); // splits[0] : int value, splits[1] : string representation of list of postings. String[] postings = splits[1].split(" "); line++; } } catch (Exception e) { System.err.println("Error: " + e.getMessage()); } } } ```
2014/01/31
[ "https://Stackoverflow.com/questions/21477011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1889192/" ]
Since you want to extract the *numeric* values of each lines, I would recommend you take a look at the [`Pattern`](http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html) class. A simple piece of code like the one below: ``` String str = "1 (201, <202,203>), (203, <204,208>), (204, <>)"; Pattern p = Pattern.compile("(\\d+)"); Matcher m = p.matcher(str); while(m.find()) { System.out.println(m.group(1)); } ``` Will yield all the numeric values in the line: ``` 1 201 202 203 203 204 208 204 ``` Essentially that pattern will look for one or more repetitions of numbers. When it finds them, it will put them in groups which it then later accesses.
``` 1 (201, <202,203>), (203, <204,208>), (204, <>) ``` Remove all of the `()` and `<>`. Then use `split()` to get the individual tokens, and finally parse them as `integers`. **Example** ``` String input = scanner.readLine(); // your input. input = input.replaceAll("\\(\\)", ""); input = input.replaceAll("<>", ""); String[] tokens = input.split(","); int[] values = new int[tokens.length]; for(int x = 0; x < tokens.length; x++) { values[x] = Integer.parseInt(tokens[x]); } ```
21,477,011
I'm totally new to Java language. It is difficult for me to efficiently manipulate strings although I've learned many things about the String class and fIle I/O. After writing some codes, I found that the split method in the String class is not a panacea. I'd like to parse this text file like ``` 1 (201, <202,203>), (203, <204,208>), (204, <>) 2 (201, <202,203>), (204, <>) 3 (201, <202,203>), (203, <204,208>) 4 (201, <202,203>), (202, <>), (208, <>) 5 (202, <>), (208, <>) 6 (202, <>) ``` The first column is characters in this text file, not line number. After reading the first line of it, I'd like to receive 1, 201, 202, 203, 203, 204, 208, and 204, as int value sequentially. What String methods it would be a good idea to use? Thank you in advance. --- Code (you may not need.) ``` import java.io.*; public class IF_Parser { private FileInputStream fstream; private DataInputStream in; private BufferedReader br; public IF_Parser(String filename) throws IOException { try { fstream = new FileInputStream(filename); // Get the object of DataInputStream in = new DataInputStream(fstream); br = new BufferedReader(new InputStreamReader(in)); } catch (Exception e) { System.err.println("Error: " + e.getMessage()); } } public void Parse_given_file() throws IOException { try { String strLine; int line = 1; while ((strLine = br.readLine()) != null) { System.out.println("Line " + line); int i; String[] splits = strLine.split("\t"); // splits[0] : int value, splits[1] : string representation of list of postings. String[] postings = splits[1].split(" "); line++; } } catch (Exception e) { System.err.println("Error: " + e.getMessage()); } } } ```
2014/01/31
[ "https://Stackoverflow.com/questions/21477011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1889192/" ]
You can use StringTokenizer class as well. Code is as simple as follows: import java.util.StringTokenizer; public class App { public static void main(String[] args) { ``` String str = "1 (201, <202,203>), (203, <204,208>), (204, <>)"; StringTokenizer st = new StringTokenizer( str, " ,()<>" ); while ( st.hasMoreElements() ) { System.out.println( st.nextElement() ); } } ``` } Output prints: 1 201 202 203 203 204 208 204
``` 1 (201, <202,203>), (203, <204,208>), (204, <>) ``` Remove all of the `()` and `<>`. Then use `split()` to get the individual tokens, and finally parse them as `integers`. **Example** ``` String input = scanner.readLine(); // your input. input = input.replaceAll("\\(\\)", ""); input = input.replaceAll("<>", ""); String[] tokens = input.split(","); int[] values = new int[tokens.length]; for(int x = 0; x < tokens.length; x++) { values[x] = Integer.parseInt(tokens[x]); } ```
21,477,011
I'm totally new to Java language. It is difficult for me to efficiently manipulate strings although I've learned many things about the String class and fIle I/O. After writing some codes, I found that the split method in the String class is not a panacea. I'd like to parse this text file like ``` 1 (201, <202,203>), (203, <204,208>), (204, <>) 2 (201, <202,203>), (204, <>) 3 (201, <202,203>), (203, <204,208>) 4 (201, <202,203>), (202, <>), (208, <>) 5 (202, <>), (208, <>) 6 (202, <>) ``` The first column is characters in this text file, not line number. After reading the first line of it, I'd like to receive 1, 201, 202, 203, 203, 204, 208, and 204, as int value sequentially. What String methods it would be a good idea to use? Thank you in advance. --- Code (you may not need.) ``` import java.io.*; public class IF_Parser { private FileInputStream fstream; private DataInputStream in; private BufferedReader br; public IF_Parser(String filename) throws IOException { try { fstream = new FileInputStream(filename); // Get the object of DataInputStream in = new DataInputStream(fstream); br = new BufferedReader(new InputStreamReader(in)); } catch (Exception e) { System.err.println("Error: " + e.getMessage()); } } public void Parse_given_file() throws IOException { try { String strLine; int line = 1; while ((strLine = br.readLine()) != null) { System.out.println("Line " + line); int i; String[] splits = strLine.split("\t"); // splits[0] : int value, splits[1] : string representation of list of postings. String[] postings = splits[1].split(" "); line++; } } catch (Exception e) { System.err.println("Error: " + e.getMessage()); } } } ```
2014/01/31
[ "https://Stackoverflow.com/questions/21477011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1889192/" ]
Since you want to extract the *numeric* values of each lines, I would recommend you take a look at the [`Pattern`](http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html) class. A simple piece of code like the one below: ``` String str = "1 (201, <202,203>), (203, <204,208>), (204, <>)"; Pattern p = Pattern.compile("(\\d+)"); Matcher m = p.matcher(str); while(m.find()) { System.out.println(m.group(1)); } ``` Will yield all the numeric values in the line: ``` 1 201 202 203 203 204 208 204 ``` Essentially that pattern will look for one or more repetitions of numbers. When it finds them, it will put them in groups which it then later accesses.
You can use StringTokenizer class as well. Code is as simple as follows: import java.util.StringTokenizer; public class App { public static void main(String[] args) { ``` String str = "1 (201, <202,203>), (203, <204,208>), (204, <>)"; StringTokenizer st = new StringTokenizer( str, " ,()<>" ); while ( st.hasMoreElements() ) { System.out.println( st.nextElement() ); } } ``` } Output prints: 1 201 202 203 203 204 208 204
5,745,243
Recently i had an interview in which the question was asked as "How would you be able to share the data between two installed apps or apk's?" I didn't have any answer for this question. Can anyone help me in determining an way to do so...
2011/04/21
[ "https://Stackoverflow.com/questions/5745243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/303155/" ]
If you want to share data between applications, make sure you sign with the same key: > > Code/data sharing through permissions – The Android system provides > signature-based permissions enforcement, so that an application can > expose functionality to another application that is signed with a > specified certificate. By signing multiple applications with the same > certificate and using signature-based permissions checks, your > applications can share code and data in a secure manner. > > > This is quoted from: [android developer page about signing](http://developer.android.com/tools/publishing/app-signing.html) If it's a small amount of data you could send it through an intent.
1. using implicit intent and startActivityForResult. 2. Using Content provider [eg of content Providor:](http://content%20providor%20example)
5,745,243
Recently i had an interview in which the question was asked as "How would you be able to share the data between two installed apps or apk's?" I didn't have any answer for this question. Can anyone help me in determining an way to do so...
2011/04/21
[ "https://Stackoverflow.com/questions/5745243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/303155/" ]
**Send data from Application 1 (for ex:Application 1 package name is "com.sharedpref1" ).** ``` SharedPreferences prefs = getSharedPreferences("demopref", Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putString("demostring", strShareValue); editor.commit(); ``` **Receive the data in Application 2( to get data from Shared Preferences in Application 1).** ``` try { con = createPackageContext("com.sharedpref1", 0);//first app package name is "com.sharedpref1" SharedPreferences pref = con.getSharedPreferences( "demopref", Context.MODE_PRIVATE); String your_data = pref.getString("demostring", "No Value"); } catch (NameNotFoundException e) { Log.e("Not data shared", e.toString()); } ``` **In both application manifest files add same shared user id & label,** ``` android:sharedUserId="any string" android:sharedUserLabel="@string/any_string" ``` both are same... and shared user label must from string.xml **like this example.** ``` <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.xxxx" android:versionCode="1" android:versionName="1.0" android:sharedUserId="any string" android:sharedUserLabel="@string/any_string"> ```
Content provider is the android component, which has to be used if one application wants to share its data with other application. Note: Files, SqliteDatabases, Sharedpreference files created by an application is private to only that application. Other application can't directly access it. If programmer exposes database by using content provider, then only that data is accessible to other applications. To communicate with content provider use content resolver.
5,745,243
Recently i had an interview in which the question was asked as "How would you be able to share the data between two installed apps or apk's?" I didn't have any answer for this question. Can anyone help me in determining an way to do so...
2011/04/21
[ "https://Stackoverflow.com/questions/5745243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/303155/" ]
**Send data from Application 1 (for ex:Application 1 package name is "com.sharedpref1" ).** ``` SharedPreferences prefs = getSharedPreferences("demopref", Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putString("demostring", strShareValue); editor.commit(); ``` **Receive the data in Application 2( to get data from Shared Preferences in Application 1).** ``` try { con = createPackageContext("com.sharedpref1", 0);//first app package name is "com.sharedpref1" SharedPreferences pref = con.getSharedPreferences( "demopref", Context.MODE_PRIVATE); String your_data = pref.getString("demostring", "No Value"); } catch (NameNotFoundException e) { Log.e("Not data shared", e.toString()); } ``` **In both application manifest files add same shared user id & label,** ``` android:sharedUserId="any string" android:sharedUserLabel="@string/any_string" ``` both are same... and shared user label must from string.xml **like this example.** ``` <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.xxxx" android:versionCode="1" android:versionName="1.0" android:sharedUserId="any string" android:sharedUserLabel="@string/any_string"> ```
If you want to share data between applications, make sure you sign with the same key: > > Code/data sharing through permissions – The Android system provides > signature-based permissions enforcement, so that an application can > expose functionality to another application that is signed with a > specified certificate. By signing multiple applications with the same > certificate and using signature-based permissions checks, your > applications can share code and data in a secure manner. > > > This is quoted from: [android developer page about signing](http://developer.android.com/tools/publishing/app-signing.html) If it's a small amount of data you could send it through an intent.
5,745,243
Recently i had an interview in which the question was asked as "How would you be able to share the data between two installed apps or apk's?" I didn't have any answer for this question. Can anyone help me in determining an way to do so...
2011/04/21
[ "https://Stackoverflow.com/questions/5745243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/303155/" ]
I suspect they were likely looking for Android specific methods such as the content provider answer. Other alternatives... Android Specific - Remote services General - TCP/IP connections General - Writing to a location on the SD card Care to hear more about a specific method? Also stealing this question for an interview today :)
My requirement was to send a simple string from one app to another and get a string back. Like "user id" from App1 to App2 and get "username" back to App1. I was able to achieve this using **implicit intent** and **startActivityForResult**. If anyone is looking for the full process I posted my answer here [How to send data between one application to other application in android?](https://stackoverflow.com/questions/38608496/how-to-send-data-between-one-application-to-other-application-in-android/56737554#56737554). App1 > MainActivity.java ``` //Need to register your intent filter in App2 in manifest file with same action. intent.setAction("com.example.sender.login"); // <packagename.login> intent.setType("text/plain"); startActivityForResult(intent, REQUEST_CODE); onActivityResult(...) { ... // Handle received data from App2 here } ``` I had two activity in App2 ie. MainActivity and LoginActivity. App2 > AndroidManifest.xml ``` <intent-filter> <!--The action has to be same as App1--> <action android:name="com.example.sender.login" /> ... </intent-filter> ``` App2 > LoginActivity.java ``` override fun onResume() { ... // Handle data from App1 here } fun onClickBack(view: View) { val intent = intent ... // Set data in bundle here for App1 setResult(Activity.RESULT_OK, intent) finish() } ```
5,745,243
Recently i had an interview in which the question was asked as "How would you be able to share the data between two installed apps or apk's?" I didn't have any answer for this question. Can anyone help me in determining an way to do so...
2011/04/21
[ "https://Stackoverflow.com/questions/5745243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/303155/" ]
[ContentProviders](http://developer.android.com/guide/topics/providers/content-providers.html) are a good approach to share data between applications.
My requirement was to send a simple string from one app to another and get a string back. Like "user id" from App1 to App2 and get "username" back to App1. I was able to achieve this using **implicit intent** and **startActivityForResult**. If anyone is looking for the full process I posted my answer here [How to send data between one application to other application in android?](https://stackoverflow.com/questions/38608496/how-to-send-data-between-one-application-to-other-application-in-android/56737554#56737554). App1 > MainActivity.java ``` //Need to register your intent filter in App2 in manifest file with same action. intent.setAction("com.example.sender.login"); // <packagename.login> intent.setType("text/plain"); startActivityForResult(intent, REQUEST_CODE); onActivityResult(...) { ... // Handle received data from App2 here } ``` I had two activity in App2 ie. MainActivity and LoginActivity. App2 > AndroidManifest.xml ``` <intent-filter> <!--The action has to be same as App1--> <action android:name="com.example.sender.login" /> ... </intent-filter> ``` App2 > LoginActivity.java ``` override fun onResume() { ... // Handle data from App1 here } fun onClickBack(view: View) { val intent = intent ... // Set data in bundle here for App1 setResult(Activity.RESULT_OK, intent) finish() } ```
5,745,243
Recently i had an interview in which the question was asked as "How would you be able to share the data between two installed apps or apk's?" I didn't have any answer for this question. Can anyone help me in determining an way to do so...
2011/04/21
[ "https://Stackoverflow.com/questions/5745243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/303155/" ]
I suspect they were likely looking for Android specific methods such as the content provider answer. Other alternatives... Android Specific - Remote services General - TCP/IP connections General - Writing to a location on the SD card Care to hear more about a specific method? Also stealing this question for an interview today :)
Content provider is the android component, which has to be used if one application wants to share its data with other application. Note: Files, SqliteDatabases, Sharedpreference files created by an application is private to only that application. Other application can't directly access it. If programmer exposes database by using content provider, then only that data is accessible to other applications. To communicate with content provider use content resolver.
5,745,243
Recently i had an interview in which the question was asked as "How would you be able to share the data between two installed apps or apk's?" I didn't have any answer for this question. Can anyone help me in determining an way to do so...
2011/04/21
[ "https://Stackoverflow.com/questions/5745243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/303155/" ]
[ContentProviders](http://developer.android.com/guide/topics/providers/content-providers.html) are a good approach to share data between applications.
**Send data from Application 1 (for ex:Application 1 package name is "com.sharedpref1" ).** ``` SharedPreferences prefs = getSharedPreferences("demopref", Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putString("demostring", strShareValue); editor.commit(); ``` **Receive the data in Application 2( to get data from Shared Preferences in Application 1).** ``` try { con = createPackageContext("com.sharedpref1", 0);//first app package name is "com.sharedpref1" SharedPreferences pref = con.getSharedPreferences( "demopref", Context.MODE_PRIVATE); String your_data = pref.getString("demostring", "No Value"); } catch (NameNotFoundException e) { Log.e("Not data shared", e.toString()); } ``` **In both application manifest files add same shared user id & label,** ``` android:sharedUserId="any string" android:sharedUserLabel="@string/any_string" ``` both are same... and shared user label must from string.xml **like this example.** ``` <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.xxxx" android:versionCode="1" android:versionName="1.0" android:sharedUserId="any string" android:sharedUserLabel="@string/any_string"> ```
5,745,243
Recently i had an interview in which the question was asked as "How would you be able to share the data between two installed apps or apk's?" I didn't have any answer for this question. Can anyone help me in determining an way to do so...
2011/04/21
[ "https://Stackoverflow.com/questions/5745243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/303155/" ]
**Send data from Application 1 (for ex:Application 1 package name is "com.sharedpref1" ).** ``` SharedPreferences prefs = getSharedPreferences("demopref", Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putString("demostring", strShareValue); editor.commit(); ``` **Receive the data in Application 2( to get data from Shared Preferences in Application 1).** ``` try { con = createPackageContext("com.sharedpref1", 0);//first app package name is "com.sharedpref1" SharedPreferences pref = con.getSharedPreferences( "demopref", Context.MODE_PRIVATE); String your_data = pref.getString("demostring", "No Value"); } catch (NameNotFoundException e) { Log.e("Not data shared", e.toString()); } ``` **In both application manifest files add same shared user id & label,** ``` android:sharedUserId="any string" android:sharedUserLabel="@string/any_string" ``` both are same... and shared user label must from string.xml **like this example.** ``` <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.xxxx" android:versionCode="1" android:versionName="1.0" android:sharedUserId="any string" android:sharedUserLabel="@string/any_string"> ```
I suspect they were likely looking for Android specific methods such as the content provider answer. Other alternatives... Android Specific - Remote services General - TCP/IP connections General - Writing to a location on the SD card Care to hear more about a specific method? Also stealing this question for an interview today :)
5,745,243
Recently i had an interview in which the question was asked as "How would you be able to share the data between two installed apps or apk's?" I didn't have any answer for this question. Can anyone help me in determining an way to do so...
2011/04/21
[ "https://Stackoverflow.com/questions/5745243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/303155/" ]
I suspect they were likely looking for Android specific methods such as the content provider answer. Other alternatives... Android Specific - Remote services General - TCP/IP connections General - Writing to a location on the SD card Care to hear more about a specific method? Also stealing this question for an interview today :)
1. using implicit intent and startActivityForResult. 2. Using Content provider [eg of content Providor:](http://content%20providor%20example)
5,745,243
Recently i had an interview in which the question was asked as "How would you be able to share the data between two installed apps or apk's?" I didn't have any answer for this question. Can anyone help me in determining an way to do so...
2011/04/21
[ "https://Stackoverflow.com/questions/5745243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/303155/" ]
If you want to share data between applications, make sure you sign with the same key: > > Code/data sharing through permissions – The Android system provides > signature-based permissions enforcement, so that an application can > expose functionality to another application that is signed with a > specified certificate. By signing multiple applications with the same > certificate and using signature-based permissions checks, your > applications can share code and data in a secure manner. > > > This is quoted from: [android developer page about signing](http://developer.android.com/tools/publishing/app-signing.html) If it's a small amount of data you could send it through an intent.
My requirement was to send a simple string from one app to another and get a string back. Like "user id" from App1 to App2 and get "username" back to App1. I was able to achieve this using **implicit intent** and **startActivityForResult**. If anyone is looking for the full process I posted my answer here [How to send data between one application to other application in android?](https://stackoverflow.com/questions/38608496/how-to-send-data-between-one-application-to-other-application-in-android/56737554#56737554). App1 > MainActivity.java ``` //Need to register your intent filter in App2 in manifest file with same action. intent.setAction("com.example.sender.login"); // <packagename.login> intent.setType("text/plain"); startActivityForResult(intent, REQUEST_CODE); onActivityResult(...) { ... // Handle received data from App2 here } ``` I had two activity in App2 ie. MainActivity and LoginActivity. App2 > AndroidManifest.xml ``` <intent-filter> <!--The action has to be same as App1--> <action android:name="com.example.sender.login" /> ... </intent-filter> ``` App2 > LoginActivity.java ``` override fun onResume() { ... // Handle data from App1 here } fun onClickBack(view: View) { val intent = intent ... // Set data in bundle here for App1 setResult(Activity.RESULT_OK, intent) finish() } ```
21,229,887
I am new to Kinect.. I wanted to know how is it possible to get point cloud from kinect's depth data. I have tried getting the depth pixels and colorizing the near pixels based on depth. Now, my requirement is to get a 3d map based on the depth data. So, I guess first I need to have the point cloud. How should I proceed?
2014/01/20
[ "https://Stackoverflow.com/questions/21229887", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1652168/" ]
```js Add this to your jQuery **jQuery('.panel-collapse').removeClass("in");** This will close the accordion on page load ``` ```html `<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne"> <div class="panel-body"> <div class="textwidget"> <ul> <li>1</li> <li>2</li> </ul> </div> </div> ```
Try to use [.collapse('hide')](http://getbootstrap.com/javascript/#collapse) method: ``` $(document).ready(function() { $('#yourAccordionId').collapse("hide"); // Rest of the code here }); ```
528,284
Please consider the following efficiency graphs of the exemplary [MP2384](https://www.monolithicpower.com/en/mp2384.html) buck sync converter: [![enter image description here](https://i.stack.imgur.com/qc9CG.png)](https://i.stack.imgur.com/qc9CG.png) What I am trying to understand is why is the efficiency at light loads worse for the cases in which the VIN value is a lot higher than the VOUT. In the end, the efficiency difference is negligible for higher loads. This behavior I have observed for different buck converters in the past as well. I would appreciate all feedback regarding this case.
2020/10/20
[ "https://electronics.stackexchange.com/questions/528284", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/59894/" ]
The part of the chip that does the management (the comparator, the voltage reference, the PWM generator and various low-level interface circuits) take some amount of current i.e. they are not self-powering and that's basically the main clue. They require current and that current/power quite often is provided by a low-level **LINEAR** regulator. Given that the efficiency of that (or any) linear regulator worsens proportional to input voltage, then that linearly regulated power eats into the overall efficiency of the full converter and, it's more obvious at higher input voltages and lower output load powers. Here's what the quiescent power required by the converter is at various input voltages: - [![enter image description here](https://i.stack.imgur.com/sLuOZ.png)](https://i.stack.imgur.com/sLuOZ.png) So, when Vin = 19 volts, the device is "wasting" 2.2 mW and, given that in your 3.3 volt efficiency diagram (on the right) there is a load power of 33 mW at 10 mA load you can begin to see that the "management stuff" is becoming a significant factor. The actual implied losses when producing 10 mA at 3.3 volts will be from the MOSFETs and inductor. They don't come for free either. So, if I were to add things up, to make an output power of 33 mW at an efficiency of 84% requires a total power in of 39.3 mW. Given that the management stuff consumes about 2.2 mW that leaves about 4 mW wasted in the MOSFETs and inductor. On a high load power, the 2.2 mW consumed by the management stuff becomes trivial because most of the losses are being created by the MOSFETs and inductor. For instance, with a 4 amp load and Vout = 3.3 volts, the output power is 13.2 watts. The graph's stated efficiency is 94% hence, the total power is 14.04 watts. In other words 0.84 watts are wasted by MOSFETs and inductor and, it's just not worth trying to factor in the 2.2 mW of the management stuff. But clearly they are significant when you are talking low output powers.
The regulator itself consumes current. It has an internal linear LDO to drop input voltage to useful levels. And therefore, LDO losses are higher at higher input voltage, even if the circuitry powered by the LDO uses exactly same amount of power.
528,284
Please consider the following efficiency graphs of the exemplary [MP2384](https://www.monolithicpower.com/en/mp2384.html) buck sync converter: [![enter image description here](https://i.stack.imgur.com/qc9CG.png)](https://i.stack.imgur.com/qc9CG.png) What I am trying to understand is why is the efficiency at light loads worse for the cases in which the VIN value is a lot higher than the VOUT. In the end, the efficiency difference is negligible for higher loads. This behavior I have observed for different buck converters in the past as well. I would appreciate all feedback regarding this case.
2020/10/20
[ "https://electronics.stackexchange.com/questions/528284", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/59894/" ]
The part of the chip that does the management (the comparator, the voltage reference, the PWM generator and various low-level interface circuits) take some amount of current i.e. they are not self-powering and that's basically the main clue. They require current and that current/power quite often is provided by a low-level **LINEAR** regulator. Given that the efficiency of that (or any) linear regulator worsens proportional to input voltage, then that linearly regulated power eats into the overall efficiency of the full converter and, it's more obvious at higher input voltages and lower output load powers. Here's what the quiescent power required by the converter is at various input voltages: - [![enter image description here](https://i.stack.imgur.com/sLuOZ.png)](https://i.stack.imgur.com/sLuOZ.png) So, when Vin = 19 volts, the device is "wasting" 2.2 mW and, given that in your 3.3 volt efficiency diagram (on the right) there is a load power of 33 mW at 10 mA load you can begin to see that the "management stuff" is becoming a significant factor. The actual implied losses when producing 10 mA at 3.3 volts will be from the MOSFETs and inductor. They don't come for free either. So, if I were to add things up, to make an output power of 33 mW at an efficiency of 84% requires a total power in of 39.3 mW. Given that the management stuff consumes about 2.2 mW that leaves about 4 mW wasted in the MOSFETs and inductor. On a high load power, the 2.2 mW consumed by the management stuff becomes trivial because most of the losses are being created by the MOSFETs and inductor. For instance, with a 4 amp load and Vout = 3.3 volts, the output power is 13.2 watts. The graph's stated efficiency is 94% hence, the total power is 14.04 watts. In other words 0.84 watts are wasted by MOSFETs and inductor and, it's just not worth trying to factor in the 2.2 mW of the management stuff. But clearly they are significant when you are talking low output powers.
As the others explained, the regulator draws some current from the input in order to function. This will be current to power internal circuitry plus a variable current to charge the FET gates that is roughly proportional to switching frequency. Let's call this total quiescent current Io. Since the internal LDO wastes excess voltage as heat, it'll use a power of Io\*Vin. Relative to varying output power this management overhead results in lower efficiency at low loads and high Vin. Switching regulators marketed as "high efficiency at light load" will have some kind of sleep/burst modes or cycle-skipping to reduce these losses. At light load, the chip sleeps, then only resumes switching when the output voltage falls below a threshold, then it tops up the output capacitor with a burst of switching until it reaches another threshold, and goes back to sleep. This reduces Io at the cost of increased output voltage ripple. If the regulator has a pin that sounds like "Internal VCC" then you can power its internal circuitry and MOSFET driver from another supply, or from the output of the regulator via a diode if the voltage is suitable, which turns off the internal LDO and avoids its losses. This makes it more efficient. If you have two supply voltages, say a small switcher and a high current switcher then you can also power the big switcher's InternalVCC from the small one if voltages are compatible. This optimizes away LDO losses.
528,284
Please consider the following efficiency graphs of the exemplary [MP2384](https://www.monolithicpower.com/en/mp2384.html) buck sync converter: [![enter image description here](https://i.stack.imgur.com/qc9CG.png)](https://i.stack.imgur.com/qc9CG.png) What I am trying to understand is why is the efficiency at light loads worse for the cases in which the VIN value is a lot higher than the VOUT. In the end, the efficiency difference is negligible for higher loads. This behavior I have observed for different buck converters in the past as well. I would appreciate all feedback regarding this case.
2020/10/20
[ "https://electronics.stackexchange.com/questions/528284", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/59894/" ]
The part of the chip that does the management (the comparator, the voltage reference, the PWM generator and various low-level interface circuits) take some amount of current i.e. they are not self-powering and that's basically the main clue. They require current and that current/power quite often is provided by a low-level **LINEAR** regulator. Given that the efficiency of that (or any) linear regulator worsens proportional to input voltage, then that linearly regulated power eats into the overall efficiency of the full converter and, it's more obvious at higher input voltages and lower output load powers. Here's what the quiescent power required by the converter is at various input voltages: - [![enter image description here](https://i.stack.imgur.com/sLuOZ.png)](https://i.stack.imgur.com/sLuOZ.png) So, when Vin = 19 volts, the device is "wasting" 2.2 mW and, given that in your 3.3 volt efficiency diagram (on the right) there is a load power of 33 mW at 10 mA load you can begin to see that the "management stuff" is becoming a significant factor. The actual implied losses when producing 10 mA at 3.3 volts will be from the MOSFETs and inductor. They don't come for free either. So, if I were to add things up, to make an output power of 33 mW at an efficiency of 84% requires a total power in of 39.3 mW. Given that the management stuff consumes about 2.2 mW that leaves about 4 mW wasted in the MOSFETs and inductor. On a high load power, the 2.2 mW consumed by the management stuff becomes trivial because most of the losses are being created by the MOSFETs and inductor. For instance, with a 4 amp load and Vout = 3.3 volts, the output power is 13.2 watts. The graph's stated efficiency is 94% hence, the total power is 14.04 watts. In other words 0.84 watts are wasted by MOSFETs and inductor and, it's just not worth trying to factor in the 2.2 mW of the management stuff. But clearly they are significant when you are talking low output powers.
Besides of the self-consumption mentioned in other answers (that probably dominates loses in a well-designed circuit), there is one more V\_IN dependence: switching capacitive loses. Output switch has internal capacity. It also probably has a snubber. Both of them charge at each switch either to 0 or to V\_IN. These loses are proportional to V\_IN squared and mostly independent from the load.
528,284
Please consider the following efficiency graphs of the exemplary [MP2384](https://www.monolithicpower.com/en/mp2384.html) buck sync converter: [![enter image description here](https://i.stack.imgur.com/qc9CG.png)](https://i.stack.imgur.com/qc9CG.png) What I am trying to understand is why is the efficiency at light loads worse for the cases in which the VIN value is a lot higher than the VOUT. In the end, the efficiency difference is negligible for higher loads. This behavior I have observed for different buck converters in the past as well. I would appreciate all feedback regarding this case.
2020/10/20
[ "https://electronics.stackexchange.com/questions/528284", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/59894/" ]
Besides of the self-consumption mentioned in other answers (that probably dominates loses in a well-designed circuit), there is one more V\_IN dependence: switching capacitive loses. Output switch has internal capacity. It also probably has a snubber. Both of them charge at each switch either to 0 or to V\_IN. These loses are proportional to V\_IN squared and mostly independent from the load.
The regulator itself consumes current. It has an internal linear LDO to drop input voltage to useful levels. And therefore, LDO losses are higher at higher input voltage, even if the circuitry powered by the LDO uses exactly same amount of power.
528,284
Please consider the following efficiency graphs of the exemplary [MP2384](https://www.monolithicpower.com/en/mp2384.html) buck sync converter: [![enter image description here](https://i.stack.imgur.com/qc9CG.png)](https://i.stack.imgur.com/qc9CG.png) What I am trying to understand is why is the efficiency at light loads worse for the cases in which the VIN value is a lot higher than the VOUT. In the end, the efficiency difference is negligible for higher loads. This behavior I have observed for different buck converters in the past as well. I would appreciate all feedback regarding this case.
2020/10/20
[ "https://electronics.stackexchange.com/questions/528284", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/59894/" ]
Besides of the self-consumption mentioned in other answers (that probably dominates loses in a well-designed circuit), there is one more V\_IN dependence: switching capacitive loses. Output switch has internal capacity. It also probably has a snubber. Both of them charge at each switch either to 0 or to V\_IN. These loses are proportional to V\_IN squared and mostly independent from the load.
As the others explained, the regulator draws some current from the input in order to function. This will be current to power internal circuitry plus a variable current to charge the FET gates that is roughly proportional to switching frequency. Let's call this total quiescent current Io. Since the internal LDO wastes excess voltage as heat, it'll use a power of Io\*Vin. Relative to varying output power this management overhead results in lower efficiency at low loads and high Vin. Switching regulators marketed as "high efficiency at light load" will have some kind of sleep/burst modes or cycle-skipping to reduce these losses. At light load, the chip sleeps, then only resumes switching when the output voltage falls below a threshold, then it tops up the output capacitor with a burst of switching until it reaches another threshold, and goes back to sleep. This reduces Io at the cost of increased output voltage ripple. If the regulator has a pin that sounds like "Internal VCC" then you can power its internal circuitry and MOSFET driver from another supply, or from the output of the regulator via a diode if the voltage is suitable, which turns off the internal LDO and avoids its losses. This makes it more efficient. If you have two supply voltages, say a small switcher and a high current switcher then you can also power the big switcher's InternalVCC from the small one if voltages are compatible. This optimizes away LDO losses.
60,667,536
I am working on python 3.7 and trying to scrape data from website, below is my code ``` import requests session = requests.session() session.headers= {'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46'} base_url="any_website" res=session.get(base_url, timeout=25) ``` The above code causes: socket.timeout: The read operation timed out exception However after removing headers, the same code. works. can anyone help me with the issue.
2020/03/13
[ "https://Stackoverflow.com/questions/60667536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5462787/" ]
It depends on what your are trying to achieve. In the first example you'll run the same code if one of them is true, and in the second example you'll run probably different lines of code for each equality. This is the difference between the two. So the efficiency in number of lines is not a factor here.
Your 2 examples serve 2 different purposes, the first is when each of the condition has the same outcome / code to be ran, whereas the second example, each condition has a different outcome / code to be ran
60,667,536
I am working on python 3.7 and trying to scrape data from website, below is my code ``` import requests session = requests.session() session.headers= {'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46'} base_url="any_website" res=session.get(base_url, timeout=25) ``` The above code causes: socket.timeout: The read operation timed out exception However after removing headers, the same code. works. can anyone help me with the issue.
2020/03/13
[ "https://Stackoverflow.com/questions/60667536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5462787/" ]
``` if (number === 1 || number === 2 || number === 3) { console.log('here') } ``` is different from ``` if (number === 1) { console.log('here',number) //here1 } else if (number === 2) { console.log('here',number) //here2 } else if (number === 3) { console.log('here',number) //here3 } ``` in first example if the number is 1 or 2 or 3 it will work same but in second example if the number is 1 will work different and if number is 2 it will work different and for 3 it will work different
Your 2 examples serve 2 different purposes, the first is when each of the condition has the same outcome / code to be ran, whereas the second example, each condition has a different outcome / code to be ran
60,667,536
I am working on python 3.7 and trying to scrape data from website, below is my code ``` import requests session = requests.session() session.headers= {'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46'} base_url="any_website" res=session.get(base_url, timeout=25) ``` The above code causes: socket.timeout: The read operation timed out exception However after removing headers, the same code. works. can anyone help me with the issue.
2020/03/13
[ "https://Stackoverflow.com/questions/60667536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5462787/" ]
Your 2 examples serve 2 different purposes, the first is when each of the condition has the same outcome / code to be ran, whereas the second example, each condition has a different outcome / code to be ran
the differnece is below:- first statement will going to print the same result every time if any one or "||" condition is true. Second statement will going to print the result on the basis of condition inside if and else if which one is true.
60,667,536
I am working on python 3.7 and trying to scrape data from website, below is my code ``` import requests session = requests.session() session.headers= {'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46'} base_url="any_website" res=session.get(base_url, timeout=25) ``` The above code causes: socket.timeout: The read operation timed out exception However after removing headers, the same code. works. can anyone help me with the issue.
2020/03/13
[ "https://Stackoverflow.com/questions/60667536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5462787/" ]
Your 2 examples serve 2 different purposes, the first is when each of the condition has the same outcome / code to be ran, whereas the second example, each condition has a different outcome / code to be ran
Most programming language supports short circuit. Meaning to if any of the earlier conditions are met, it will go into the block immediately without checking the the truth of latter conditions. In the case where you just need to check if number equals to either 1, 2 or 3, and do one action regardless of the value of number, Example a would be more suitable. Although the overhead is negligible, you save on the duplication of code, mentioned by all other answers!
60,667,536
I am working on python 3.7 and trying to scrape data from website, below is my code ``` import requests session = requests.session() session.headers= {'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46'} base_url="any_website" res=session.get(base_url, timeout=25) ``` The above code causes: socket.timeout: The read operation timed out exception However after removing headers, the same code. works. can anyone help me with the issue.
2020/03/13
[ "https://Stackoverflow.com/questions/60667536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5462787/" ]
It depends on what your are trying to achieve. In the first example you'll run the same code if one of them is true, and in the second example you'll run probably different lines of code for each equality. This is the difference between the two. So the efficiency in number of lines is not a factor here.
the differnece is below:- first statement will going to print the same result every time if any one or "||" condition is true. Second statement will going to print the result on the basis of condition inside if and else if which one is true.
60,667,536
I am working on python 3.7 and trying to scrape data from website, below is my code ``` import requests session = requests.session() session.headers= {'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46'} base_url="any_website" res=session.get(base_url, timeout=25) ``` The above code causes: socket.timeout: The read operation timed out exception However after removing headers, the same code. works. can anyone help me with the issue.
2020/03/13
[ "https://Stackoverflow.com/questions/60667536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5462787/" ]
It depends on what your are trying to achieve. In the first example you'll run the same code if one of them is true, and in the second example you'll run probably different lines of code for each equality. This is the difference between the two. So the efficiency in number of lines is not a factor here.
Most programming language supports short circuit. Meaning to if any of the earlier conditions are met, it will go into the block immediately without checking the the truth of latter conditions. In the case where you just need to check if number equals to either 1, 2 or 3, and do one action regardless of the value of number, Example a would be more suitable. Although the overhead is negligible, you save on the duplication of code, mentioned by all other answers!
60,667,536
I am working on python 3.7 and trying to scrape data from website, below is my code ``` import requests session = requests.session() session.headers= {'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46'} base_url="any_website" res=session.get(base_url, timeout=25) ``` The above code causes: socket.timeout: The read operation timed out exception However after removing headers, the same code. works. can anyone help me with the issue.
2020/03/13
[ "https://Stackoverflow.com/questions/60667536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5462787/" ]
``` if (number === 1 || number === 2 || number === 3) { console.log('here') } ``` is different from ``` if (number === 1) { console.log('here',number) //here1 } else if (number === 2) { console.log('here',number) //here2 } else if (number === 3) { console.log('here',number) //here3 } ``` in first example if the number is 1 or 2 or 3 it will work same but in second example if the number is 1 will work different and if number is 2 it will work different and for 3 it will work different
the differnece is below:- first statement will going to print the same result every time if any one or "||" condition is true. Second statement will going to print the result on the basis of condition inside if and else if which one is true.
60,667,536
I am working on python 3.7 and trying to scrape data from website, below is my code ``` import requests session = requests.session() session.headers= {'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46'} base_url="any_website" res=session.get(base_url, timeout=25) ``` The above code causes: socket.timeout: The read operation timed out exception However after removing headers, the same code. works. can anyone help me with the issue.
2020/03/13
[ "https://Stackoverflow.com/questions/60667536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5462787/" ]
``` if (number === 1 || number === 2 || number === 3) { console.log('here') } ``` is different from ``` if (number === 1) { console.log('here',number) //here1 } else if (number === 2) { console.log('here',number) //here2 } else if (number === 3) { console.log('here',number) //here3 } ``` in first example if the number is 1 or 2 or 3 it will work same but in second example if the number is 1 will work different and if number is 2 it will work different and for 3 it will work different
Most programming language supports short circuit. Meaning to if any of the earlier conditions are met, it will go into the block immediately without checking the the truth of latter conditions. In the case where you just need to check if number equals to either 1, 2 or 3, and do one action regardless of the value of number, Example a would be more suitable. Although the overhead is negligible, you save on the duplication of code, mentioned by all other answers!
4,995,425
I've been fighting with SSRS now for a while and it's beyond silly. When I add a reference to a dll (which is part of the same solution) it gives me nothing but a > > [rsErrorLoadingCodeModule] Error > while loading code module: > ‘MyFile.MyClass.Code, Version=1.0.0.0, > Culture=neutral, PublicKeyToken=null’. > Details: Could not load file or > assembly 'MyFile.MyClass.Code, > Version=1.0.0.0, Culture=neutral, > PublicKeyToken=null' or one of its > dependencies. The system cannot find > the file specified. > > > I've tried hitting the solution config to tell it debug source is in other locations, copying the file to about 50 different locations (not gac, not possible), running Visual Studio 2008 as admin, all the goofy stuff you can think of ... nothing, same error everytime. Any ideas?
2011/02/14
[ "https://Stackoverflow.com/questions/4995425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/202728/" ]
I got a similar error on ssrs-2005. Just manually copy your dll to the following report server folder: "C:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\ReportServer\bin" and everything should work fine.
You may need to add references to the assemblies that your MyFile assembly itself references. So, if MyFile references System.IO for example, you may need to add that dll reference explicitly to the report.
4,995,425
I've been fighting with SSRS now for a while and it's beyond silly. When I add a reference to a dll (which is part of the same solution) it gives me nothing but a > > [rsErrorLoadingCodeModule] Error > while loading code module: > ‘MyFile.MyClass.Code, Version=1.0.0.0, > Culture=neutral, PublicKeyToken=null’. > Details: Could not load file or > assembly 'MyFile.MyClass.Code, > Version=1.0.0.0, Culture=neutral, > PublicKeyToken=null' or one of its > dependencies. The system cannot find > the file specified. > > > I've tried hitting the solution config to tell it debug source is in other locations, copying the file to about 50 different locations (not gac, not possible), running Visual Studio 2008 as admin, all the goofy stuff you can think of ... nothing, same error everytime. Any ideas?
2011/02/14
[ "https://Stackoverflow.com/questions/4995425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/202728/" ]
Here is the actual correct answer.. I've had to fight with this twice now and did not document it well enough the first time thinking it was a one-time thing. Putting it in the SQL Server Bin folder is for the server. for DEVELOPMENT put a copy in the Visual Studio folder, something like: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies or Windows 7 64 bit C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies
You may need to add references to the assemblies that your MyFile assembly itself references. So, if MyFile references System.IO for example, you may need to add that dll reference explicitly to the report.
4,995,425
I've been fighting with SSRS now for a while and it's beyond silly. When I add a reference to a dll (which is part of the same solution) it gives me nothing but a > > [rsErrorLoadingCodeModule] Error > while loading code module: > ‘MyFile.MyClass.Code, Version=1.0.0.0, > Culture=neutral, PublicKeyToken=null’. > Details: Could not load file or > assembly 'MyFile.MyClass.Code, > Version=1.0.0.0, Culture=neutral, > PublicKeyToken=null' or one of its > dependencies. The system cannot find > the file specified. > > > I've tried hitting the solution config to tell it debug source is in other locations, copying the file to about 50 different locations (not gac, not possible), running Visual Studio 2008 as admin, all the goofy stuff you can think of ... nothing, same error everytime. Any ideas?
2011/02/14
[ "https://Stackoverflow.com/questions/4995425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/202728/" ]
Here is the actual correct answer.. I've had to fight with this twice now and did not document it well enough the first time thinking it was a one-time thing. Putting it in the SQL Server Bin folder is for the server. for DEVELOPMENT put a copy in the Visual Studio folder, something like: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies or Windows 7 64 bit C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies
I got a similar error on ssrs-2005. Just manually copy your dll to the following report server folder: "C:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\ReportServer\bin" and everything should work fine.
4,995,425
I've been fighting with SSRS now for a while and it's beyond silly. When I add a reference to a dll (which is part of the same solution) it gives me nothing but a > > [rsErrorLoadingCodeModule] Error > while loading code module: > ‘MyFile.MyClass.Code, Version=1.0.0.0, > Culture=neutral, PublicKeyToken=null’. > Details: Could not load file or > assembly 'MyFile.MyClass.Code, > Version=1.0.0.0, Culture=neutral, > PublicKeyToken=null' or one of its > dependencies. The system cannot find > the file specified. > > > I've tried hitting the solution config to tell it debug source is in other locations, copying the file to about 50 different locations (not gac, not possible), running Visual Studio 2008 as admin, all the goofy stuff you can think of ... nothing, same error everytime. Any ideas?
2011/02/14
[ "https://Stackoverflow.com/questions/4995425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/202728/" ]
I got a similar error on ssrs-2005. Just manually copy your dll to the following report server folder: "C:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\ReportServer\bin" and everything should work fine.
For those who have been having trouble with custom dlls which import System.Data.SqlClient, I found the following tip absolutely essential in the rssrvpolicy.config file: Short and dirty answer: Change the PermissionSetName attribute from "Execution" to "FullTrust" for CodeGroup "Report\_Expressions\_Default\_Permissions". I hope this helps someone.
4,995,425
I've been fighting with SSRS now for a while and it's beyond silly. When I add a reference to a dll (which is part of the same solution) it gives me nothing but a > > [rsErrorLoadingCodeModule] Error > while loading code module: > ‘MyFile.MyClass.Code, Version=1.0.0.0, > Culture=neutral, PublicKeyToken=null’. > Details: Could not load file or > assembly 'MyFile.MyClass.Code, > Version=1.0.0.0, Culture=neutral, > PublicKeyToken=null' or one of its > dependencies. The system cannot find > the file specified. > > > I've tried hitting the solution config to tell it debug source is in other locations, copying the file to about 50 different locations (not gac, not possible), running Visual Studio 2008 as admin, all the goofy stuff you can think of ... nothing, same error everytime. Any ideas?
2011/02/14
[ "https://Stackoverflow.com/questions/4995425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/202728/" ]
Here is the actual correct answer.. I've had to fight with this twice now and did not document it well enough the first time thinking it was a one-time thing. Putting it in the SQL Server Bin folder is for the server. for DEVELOPMENT put a copy in the Visual Studio folder, something like: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies or Windows 7 64 bit C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies
For those who have been having trouble with custom dlls which import System.Data.SqlClient, I found the following tip absolutely essential in the rssrvpolicy.config file: Short and dirty answer: Change the PermissionSetName attribute from "Execution" to "FullTrust" for CodeGroup "Report\_Expressions\_Default\_Permissions". I hope this helps someone.
48,645,134
I been trying to access my Google calendar using the calendar api. On my development machine I am able to access the data and display the events on the calendar, but when I push it to the production server I get the following error after giving permission access to the calendar. Forbidden > > You don't have permission to access /secondavechurch/calendar2.php on > this server. > > > Additionally, a 403 Forbidden error was encountered while trying to > use an ErrorDocument to handle the request. > > > I made a service account and gave rights to access the calendar to see if it's was the issue, but still get the same error. Here is my code ``` require_once __DIR__ . '/vendor/autoload.php'; date_default_timezone_set('America/New_York'); $REDIRECT_URI = 'http://' . $_SERVER['HTTP_HOST'] .'/calendar2.php'; $KEY_LOCATION = __DIR__ . '/client_secret.json'; $SERVICE_ACCOUNT_NAME = 'xxxxxx.iam.gserviceaccount.com'; $TOKEN_FILE = "token.txt"; $SCOPES = array( Google_Service_Calendar::CALENDAR_READONLY ); $client = new Google_Client(); $client->setApplicationName("Second Ave Church Calendar"); $client->setAuthConfig($KEY_LOCATION); $service = new Google_Service_Calendar($client); // Incremental authorization $client->setIncludeGrantedScopes(true); // Allow access to Google API when the user is not present. $client->setAccessType('offline'); $client->setApprovalPrompt ("force"); $client->setRedirectUri($REDIRECT_URI); $client->setScopes($SCOPES); if (isset($_GET['code']) && !empty($_GET['code'])) { try { // Exchange the one-time authorization code for an access token $accessToken = $client->fetchAccessTokenWithAuthCode($_GET['code']); // Save the access token and refresh token in local filesystem file_put_contents($TOKEN_FILE, json_encode($accessToken)); $_SESSION['accessToken'] = $accessToken; header('Location: ' . filter_var($REDIRECT_URI, FILTER_SANITIZE_URL)); exit(); } catch (\Google_Service_Exception $e) { print_r($e); } } if (!isset($_SESSION['accessToken'])) { $token = @file_get_contents($TOKEN_FILE); if ($token == null) { // Generate a URL to request access from Google's OAuth 2.0 server: $authUrl = $client->createAuthUrl(); // Redirect the user to Google's OAuth server header('Location: ' . filter_var($authUrl, FILTER_SANITIZE_URL)); exit(); } else { $_SESSION['accessToken'] = json_decode($token, true); } } $client->setAccessToken($_SESSION['accessToken']); /* Refresh token when expired */ if ($client->isAccessTokenExpired()) { // the new access token comes with a refresh token as well $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken()); file_put_contents($TOKEN_FILE, json_encode($client->getAccessToken())); } $currentEvents = date('Y-m-d', strtotime(date('Y-m-1'))) . 'T00:00:00-23:59'; $currentMonth = date('F'); $currentYear = date('Y'); $endDay = get_number_of_days_in_month(date('m'), $currentYear); $endOfMonth = date('Y-m-d', strtotime(date('Y-m-' . $endDay ))) . 'T00:00:00-23:59'; $calendarId = '[email protected]'; $optParams = array( 'maxResults' => 100, 'orderBy' => 'startTime', 'singleEvents' => TRUE, 'timeMin' => $currentEvents, 'timeMax' => $endOfMonth ); $results = $service->events->listEvents($calendarId, $optParams); if (count($results->getItems()) == 0) { $Heading = "No upcoming events found.\n"; } else { $Heading = $currentMonth . " events:\n"; echo "<div class='calendar'><h2> " . $Heading . "</h2></div>"; foreach ($results->getItems() as $event) { $start = $event->start->dateTime; $description = $event->getDescription(); $formattedDate = date_format(new DateTime($start),"F j, Y - G:i A"); if (empty($description)){ $description = "No Description"; } if (empty($start)) { $start = 'All Day Event'; } echo "<div class='calendar'><h1>" .$event->getSummary() . "</h1> <h3 class='getdates'>" . $formattedDate . " </h3><br /><span class='description'>" . $description . "</span></div>"; } } function get_number_of_days_in_month($month, $year) { // Using first day of the month, it doesn't really matter $date = $year."-".$month."-1"; return date("t", strtotime($date)); } ``` Thanks for the help with this Update: Changed permission to calendar2.php Got 500 Internal Server Error Here is the error log ``` [05-Feb-2018 14:55:51 America/New_York] PHP Fatal error: Call to undefined function GuzzleHttp\Handler\curl_reset() in .../secondavechurch/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 78 [05-Feb-2018 14:56:03 America/New_York] PHP Fatal error: Call to undefined function GuzzleHttp\Handler\curl_reset() in .../secondavechurch/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 78 [05-Feb-2018 16:20:46 America/Detroit] PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message 'file does not exist' in .../secondavechurch/vendor/google/apiclient/src/Google/Client.php:839 Stack trace: #0 .../secondavechurch/vendor/google/apiclient/src/Google/Client.php(824): Google_Client->setAuthConfig('CLIENT_SECRET_P...') #1 .../secondavechurch/oauth2callback.php(13): Google_Client->setAuthConfigFile('CLIENT_SECRET_P...') #2 {main} thrown in .../secondavechurch/vendor/google/apiclient/src/Google/Client.php on line 839 ``` Further Update: This is the error I am getting after configuring error page ``` /secondavechurch/calendar2.php?code=4/aajajkajkdnanfnoaono&scope=https://www.googleapis.com/auth/calendar.readonly Error Code: 403 ``` Further Update: Changed code to the following: ``` require_once __DIR__.'/vendor/autoload.php'; putenv('GOOGLE_APPLICATION_CREDENTIALS=servicea.json'); $SCOPES = array( Google_Service_Calendar::CALENDAR_READONLY ); $REDIRECT_URI = 'http://' . $_SERVER['HTTP_HOST'] .'/secondavechurch/calendar3.php'; $client = new Google_Client(); $client->useApplicationDefaultCredentials(); $client->setAccessType('offline'); $client->setApprovalPrompt ("force"); $client->setRedirectUri($REDIRECT_URI); $client->setScopes($SCOPES); $service = new Google_Service_Calendar($client); $currentEvents = date('Y-m-d', strtotime(date('Y-m-1'))) . 'T00:00:00-23:59'; $currentMonth = date('F'); $currentYear = date('Y'); $endDay = get_number_of_days_in_month(date('m'), $currentYear); $endOfMonth = date('Y-m-d', strtotime(date('Y-m-' . $endDay ))) . 'T00:00:00-23:59'; $calendarId = '[email protected]'; $optParams = array( 'maxResults' => 100, 'orderBy' => 'startTime', 'singleEvents' => TRUE, 'timeMin' => $currentEvents, 'timeMax' => $endOfMonth ); $results = $service->events->listEvents($calendarId, $optParams); if (count($results->getItems()) == 0) { $Heading = "No upcoming events found.\n"; } else { $Heading = $currentMonth . " events:\n"; echo "<div class='calendar'><h2> " . $Heading . "</h2></div>"; foreach ($results->getItems() as $event) { $start = $event->start->dateTime; $description = $event->getDescription(); $formattedDate = date_format(new DateTime($start),"F j, Y - G:i A"); if (empty($description)){ $description = "No Description"; } if (empty($start)) { $start = 'All Day Event'; } echo "<div class='calendar'><h1>" .$event->getSummary() . "</h1> <h3 class='getdates'>" . $formattedDate . " </h3><br /><span class='description'>" . $description . "</span></div>"; } } function get_number_of_days_in_month($month, $year) { // Using first day of the month, it doesn't really matter $date = $year."-".$month."-1"; return date("t", strtotime($date)); } ``` development gets data production doesn't get anything. No error comes up, but when I go to developer tools it shows a 500 error. No error on error log. Maybe I can use try catch in php to see if it does get any error.
2018/02/06
[ "https://Stackoverflow.com/questions/48645134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/586071/" ]
Create a .NET Core console app. Add the references: **Microsoft.SharePoint.Client.Portable.dll**, **Microsoft.SharePoint.Client.Runtime.Portable.dll** and **Microsoft.SharePoint.Client.Runtime.Windows.dll**. Then check if it works. As a workaround, we can also use REST API or web service in .NET Core application currently. Using REST API, we don't need reference those dlls in project. **Get to know the SharePoint REST service**: <https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service>
I'm thinking you may have the URL incorrectly entered? You should use "<http://servername/>" instead of "<http://servername/sites/subfolder/default.aspx>"
10,784
I plan on running PEX pipes both hot and cold across 16 feet of unheated attic space above a foyer. The foyer is 16' long and is off the kitchen, it isn't heated directly but is part of the house; it is usually colder than the rest of the house, mostly due to the cat door and slider the dogs go in and out of. There is insulation along the ceiling, underneath where I will be running the pipes. What is the best way to keep the pipes from freezing? Would an insulation pipe jacket be enough to keep the water in it from freezing or should I also run a long heating cable? I also considered insulating along the roof but it is a tight crawlspace and not much room in there to work. This is in New England so some days it gets pretty cold.
2011/12/20
[ "https://diy.stackexchange.com/questions/10784", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/4651/" ]
You are definitely running a risk of freezing these lines in an unheated space. It is never wise to run water lines in an outside wall or above an insulated ceiling in an unheated space. Perhaps you can do one of the following: 1. Run the lines under the floor in the basement (not unheated crawl space) where freezing will be much less likely. 2. Run the lines under the insulation in your ceiling next to the heated drywall. If you have to drill holes in ceiling joists, be sure they are at least 2 inches from ceiling to prevent accidental puncturing from drywall screws. Apply the insulation over the lines. 3. Thermostatically controlled heat tape can work, but be absolutely sure it is installed properly and if possible use a heat tape that you can use pipe insulation over. Not all heat tapes allow use of pipe insulation due to overheating of the PEX. 4. If you do have to run in this area, be sure there are no drafts that can come to bear on the tubing. Freezing is always faster if a cold draft blows on a water line. I wish I had a foolproof method for you to use. Just be cautious, monitor the conditions and have a water shut off handy. Although PEX will handle a lot of freezing without bursting, a leak is going to be a very expensive fix and a mess to clean up. Good Luck
Additional information as this winter tests out badly routed plumbing. PEX that gets water frozen inside it stretches and expands over time. The weak point is fittings. Depending on the fitting, it can crack, the crimp rings can be stretched leading to a leak from the fitting or the PEX slipping off under pressure. They don't use the type fittings where they expand the PEX to go over a plastic fitting around here so I don't know how those hold up. Keep the fittings out of the freeze zone, and summer cabin owners recommend having a gravity drain so the pipe doesn't grow or else charge the system with RV antifreeze. My former neighbor had a blowout in the soffit in his new house built quite recently. It was a couple weeks ago where we had a snap down into the teens, a fitting let go. As a plumbing system, PEX is a lot more forgiving, but not invulnerable. If you do freeze up, PEX is an insulator, it will take longer after **heating the containing area** for water in it to melt. Be careful with any sort of direct heat application (should I have to say no torches?). Why water lines are being run through a soffit area, only the builder knows. Cheapness, ignorance, either unforgivable.
10,784
I plan on running PEX pipes both hot and cold across 16 feet of unheated attic space above a foyer. The foyer is 16' long and is off the kitchen, it isn't heated directly but is part of the house; it is usually colder than the rest of the house, mostly due to the cat door and slider the dogs go in and out of. There is insulation along the ceiling, underneath where I will be running the pipes. What is the best way to keep the pipes from freezing? Would an insulation pipe jacket be enough to keep the water in it from freezing or should I also run a long heating cable? I also considered insulating along the roof but it is a tight crawlspace and not much room in there to work. This is in New England so some days it gets pretty cold.
2011/12/20
[ "https://diy.stackexchange.com/questions/10784", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/4651/" ]
You are definitely running a risk of freezing these lines in an unheated space. It is never wise to run water lines in an outside wall or above an insulated ceiling in an unheated space. Perhaps you can do one of the following: 1. Run the lines under the floor in the basement (not unheated crawl space) where freezing will be much less likely. 2. Run the lines under the insulation in your ceiling next to the heated drywall. If you have to drill holes in ceiling joists, be sure they are at least 2 inches from ceiling to prevent accidental puncturing from drywall screws. Apply the insulation over the lines. 3. Thermostatically controlled heat tape can work, but be absolutely sure it is installed properly and if possible use a heat tape that you can use pipe insulation over. Not all heat tapes allow use of pipe insulation due to overheating of the PEX. 4. If you do have to run in this area, be sure there are no drafts that can come to bear on the tubing. Freezing is always faster if a cold draft blows on a water line. I wish I had a foolproof method for you to use. Just be cautious, monitor the conditions and have a water shut off handy. Although PEX will handle a lot of freezing without bursting, a leak is going to be a very expensive fix and a mess to clean up. Good Luck
If you are using PEX, you can run it through your attic. PEX will NOT burst unless you live in a place that gets like 50 below. And it does not freeze as readily as metal pipe. We used PEX once and ended up replumbing our entire house with it. You can put foam insulation tubing on it to make you feel more secure, but you do need to give it some slack which causes it to snake. Still, the foam tubing insulation works great, but under our house - which is open - our PEX has been fine.
10,784
I plan on running PEX pipes both hot and cold across 16 feet of unheated attic space above a foyer. The foyer is 16' long and is off the kitchen, it isn't heated directly but is part of the house; it is usually colder than the rest of the house, mostly due to the cat door and slider the dogs go in and out of. There is insulation along the ceiling, underneath where I will be running the pipes. What is the best way to keep the pipes from freezing? Would an insulation pipe jacket be enough to keep the water in it from freezing or should I also run a long heating cable? I also considered insulating along the roof but it is a tight crawlspace and not much room in there to work. This is in New England so some days it gets pretty cold.
2011/12/20
[ "https://diy.stackexchange.com/questions/10784", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/4651/" ]
My research on topic: 1. Use PEX 'A' - it's better designed to flex; PEX is not guaranteed not to freeze or rupture; so use the better PEX grade; if possible avoid Grade 'B' and 'C'; use PEX 'A' if you have to go this method. 2. Will freeze and certainly can rupture, but less likely than copper pipes. 3. Make sure to have a good manifold system with individual line shutoffs. 4. Have an indoor water supply cutoff and an indoor pressure relief value on manifold or below manifold to relieve pressure on tubing during deep freezes; simply allowing some of the water lines to drip may not be sufficient; vacuum may prevent all lines from being relieved of pressure. 5. Stay out of attic if possible; but if you must go through attic, well insulate the tubing; pay attention to #3 & 4 above. 6. Keep a lot of towels ready just in case.
If you are using PEX, you can run it through your attic. PEX will NOT burst unless you live in a place that gets like 50 below. And it does not freeze as readily as metal pipe. We used PEX once and ended up replumbing our entire house with it. You can put foam insulation tubing on it to make you feel more secure, but you do need to give it some slack which causes it to snake. Still, the foam tubing insulation works great, but under our house - which is open - our PEX has been fine.
10,784
I plan on running PEX pipes both hot and cold across 16 feet of unheated attic space above a foyer. The foyer is 16' long and is off the kitchen, it isn't heated directly but is part of the house; it is usually colder than the rest of the house, mostly due to the cat door and slider the dogs go in and out of. There is insulation along the ceiling, underneath where I will be running the pipes. What is the best way to keep the pipes from freezing? Would an insulation pipe jacket be enough to keep the water in it from freezing or should I also run a long heating cable? I also considered insulating along the roof but it is a tight crawlspace and not much room in there to work. This is in New England so some days it gets pretty cold.
2011/12/20
[ "https://diy.stackexchange.com/questions/10784", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/4651/" ]
You are definitely running a risk of freezing these lines in an unheated space. It is never wise to run water lines in an outside wall or above an insulated ceiling in an unheated space. Perhaps you can do one of the following: 1. Run the lines under the floor in the basement (not unheated crawl space) where freezing will be much less likely. 2. Run the lines under the insulation in your ceiling next to the heated drywall. If you have to drill holes in ceiling joists, be sure they are at least 2 inches from ceiling to prevent accidental puncturing from drywall screws. Apply the insulation over the lines. 3. Thermostatically controlled heat tape can work, but be absolutely sure it is installed properly and if possible use a heat tape that you can use pipe insulation over. Not all heat tapes allow use of pipe insulation due to overheating of the PEX. 4. If you do have to run in this area, be sure there are no drafts that can come to bear on the tubing. Freezing is always faster if a cold draft blows on a water line. I wish I had a foolproof method for you to use. Just be cautious, monitor the conditions and have a water shut off handy. Although PEX will handle a lot of freezing without bursting, a leak is going to be a very expensive fix and a mess to clean up. Good Luck
My research on topic: 1. Use PEX 'A' - it's better designed to flex; PEX is not guaranteed not to freeze or rupture; so use the better PEX grade; if possible avoid Grade 'B' and 'C'; use PEX 'A' if you have to go this method. 2. Will freeze and certainly can rupture, but less likely than copper pipes. 3. Make sure to have a good manifold system with individual line shutoffs. 4. Have an indoor water supply cutoff and an indoor pressure relief value on manifold or below manifold to relieve pressure on tubing during deep freezes; simply allowing some of the water lines to drip may not be sufficient; vacuum may prevent all lines from being relieved of pressure. 5. Stay out of attic if possible; but if you must go through attic, well insulate the tubing; pay attention to #3 & 4 above. 6. Keep a lot of towels ready just in case.
10,784
I plan on running PEX pipes both hot and cold across 16 feet of unheated attic space above a foyer. The foyer is 16' long and is off the kitchen, it isn't heated directly but is part of the house; it is usually colder than the rest of the house, mostly due to the cat door and slider the dogs go in and out of. There is insulation along the ceiling, underneath where I will be running the pipes. What is the best way to keep the pipes from freezing? Would an insulation pipe jacket be enough to keep the water in it from freezing or should I also run a long heating cable? I also considered insulating along the roof but it is a tight crawlspace and not much room in there to work. This is in New England so some days it gets pretty cold.
2011/12/20
[ "https://diy.stackexchange.com/questions/10784", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/4651/" ]
Pex in the attic simply needs to be run BELOW the insulation. Put it against the ceiling drywall, and it will never get particularly cold. The problem is, lots of installers don't do this. My contractor actually went to some trouble to hang the pex up high. I had to go through and undo all the clamps and put it down below the insulation, but it wasn't too big a deal. Get it LOW and make sure there's more insulation above it than below it, and it will be fine in all but the most ridiculous of climates.
I have PEX in my attic and it was not properly secured to the rafters. This has caused some sections to rise above the blown in insulation. IT WILL FREEZE, mine freezes everyday if I don't use the fixtures in each bathroom at least sometime between dusk and dawn for a good while.
10,784
I plan on running PEX pipes both hot and cold across 16 feet of unheated attic space above a foyer. The foyer is 16' long and is off the kitchen, it isn't heated directly but is part of the house; it is usually colder than the rest of the house, mostly due to the cat door and slider the dogs go in and out of. There is insulation along the ceiling, underneath where I will be running the pipes. What is the best way to keep the pipes from freezing? Would an insulation pipe jacket be enough to keep the water in it from freezing or should I also run a long heating cable? I also considered insulating along the roof but it is a tight crawlspace and not much room in there to work. This is in New England so some days it gets pretty cold.
2011/12/20
[ "https://diy.stackexchange.com/questions/10784", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/4651/" ]
I have PEX in my attic and it was not properly secured to the rafters. This has caused some sections to rise above the blown in insulation. IT WILL FREEZE, mine freezes everyday if I don't use the fixtures in each bathroom at least sometime between dusk and dawn for a good while.
If you are using PEX, you can run it through your attic. PEX will NOT burst unless you live in a place that gets like 50 below. And it does not freeze as readily as metal pipe. We used PEX once and ended up replumbing our entire house with it. You can put foam insulation tubing on it to make you feel more secure, but you do need to give it some slack which causes it to snake. Still, the foam tubing insulation works great, but under our house - which is open - our PEX has been fine.
10,784
I plan on running PEX pipes both hot and cold across 16 feet of unheated attic space above a foyer. The foyer is 16' long and is off the kitchen, it isn't heated directly but is part of the house; it is usually colder than the rest of the house, mostly due to the cat door and slider the dogs go in and out of. There is insulation along the ceiling, underneath where I will be running the pipes. What is the best way to keep the pipes from freezing? Would an insulation pipe jacket be enough to keep the water in it from freezing or should I also run a long heating cable? I also considered insulating along the roof but it is a tight crawlspace and not much room in there to work. This is in New England so some days it gets pretty cold.
2011/12/20
[ "https://diy.stackexchange.com/questions/10784", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/4651/" ]
You are definitely running a risk of freezing these lines in an unheated space. It is never wise to run water lines in an outside wall or above an insulated ceiling in an unheated space. Perhaps you can do one of the following: 1. Run the lines under the floor in the basement (not unheated crawl space) where freezing will be much less likely. 2. Run the lines under the insulation in your ceiling next to the heated drywall. If you have to drill holes in ceiling joists, be sure they are at least 2 inches from ceiling to prevent accidental puncturing from drywall screws. Apply the insulation over the lines. 3. Thermostatically controlled heat tape can work, but be absolutely sure it is installed properly and if possible use a heat tape that you can use pipe insulation over. Not all heat tapes allow use of pipe insulation due to overheating of the PEX. 4. If you do have to run in this area, be sure there are no drafts that can come to bear on the tubing. Freezing is always faster if a cold draft blows on a water line. I wish I had a foolproof method for you to use. Just be cautious, monitor the conditions and have a water shut off handy. Although PEX will handle a lot of freezing without bursting, a leak is going to be a very expensive fix and a mess to clean up. Good Luck
Pex in the attic simply needs to be run BELOW the insulation. Put it against the ceiling drywall, and it will never get particularly cold. The problem is, lots of installers don't do this. My contractor actually went to some trouble to hang the pex up high. I had to go through and undo all the clamps and put it down below the insulation, but it wasn't too big a deal. Get it LOW and make sure there's more insulation above it than below it, and it will be fine in all but the most ridiculous of climates.