This file contains 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
var middleware = require('middleware'), // the Middleware you want to test | |
httpMocks = require('node-mocks-http'), // quickly sets up REQUEST and RESPONSE to be passed into Express Middleware | |
request = {}, // define REQUEST | |
response = {} // define RESPONSE | |
; | |
describe('Middleware test', function(){ | |
context('Valid arguments are passed', function() { | |
beforeEach(function(done) { | |
/* |
This file contains 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
// TODO add <meta-data android:value="GlideModule" android:name="....OkHttpProgressGlideModule" /> | |
// TODO add <meta-data android:value="GlideModule" tools:node="remove" android:name="com.bumptech.glide.integration.okhttp.OkHttpGlideModule" /> | |
// or not use 'okhttp@aar' in Gradle depdendencies | |
public class OkHttpProgressGlideModule implements GlideModule { | |
@Override public void applyOptions(Context context, GlideBuilder builder) { } | |
@Override public void registerComponents(Context context, Glide glide) { | |
OkHttpClient client = new OkHttpClient(); | |
client.networkInterceptors().add(createInterceptor(new DispatchingProgressListener())); | |
glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client)); | |
} |
This file contains 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
/** | |
* Text view that allows changing the letter spacing of the text. | |
* | |
* @author Pedro Barros (pedrobarros.dev at gmail.com) | |
* @since May 7, 2013 | |
*/ | |
public static class LetterSpacingTextView extends TextView { | |
private float spacing = Spacing.NORMAL; | |
private CharSequence originalText = ""; |
This file contains 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
function createUUID() { | |
// http://www.ietf.org/rfc/rfc4122.txt | |
var s = []; | |
var hexDigits = "0123456789abcdef"; | |
for (var i = 0; i < 36; i++) { | |
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1); | |
} | |
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010 | |
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01 | |
s[8] = s[13] = s[18] = s[23] = "-"; |
This file contains 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
var options = { | |
headers: { | |
'Content-Type': 'application/json' | |
} | |
}; | |
needle('post',url, body,options) | |
.then((response) => { | |
if (response.statusCode !== 200) { | |
//do things |
This file contains 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
/** | |
* Layout for ingredients in recipe info | |
*/ | |
fun ingredientLayout(ingredientsList: List<RecipeIngredientsPojo>) { | |
var i = 1 | |
mutableListIngredients.clear() | |
ingredientLayout.removeAllViews() | |
if (!ingredientsList.isEmpty()) { |
This file contains 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
AlertDialog dialog = null; | |
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); | |
final EditText editText; | |
dialogBuilder.setTitle("Edit Balance "); | |
LayoutInflater inflater = getLayoutInflater(); | |
View dialogView = inflater.inflate(R.layout., null); | |
dialogBuilder.setView(dialogView); | |
editText = (EditText) dialogView.findViewById(R.id.alert_edit_text); |
This file contains 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
fun withSuffix(count: Int): String { | |
if (count < 1000) return "" + count | |
val exp = (Math.log(count.toDouble()) / Math.log(1000.0)).toInt() | |
return String.format("%.1f %c", | |
count / Math.pow(1000.0, exp.toDouble()), | |
"kMGTPE"[exp - 1]) | |
} |
This file contains 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
String text = "This text is white. <font color=\"blue\">This text is blue.</font>"; | |
textView.setText(Html.fromHtml(text), BufferType.SPANNABLE); | |
// ----- | |
SpannableStringBuilder builder = new SpannableStringBuilder(); | |
String red = "this is red"; | |
SpannableString redSpannable= new SpannableString(red); | |
redSpannable.setSpan(new ForegroundColorSpan(Color.RED), 0, red.length(), 0); |
This file contains 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
fun capWord(string: String): String { | |
val result = StringBuilder(string.length) | |
val words = string.split("\\ ".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() | |
for (i in words.indices) { | |
result.append(Character.toUpperCase(words[i][0])).append(words[i].substring(1)).append(" ") | |
} | |
return result.toString() | |
} |
OlderNewer