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.FileNotFoundException; | |
import java.io.FileReader; | |
import java.io.IOException; | |
public class ReadFileLineByLine { | |
public static void readFile(String fileName) { | |
try { | |
BufferedReader br = new BufferedReader(new FileReader(fileName)); |
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
<?php | |
/* | |
* I have many .mp3 files with naming rule is: <song's name> - <singer's name> [MP3 320kbps].mp3. Ex: Dao Nguyen - NSUT Thuy Huong [MP3 320kbps].mp3 | |
* I want to rename them using new naming rule is: <song's name>.mp3. Ex: Dao_Nguyen.mp3 | |
*/ | |
date_default_timezone_set('Asia/Ho_Chi_Minh'); | |
$dir = "directory"; |
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
#include <stdio.h> | |
#include <string.h> | |
#include "base64.h" | |
#include "xxtea.h" | |
int main(int argc, const char * argv[]) { | |
const char *key = "123456"; | |
const char *str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit"; | |
size_t len; | |
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
#include <stdio.h> | |
#include <string.h> | |
#include "xxhash.h" | |
int main(int argc, const char * argv[]) { | |
const char *str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit"; | |
unsigned int sum = XXH32(str, strlen(str), 0); | |
printf("hash: %08x\n", sum); | |
return 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
/** | |
* @author quydm | |
*/ | |
public class StringUtils { | |
public static final String EMPTY_STRING = ""; | |
public static String join(Object[] array, String separator) { | |
return join(array, separator, 0, array.length); |
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 android.Manifest; | |
import android.app.Fragment; | |
import android.content.pm.PackageManager; | |
import android.location.Location; | |
import android.os.Bundle; | |
import android.support.v4.content.ContextCompat; | |
import android.util.Log; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; |
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
<?php | |
$file = 'dimens.xml'; | |
$ratio = 1;// change ratio with screen density. Example: ratio = 1 for values, 1.5 for values-hdpi or values-sw600dp | |
$tab_size = ' '; | |
$str = '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL; | |
$str .= '<resources>' . PHP_EOL . PHP_EOL; | |
for ($i = 1; $i <= 600; $i ++) | |
$str .= $tab_size . '<dimen name="n' . $i . 'dp">' . ($i * $ratio) . 'dp</dimen>' . PHP_EOL; |
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
try { | |
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES); | |
for (Signature signature : info.signatures) { | |
MessageDigest md = MessageDigest.getInstance("SHA"); | |
md.update(signature.toByteArray()); | |
Log.d("KeyHash: ", Base64.encodeToString(md.digest(), Base64.DEFAULT)); | |
} | |
} catch (NameNotFoundException e) { | |
e.printStackTrace(); | |
} catch (NoSuchAlgorithmException e) { |