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 Singleton { | |
| private static final Singleton instance = new Singleton(); | |
| private Singleton() { | |
| } | |
| public static Singleton getInstance() { | |
| return instance; | |
| } |
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
| private void getKeyHash() { | |
| try { | |
| PackageInfo info = getPackageManager().getPackageInfo( | |
| "your Application Id", | |
| 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)); | |
| } |
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 String getRealPathFromURI(Context context, Uri contentUri) { | |
| Cursor cursor = null; | |
| try { | |
| String[] proj = {MediaStore.Images.Media.DATA}; | |
| cursor = context.getContentResolver().query(contentUri, proj, null, null, null); | |
| int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); | |
| cursor.moveToFirst(); | |
| return cursor.getString(column_index); | |
| } finally { | |
| if (cursor != null) { |
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 MySubString { | |
| public static void main(String args[]) { | |
| String s1="HuyHung"; | |
| System.out.println(s1.substring(2,4));//return yH | |
| System.out.println(s1.substring(2)); //return yHung | |
| } | |
| } |
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 static void printNameOfVideos(Context context) { | |
| Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; | |
| String[] projection = { MediaStore.Video.VideoColumns.DATA }; | |
| Cursor c = context.getContentResolver().query(uri, projection, null, null, null); | |
| int vidsCount = 0; | |
| if (c != null) { | |
| vidsCount = c.getCount(); | |
| while (c.moveToNext()) { | |
| Log.d("VIDEO", c.getString(0)); | |
| } |
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
| <script> | |
| window.fbAsyncInit = function() { | |
| FB.init({ | |
| appId : 'your facebook app id', | |
| xfbml : true, | |
| version: 'v2.6' | |
| }); | |
| }; | |
| (function(d, s, id) { | |
| var js, fjs = d.getElementsByTagName(s) [0]; |
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
| function removeVietnameseTones(str) { | |
| str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g,"a"); | |
| str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g,"e"); | |
| str = str.replace(/ì|í|ị|ỉ|ĩ/g,"i"); | |
| str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g,"o"); | |
| str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g,"u"); | |
| str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g,"y"); | |
| str = str.replace(/đ/g,"d"); | |
| str = str.replace(/À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ/g, "A"); | |
| str = str.replace(/È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ/g, "E"); |
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
| //nstallation: | |
| //npm install --save xml2js | |
| //Usage: | |
| //Read XML | |
| var returnJSONResults = function(baseName, queryName) { | |
| var XMLPath = "data.xml"; | |
| var rawJSON = loadXMLDoc(XMLPath); | |
| function loadXMLDoc(filePath) { | |
| var fs = require('fs'); | |
| var xml2js = require('xml2js'); |
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
| #include<stdio.h> | |
| int main() | |
| { | |
| char input[200]; | |
| while(1) | |
| { | |
| printf("\n\n"); | |
| gets(input); | |
| printf(input); | |
| } |
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
| int n; | |
| n = int.Parse(Console.ReadLine()); | |
| double sum = 0.0; | |
| for (int iCount = 1; iCount <= n; iCount++) | |
| { | |
| sum = sum + 1 / iCount; | |
| } | |
| Console.WriteLine("Ket qua: {0}", sum); | |
OlderNewer