This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
binarySearch(array, target, startIndex, endIndex) | |
// target might still be in the range | |
if(endIndex >= startIndex) | |
midIndex = (startIndex + endIndex) // 2 | |
// found! | |
if(target == array[midIndex]) | |
return midIndex |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
import redis | |
import random | |
import pylibmc | |
import sys | |
r = redis.Redis(host = 'localhost', port = 6389) | |
mc = pylibmc.Client(['localhost:11222']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1、SwipeRefreshLayout下只能有一个具有scroll功能的子View(ScrollView、ListView、RecyclerView等),子View可以有多个子View | |
2、实现上拉加载更多,利用RecyclerView的LayoutManger实现 | |
mRecyclerView.setOnScrollListener(new OnScrollListener() { | |
@Override | |
public void onScrolled(int dx, int dy) { | |
if(mLayoutManager.findLastVisibleItemPosition() == dataset.length-1){ | |
Log.d("onScrolled", "end"); | |
dataset[dataset.length-1] = "正在加载..."; | |
adapter.notifyItemChanged(dataset.length-1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by nikola on 11/28/14. | |
*/ | |
public class MentionTransformation implements TransformationMethod { | |
private int mColor; | |
private Pattern MENTIONS_PATTERN = Pattern.compile("\\B@[a-z0-9_-]+"); | |
private MentionTransformation(int color) { | |
mColor = color; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SwipeRefreshLayoutToggleScrollListener extends RecyclerView.OnScrollListener { | |
private List<RecyclerView.OnScrollListener> mScrollListeners = new ArrayList<RecyclerView.OnScrollListener>(); | |
private int mExpectedVisiblePosition = 0; | |
private SwipeRefreshLayout mSwipeLayout; | |
public SwipeRefreshLayoutToggleScrollListener(SwipeRefreshLayout swipeLayout) { | |
mSwipeLayout = swipeLayout; | |
} | |
public void addScrollListener(RecyclerView.OnScrollListener listener){ | |
mScrollListeners.add(listener); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.andraskindler.sandbox.activity; | |
import retrofit.RestAdapter; | |
import retrofit.http.GET; | |
import retrofit.http.Query; | |
import rx.Observable; | |
import rx.Subscriber; | |
import rx.schedulers.Schedulers; | |
public class ApiManager { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.andraskindler.playground.adapter; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.BaseAdapter; | |
import android.widget.TextView; | |
import com.andraskindler.playground.Item; | |
import com.andraskindler.playground.R; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this example request for metadata retrieve and then post to the heroku service | |
MetadataService.MetadataPort service = MetadataValidator.createService(); | |
MetadataService.RetrieveRequest retrieveRequest = new MetadataService.RetrieveRequest(); | |
retrieveRequest.apiVersion = 27; | |
retrieveRequest.packageNames = null; | |
retrieveRequest.singlePackage = true; | |
retrieveRequest.specificFiles = null; | |
retrieveRequest.unpackaged = new MetadataService.Package_x(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page sidebar="false" showHeader="false" standardStylesheets="false"> | |
<script type="text/javascript"> | |
window.location = "{!URLFOR($Resource.mobileapp, 'index.html')}#sessionId={!$API.session_Id}"; | |
</script> | |
</apex:page> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<!-- live chat button --> | |
<a id="liveagent_button_online_573i00000004DD7" href="javascript://Chat" style="display: none;" onclick="liveagent.startChat('573i00000004DD7')"> | |
Online Chat | |
</a> | |
<div id="liveagent_button_offline_573i00000004DD7" style="display: none;"> | |
Offline Chat | |
</div> |
NewerOlder