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.rayer.util.string; | |
import java.io.DataOutputStream; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.FileNotFoundException; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.OutputStream; |
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 <iostream> | |
#include <cstdio> | |
using namespace std; | |
int testCall(int a, int b) { | |
void* p = __builtin_frame_address(0); | |
printf("Function pointer frame : %p\n", p); | |
printf("Param a pointer = %p\n", &a); | |
printf("Param b pointer = %p\n", &b); |
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 <stdlib.h> | |
//CoR in C | |
//這組code可以再多做些什麼呢? | |
//1. 可以替每個handler加上priority | |
//2. 可以改成可變長度list,讓它可以在runtime加 | |
//3. 甚至可以在每次處理以前動態產生一組handler list,可以動態調整 | |
//4. (C++ only)可以做一個模板來compile time產生handler |
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
@Override | |
public boolean mouseMoved(int screenX, int screenY) { | |
screenY -= Gdx.graphics.getHeight(); | |
screenY = -screenY; | |
double length = Math.sqrt(Math.pow(((double)(screenX - sprite.getX())), 2d) + Math.pow((double)(screenY - sprite.getY()), 2d)); | |
sprite.translate((float)((screenX - sprite.getX()) / length), (float)((screenY - sprite.getY()) / length)); | |
System.out.println("Screen : " + screenX + "/" + screenY); |
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
//Update camera position | |
//Camera.x - viewPort.width must > 0, or just set to 0 | |
//Camera.y - viewPort.height must > 0, or just set to 0 | |
//restrict 0, 0 side | |
float cameraX = actor.getX() - (camera.viewportWidth / 2) > 0 ? actor.getX() : camera.viewportWidth / 2; | |
float cameraY = actor.getY() - (camera.viewportHeight / 2) > 0 ? actor.getY() : camera.viewportHeight / 2; | |
//restrict h, w side | |
cameraX = actor.getX() + (camera.viewportWidth / 2) > mapSizeX ? mapSizeX - (camera.viewportWidth / 2) : cameraX; |
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 <iostream> | |
#include <string> | |
#include <typeinfo> | |
using namespace std; | |
class foo { | |
std::string name; | |
public: |
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.util.Random; | |
class Untitled { | |
public static void main(String[] args) { | |
Random random = new Random(); | |
for(int i = 0; i < 100; ++i) { | |
if(random.nextInt() % 4 == 0) | |
System.out.print("O"); | |
else |
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
public class ObjectUtils { | |
public static <T> T initByParent(T target, Object parent) throws IllegalAccessException { | |
Class<?> parentClass = target.getClass().getSuperclass(); | |
if(parent.getClass() != parentClass) { | |
throw new IllegalArgumentException("Invalid parent!"); | |
} | |
Field[] fields = parentClass.getDeclaredFields(); |
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 <iostream> | |
using namespace std; | |
int main(int argc, char *argv[]) { | |
int *i = 0; | |
i += 10; | |
cout << i << endl; | |
cout << *i << endl; | |
} |
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 (^(NSArray* searchImageSuffix) { | |
for(NSString* suffix in searchImageSuffix) { | |
if([shortURL hasSuffix:suffix]) | |
return TRUE; | |
} | |
return FALSE; | |
}(searchImageSuffix)) | |
{ | |
addShortenedURLMenuItem(@"Image search by GOOGLE", [@"https://www.google.com/searchbyimage?&image_url=" stringByAppendingString: shortURL]); | |
} |
OlderNewer