天道酬勤,学无止境

问答

Preference fragment tab adapter

I want to build a preference tab for my app but since I have other tabs extending from a regular fragment, I have an incompatible types error, as a PreferenceFragment cannot be converted to Fragment. Here is my Tab Fragment Adapter : public class PagerAdapter extends FragmentStatePagerAdapter { int mNumOfTabs; public PagerAdapter(FragmentManager fm, int NumOfTabs) { super(fm); this.mNumOfTabs = NumOfTabs; } @Override public Fragment getItem(int position) { switch (position) { case 0: Tab1Discover tab1 = new Tab1Discover(); return tab1; case 1: Tab2Planning tab2 = new Tab2Planning(); return

2022-01-25 02:45:41   android   android-fragments   android-preferences

namespaced class template inheritance in C++

In an earlier question, I asked asked class template inheritance in C++. I now have an extra level to add! Consider the following code. (Assume the member definitions are present and accurate) namespace Game { namespace Object { template<typename T> class Packable { public: /** * Packs a <class T> into a Packet (Packet << T) * Required for chaining packet packing *************************************************/ virtual sf::Packet& operator <<(sf::Packet& packet) = 0; // Work-horse, must be defined by child-class friend sf::Packet& operator <<(sf::Packet& packet, T &t); friend sf::Packet&

2022-01-25 02:45:35   c++   templates   inheritance   namespaces   operator-overloading

Command.Parameters["@name"].Value Correct syntax

I am attempting to use a query to select everything from a table using one - three parameters; SELECT * FROM PlantAreaCodes WHERE (@AreaCode IS NULL OR AreaCode = @AreaCode) AND (@AreaName IS NULL OR AreaName LIKE @AreaName) AND (@Comments IS NULL OR Comments LIKE @Comments); Here is the c# code for my query: mySqlCommand = mySqlConnect.CreateCommand(); mySqlCommand.CommandText = "SELECT * FROM PlantAreaCodes WHERE (@AreaCode IS NULL OR AreaCode = @AreaCode) AND (@AreaName IS NULL OR AreaName LIKE @AreaName) AND (@Comments IS NULL OR Comments LIKE @Comments);"; mySqlCommand.Parameters.Add("

2022-01-25 02:45:31   c#   mysql   parameters

Draggable element inside another draggable element

Here in the fiddle is more less what i want to do: http://jsfiddle.net/EUZS5/2/ . I have different elements in a swiper and in some slides inside there is a draggable element. Currently when i drag the arrow it also pulls the slide (which is not the behaviour i want:)) I tried to use 'stopPropagation' on drag event but it does not help to prevent the slide from moving. Any ideas how to achieve this? Im using hammerjs and idangerous.swiper. $(document).ready(function(){ var mySwiper = new Swiper('.swiper-container',{ pagination: '.pagination', paginationClickable: true }) var left; $('.arrow')

2022-01-25 02:45:27   javascript   jquery   html   draggable

ASP.net Repeater -- setting N Maximum Repetitions?

I am using a Repeater control to display data from a SQL server on multiple different sites right now. I am wondering if there is any way to make a repeater only "repeat" or run through its cycles a maximum of N times. I split a Div element up into 4 equal sections which have just enough room for 4 cycles of this repeater. If it runs more than 4 times, it pushes everything down in the div and begins a new row of images/text I would prefer to avoid. It makes the web page look uglier and does not really accomplish much for the client. Also is there any way to randomly select which iterations

2022-01-25 02:45:20   c#   asp.net   .net   repeater

How to make UITextView background lines aligned with the text?

i'm trying draw background line of UITextView, here is the code i used to draw those lines CGContextBeginPath(context); CGContextSetStrokeColorWithColor(context, self.horizontalLineColor.CGColor); CGContextSetLineWidth(context, kDashedBorderWidth); CGContextSetLineDash(context, 0, kDashedLinesLength, kDashedCount) ; CGFloat baseOffset = 9.0f + self.font.descender; CGFloat boundsX = self.bounds.origin.x; CGFloat boundsWidth = self.bounds.size.width; NSInteger firstVisibleLine = MAX(1, (self.contentOffset.y / self.font.lineHeight)); NSInteger lastVisibleLine = ceilf((self.contentOffset.y + self

2022-01-25 02:45:15   ios   uitextview

Thread-safe access to a datasource during a tableView update

My app uses a tableView with a data source that can be updated asynchronously by multiple threads. When the data source is changed, the tableView is updated, not reloaded, using tableView.performBatchUpdates({ tableView.deleteRows(at: deletions, with: .automatic) tableView.insertRows(at: insertions, with: .automatic) for (from, to) in movements { tableView.moveRow(at: from, to: to) } }, completion: { (finished) in if !finished { self.tableView.reloadData() } else { // some cleanup code } completion(finished) } where completion(finished) is some completion block. Typically, the tableView update

2022-01-25 02:45:07   ios   uitableview   thread-safety   grand-central-dispatch   nscondition

Translating Curl request to Invoke-WebRequest with --data-urlencode parameter

I'm trying to request data from Mixpanel via there API. Mixpanel JQL Getting Started I can run a modified version of their basic example script and receive data. # sends the JQL code in `query.js` to the api # to a project with sample data for this tutorial curl https://mixpanel.com/api/2.0/jql \ -u API_SECRET:PASSWORD \ --data-urlencode script@query.js query.js above is the query payload, which contains a JS function that is run on Mixpanel servers. The request returns JSON data. I have been unable to translate this to Invoke-WebRequest. Below is my attempt. $urlEncodedString = gc query.js |

2022-01-25 02:45:01   powershell   curl   invoke-webrequest

Mysql stored procedure gives unknown column error when executed [duplicate]

This question already has an answer here: mysql Unknown column variable in the field list (1 answer) Closed 2 years ago. I have written a small stored procedure to store redmine issue and timelog entries in my private redmine. The procedure is stored, but when I call it, it gives SQL error (1054): Unknown column 'uid' in 'field list' error. The column that the error message mention is exists, the type matches. Rewrite code, redeploy db When the second insert removed from SP, it works great. delimiter $$ DROP PROCEDURE if exists redmine.insert_fingerprint_workday_and_hour $$ CREATE DEFINER=

2022-01-25 02:44:57   mysql   stored-procedures

Table cell padding woes with Chrome

I am having a lot of trouble with table cell paddings in Chrome. It seems that if a table cell does not contain pure text, then no padding is applied at all. My markup: <table> <tr> <th></th> <th class="account-picture"></th> <th class="account-name">Name</th> <th class="account-email">Email</th> <th class="account-last">Last Sign in</th> </tr> <tr> <td> <fieldset> <ul> <li><input type="checkbox" id="enabled" name="test[]" value="enabled"></li> </ul> </fieldset> </td> <td class="account-picture"> <div class="online"> <img src="http://www.genengnews.com/app_themes/genconnect/images/default

2022-01-25 02:44:49   css   google-chrome   firefox   html-table   padding