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
import java.io.BufferedReader; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.FileWriter; | |
import java.io.InputStreamReader; | |
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.List; | |
/** |
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
class Divider { | |
static void divide(int value, int[] out) { | |
float ave = value * 1f / out.length; | |
int integer = (int) ave; | |
float fraction = ave - integer; | |
float sumFraction = 0; | |
int sumInteger = 0; | |
for (int i = 0; i < out.length; i++) { | |
if (i == out.length - 1) { | |
out[i] = value - sumInteger; |
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
package com.github.mzule.doubanhost.plugin; | |
import android.content.ComponentName; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.content.res.AssetManager; | |
import android.os.Handler; | |
import android.os.Message; | |
import com.github.mzule.doubanhost.ui.BlankActivity; |
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
protected static String escape(String text) { | |
// Return null if text is null | |
if (text == null) { | |
return null; | |
} | |
// escape logic. | |
boolean invalidFound = false; | |
char[] chars = new char[text.length()]; | |
for (int i = 0; i < text.length(); i++) { | |
char ch = text.charAt(i); |
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
zip -r demo.zip * |
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
``` | |
yum install yum-plugin-replace | |
yum replace php-common --replace-with=php55w-common | |
``` | |
ref:[http://webtatic.com/packages/php55/](http://webtatic.com/packages/php55/) |
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 img = new Image(); | |
// User Variables - customize these to change the image being scrolled, its | |
// direction, and the speed. | |
img.src = 'https://mdn.mozillademos.org/files/4553/Capitan_Meadows,_Yosemite_National_Park.jpg'; | |
var CanvasXSize = 800; | |
var CanvasYSize = 200; | |
var speed = 30; //lower is faster | |
var scale = 1.05; |
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
import groovy.io.FileType | |
list = [ | |
1, | |
2, | |
'hello', | |
new java.util.Date() | |
] | |
assert list.size() == 4 | |
assert list.get(2) == 'hello' |
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
#if TARGET_OS_IPHONE | |
#import <UIKit/UIKit.h> | |
@interface UIColor (FPBrandColor) | |
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \ | |
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \ | |
blue:((float)(rgbValue & 0xFF))/255.0 \ | |
alpha:1.0] | |
#elif TARGET_OS_MAC |
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
import java.io.*; | |
import java.net.URL; | |
import java.net.URLConnection; | |
public class Main { | |
public static void main(String[] args) throws Exception { | |
InputStream is; | |
URL url = new URL("http://dribbble.com/system/users/1/screenshots/21603/shot_1274474082.png"); | |
URLConnection conn = url.openConnection(); | |
long start = System.currentTimeMillis(); |
NewerOlder