01/13/2012. From a lecture by Professor John Ousterhout at Stanford, class CS140
Here's today's thought for the weekend. A little bit of slope makes up for a lot of Y-intercept.
[Laughter]
import android.os.Build; | |
/** | |
* Utility methods related to physical devies and emulators. | |
*/ | |
public class DeviceUtil { | |
public static boolean isEmulator() { | |
return Build.FINGERPRINT.startsWith("generic") | |
|| Build.FINGERPRINT.startsWith("unknown") |
package com.gabesechan.android.reusable.receivers; | |
import java.util.Date; | |
import android.content.BroadcastReceiver; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.telephony.TelephonyManager; | |
public abstract class PhonecallReceiver extends BroadcastReceiver { |
#dart:convert example
How to pretty-print JSON using Dart.
How to display JSON in an easy-to-read (for human readers) format.
Main library: dart:convert
Main element: JsonEncoder.withIndent
Gist: https://gist.github.com/kasperpeulen/d61029fc0bc6cd104602
// concatAll : Stream (Stream a) -> Stream a | |
Stream.prototype.concatAll = function() { | |
return this.flatten( (s1, s2) => s1.concat(s2) ); | |
} |
Sometimes you need to keep two upstreams in sync with eachother. For example, you might need to both push to your testing environment and your GitHub repo at the same time. In order to do this simultaneously in one git command, here's a little trick to add multiple push URLs to a single remote.
Once you have a remote set up for one of your upstreams, run these commands with:
git remote set-url --add --push [remote] [original repo URL]
git remote set-url --add --push [remote] [second repo URL]
Once set up, git remote -v
should show two (push) URLs and one (fetch) URL. Something like this:
// (c) 2015 Nate Cook, licensed under the MIT license | |
// | |
// Fisher-Yates shuffle as protocol extensions | |
extension CollectionType { | |
/// Return a copy of `self` with its elements shuffled | |
func shuffle() -> [Generator.Element] { | |
var list = Array(self) | |
list.shuffleInPlace() | |
return list |
#!/usr/bin/env python | |
# | |
# I tested by Python 3.4.3 on Windows 8.1 | |
# Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32 | |
import urllib.request | |
import getpass | |
# If you access to url below via Proxy, | |
# set environment variable 'http_proxy' before execute this. |
package com.google.android.exoplayer.demo; | |
import com.facebook.stetho.okhttp.StethoInterceptor; | |
import com.google.android.exoplayer.C; | |
import com.google.android.exoplayer.upstream.DataSpec; | |
import com.google.android.exoplayer.upstream.DefaultHttpDataSource; | |
import com.google.android.exoplayer.upstream.HttpDataSource; | |
import com.google.android.exoplayer.upstream.TransferListener; | |
import com.google.android.exoplayer.util.Assertions; | |
import com.google.android.exoplayer.util.Predicate; |